✨ Able to delete product
This commit is contained in:
parent
9a265c9887
commit
79e7709cc1
@ -29,6 +29,14 @@ export default function MatrixMarketplace() {
|
|||||||
fetchProducts()
|
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 (
|
return (
|
||||||
<ConsoleLayout>
|
<ConsoleLayout>
|
||||||
<Container sx={{ py: 16, display: 'flex', flexDirection: 'column', gap: 4 }}>
|
<Container sx={{ py: 16, display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||||
@ -53,6 +61,9 @@ export default function MatrixMarketplace() {
|
|||||||
<NextLink passHref href={`/console/matrix/products/${p.id}/edit`}>
|
<NextLink passHref href={`/console/matrix/products/${p.id}/edit`}>
|
||||||
<Button size="small">Edit</Button>
|
<Button size="small">Edit</Button>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
|
<Button size="small" color="error" onClick={() => deleteProduct(p.id)}>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
</CardActions>
|
</CardActions>
|
||||||
</Card>
|
</Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -25,6 +25,14 @@ export const getServerSideProps: GetServerSideProps = (async (context) => {
|
|||||||
}) satisfies GetServerSideProps<{ product: MaProduct; releases: any[] }>
|
}) satisfies GetServerSideProps<{ product: MaProduct; releases: any[] }>
|
||||||
|
|
||||||
export default function ProductDetails({ product, releases }: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
export default function ProductDetails({ product, releases }: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
||||||
|
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 (
|
return (
|
||||||
<ConsoleLayout>
|
<ConsoleLayout>
|
||||||
<Container sx={{ py: 16, display: 'flex', flexDirection: 'column', gap: 8 }}>
|
<Container sx={{ py: 16, display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||||
@ -63,6 +71,9 @@ export default function ProductDetails({ product, releases }: InferGetServerSide
|
|||||||
<NextLink passHref href={`/console/matrix/products/${r.productId}/releases/${r.id}/edit`}>
|
<NextLink passHref href={`/console/matrix/products/${r.productId}/releases/${r.id}/edit`}>
|
||||||
<Button size="small">Edit</Button>
|
<Button size="small">Edit</Button>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
|
<Button size="small" color="error" onClick={() => deleteRelease(r.id)}>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
</CardActions>
|
</CardActions>
|
||||||
</Card>
|
</Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user