diff --git a/src/features/products/components/DeleteAllProducts.tsx b/src/features/products/components/DeleteAllProducts.tsx new file mode 100644 index 00000000..14d3682f --- /dev/null +++ b/src/features/products/components/DeleteAllProducts.tsx @@ -0,0 +1,65 @@ +import React, { useState } from 'react'; +import { Button, Dialog } from '~/components'; +import { Icons } from '~/lib/phosphor'; + +interface DeleteAllProductsProps { + disabled: boolean; + n: number; + onConfirm: () => void; +} + +const DeleteAllProducts: React.FC = ({ + disabled, + n, + onConfirm, +}) => { + const [isDialogOpen, setIsDialogOpen] = useState(false); + + const openDialog = () => setIsDialogOpen(true); + const closeDialog = () => setIsDialogOpen(false); + + const nString = `${n} product${n === 1 ? '' : 's'}`; + + return ( + <> + + + Cancel + , + , + ]} + > + You are about to delete {nString}. +
+
+ This action cannot be undone. +
+ + ); +}; + +export default DeleteAllProducts; diff --git a/src/features/products/routes/Products.tsx b/src/features/products/routes/Products.tsx index 92d1ef25..515de1d9 100644 --- a/src/features/products/routes/Products.tsx +++ b/src/features/products/routes/Products.tsx @@ -6,6 +6,7 @@ import { useDeleteProducts, useQueryProducts, } from '~/features/products'; +import DeleteAllProducts from '~/features/products/components/DeleteAllProducts'; import { ProductsList } from '../components'; import { Icons } from '~/lib/phosphor'; @@ -22,46 +23,9 @@ export function Products() {
{/* Temporary delete all products button until we have a proper header for that */} {/* TODO: isolate this into a component */} - - setIsDialogOpen(false)} - title={`Delete ${nString}`} - actions={[ - , - , - ]} - > - You are about to delete {nString}. -
-
- This action cannot be undone. -
+ {/* TODO: add tooltip? Not sure if we need it. Find examples of this*/} + {/*// size="md" TODO: match the size of the icon to the size specified here. */} + mutate()} />