Skip to content

Commit

Permalink
Add a button to delete models
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Apr 22, 2024
1 parent 78e719c commit f5c20f3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/pages/models/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetStaticPaths, GetStaticProps } from 'next';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { ParsedUrlQuery } from 'querystring';
import React, { ReactNode, useMemo } from 'react';
import { AiFillEdit } from 'react-icons/ai';
Expand Down Expand Up @@ -377,6 +378,8 @@ export default function Page({ modelId, similar: staticSimilar, modelData: stati
}
}, [staticSimilar, staticModelData, modelData, modelId, archData]);

const router = useRouter();

return (
<>
<HeadCommon
Expand Down Expand Up @@ -417,6 +420,27 @@ export default function Page({ modelId, similar: staticSimilar, modelData: stati
/>
<div className="relative">
<div>
{editMode && (
<div className="text-right">
<button
onClick={() => {
if (confirm('Are you sure you want to delete this model?')) {
webApi.models.delete([modelId]).then(
() => {
router.push('/').catch(console.error);
},
(e) => {
console.error(e);
alert(`Error deleting model: ${String(e)}`);
}
);
}
}}
>
Delete Model
</button>
</div>
)}
<h1 className="mt-0 mb-1 leading-10">
<EditableLabel
readonly={!editMode}
Expand Down

0 comments on commit f5c20f3

Please sign in to comment.