From 79e7709cc19ae9a3253c095cfa1a7ebec4af4566 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 11 Jan 2025 00:12:03 +0800 Subject: [PATCH] :sparkles: Able to delete product --- src/pages/console/matrix/index.tsx | 11 +++++++++++ src/pages/console/matrix/products/[id]/index.tsx | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/pages/console/matrix/index.tsx b/src/pages/console/matrix/index.tsx index 916162d..9d8dbad 100644 --- a/src/pages/console/matrix/index.tsx +++ b/src/pages/console/matrix/index.tsx @@ -29,6 +29,14 @@ export default function MatrixMarketplace() { fetchProducts() }, []) + async function deleteProduct(id: number) { + const yes = confirm(`Are you sure you want to delete this product #${id}?`) + if (!yes) return + + await sni.delete('/cgi/ma/products/' + id) + window.location.reload() + } + return ( @@ -53,6 +61,9 @@ export default function MatrixMarketplace() { + diff --git a/src/pages/console/matrix/products/[id]/index.tsx b/src/pages/console/matrix/products/[id]/index.tsx index 2f9a566..ec69c58 100644 --- a/src/pages/console/matrix/products/[id]/index.tsx +++ b/src/pages/console/matrix/products/[id]/index.tsx @@ -25,6 +25,14 @@ export const getServerSideProps: GetServerSideProps = (async (context) => { }) satisfies GetServerSideProps<{ product: MaProduct; releases: any[] }> export default function ProductDetails({ product, releases }: InferGetServerSidePropsType) { + async function deleteRelease(id: number) { + const yes = confirm(`Are you sure you want to delete this release #${id}?`) + if (!yes) return + + await sni.delete('/cgi/ma/products/' + product.id + '/releases/' + id) + window.location.reload() + } + return ( @@ -63,6 +71,9 @@ export default function ProductDetails({ product, releases }: InferGetServerSide +