(
{
deleteItem,
categoryValue,
categories,
fetchItems,
updateItem,
onCancel,
visible,
onClose,
onOk,
record
})
| 11 | import { ButtonGroup, ModalTitle } from "./styles"; |
| 12 | |
| 13 | const EditForm: React.FC<FormSpecs.Props> = ( |
| 14 | { |
| 15 | deleteItem, |
| 16 | categoryValue, |
| 17 | categories, |
| 18 | fetchItems, |
| 19 | updateItem, |
| 20 | onCancel, |
| 21 | visible, |
| 22 | onClose, |
| 23 | onOk, |
| 24 | record |
| 25 | }) => { |
| 26 | const handleDelete = () => { |
| 27 | deleteItem(record.id).then(() => { |
| 28 | onClose(); |
| 29 | fetchItems(); |
| 30 | }); |
| 31 | }; |
| 32 | |
| 33 | const renderFooter = () => ( |
| 34 | <ButtonGroup> |
| 35 | <div> |
| 36 | <Popconfirm title="Are you sure you want to delete this item?" |
| 37 | okText="Delete" |
| 38 | placement="bottom" |
| 39 | onConfirm={handleDelete}> |
| 40 | <Button type="danger"> |
| 41 | Delete |
| 42 | </Button> |
| 43 | </Popconfirm> |
| 44 | </div> |
| 45 | <div> |
| 46 | <Button onClick={onCancel}> |
| 47 | Cancel |
| 48 | </Button> |
| 49 | <Button type="primary" onClick={onOk}> |
| 50 | Save Changes |
| 51 | </Button> |
| 52 | </div> |
| 53 | </ButtonGroup> |
| 54 | ); |
| 55 | |
| 56 | const { product_name, name, weight_unit, weight, product_url } = record; |
| 57 | return ( |
| 58 | <Modal |
| 59 | title={<ModalTitle>Edit Item</ModalTitle>} |
| 60 | visible={visible} |
| 61 | onCancel={onCancel} |
| 62 | footer={renderFooter()} |
| 63 | > |
| 64 | <Input label="Item Type" |
| 65 | placeholder="Backpack, Compass, etc..." |
| 66 | value={name} |
| 67 | onChange={v => updateItem('name', v)} |
| 68 | /> |
| 69 | |
| 70 | <SelectCreatable |
nothing calls this directly
no test coverage detected