Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/app/sell/add-item/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function AddItemPage() {
mode="create"
submitLabel="Post Item to Swapeeee"
onCancel={() => router.push("/sell")}
onSuccess={() => router.push("/sell")}
/>
</main>
</>
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/components/itemForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<section className="min-h-screen flex flex-col mx-4 py-8 bg-white md:py-16 dark:bg-neutral-700 antialiased">
{onCancel && (
Expand Down Expand Up @@ -301,6 +314,12 @@ export default function ItemForm({
type="button"
onClick={handleSubmit}
/>
<PrimaryButton
text="Remove Item"
type="button"
onClick={onCancel}
className="ms-4 bg-gray-300 hover:bg-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-800 dark:text-gray-200"
/>
</div>
</section>
);
Expand Down
Loading