diff --git a/frontend/src/app/sell/add-item/page.tsx b/frontend/src/app/sell/add-item/page.tsx index 30b69c4..f9e9a02 100644 --- a/frontend/src/app/sell/add-item/page.tsx +++ b/frontend/src/app/sell/add-item/page.tsx @@ -18,6 +18,7 @@ export default function AddItemPage() { mode="create" submitLabel="Post Item to Swapeeee" onCancel={() => router.push("/sell")} + onSuccess={() => router.push("/sell")} /> diff --git a/frontend/src/components/itemForm.tsx b/frontend/src/components/itemForm.tsx index 3562aa1..34b4269 100644 --- a/frontend/src/components/itemForm.tsx +++ b/frontend/src/components/itemForm.tsx @@ -162,6 +162,19 @@ export default function ItemForm({ } }; + const handleRemove = async () => { + try{ + if (itemId == null) { + setSubmitError("Missing item id."); + return; + } + await api.items.delete(itemId); + onSuccess?.(); + } catch (e) { + setSubmitError(handleApiError(e)); + } + } + return (
{onCancel && ( @@ -301,6 +314,12 @@ export default function ItemForm({ type="button" onClick={handleSubmit} /> +
);