dry-scarletD
Refine2y ago
19 replies
dry-scarlet

Make Custom Item in Form Item

how to make this
            <Form.Item
               label="Status"
               name={["status"]}
               rules={[{required: true,},]}

            >
               <Input />
            </Form.Item>


to be like this

               <Table.Column
                  dataIndex="status"
                  title="Status"
                  render={(value: string) => {
                     // Define a function to determine color and icon based on status
                     const getStatusProps = (status: string) => {
                        switch (status) {
                           case "diproses":
                              return {
                                 color: "warning",
                                 icon: <ExclamationCircleOutlined />,
                              };
                           case "selesai":
                              return {
                                 color: "success",
                                 icon: <CheckCircleOutlined />,
                              };
                           default:
                              return {
                                 color: "default",
                                 icon: <CheckCircleOutlined />,
                              }; // Default case
                        }
                     };

                     const { color, icon } = getStatusProps(value);

                     // Use the getStatusProps function to dynamically set the color and icon
                     return (
                        <TagField icon={icon} color={color} value={value} />
                     );
                  }}
               />
Was this page helpful?