diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2ca430b..0a9465a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -70,7 +70,7 @@ type Photo { model AuditoryResource { id String @id @default(auto()) @map("_id") @db.ObjectId - icon String + icon String? name String description String photo Photo? diff --git a/src/components/ResourcePhoto.tsx b/src/components/ResourcePhoto.tsx index df56ba2..443b26d 100644 --- a/src/components/ResourcePhoto.tsx +++ b/src/components/ResourcePhoto.tsx @@ -8,7 +8,7 @@ type ResourcePhotoProps = ( src: string | undefined; } | { - src: string; + src: string | undefined; photo: null; } ) & { name: string }; diff --git a/src/components/admin/common.tsx b/src/components/admin/common.tsx index ce1ae95..71beaa8 100644 --- a/src/components/admin/common.tsx +++ b/src/components/admin/common.tsx @@ -1,4 +1,6 @@ +import { ExclamationCircleIcon } from "@heroicons/react/24/solid"; import Link from "next/link"; +import { useEffect, useState } from "react"; const AdminActionBody = ({ label, @@ -38,17 +40,67 @@ const AdminActionLink = ({ ); }; +const AdminActionConfirmButton = ({ + label, + onConfirm, + symbol, + type = "button", +}: { + label: string; + onConfirm?: () => void; + symbol: JSX.Element | undefined; + type?: HTMLButtonElement["type"]; +}) => { + const [isConfirmView, setConfirmView] = useState(false); + + useEffect(() => { + if (!isConfirmView) { + return; + } + + setTimeout(() => { + if (isConfirmView) { + setConfirmView(false); + } + }, 5000); + }, [isConfirmView]); + + if (isConfirmView) { + return ( + } + label={`Confirm ${label}`} + onClick={onConfirm} + type={type} + /> + ); + } + + return ( + { + setConfirmView(true); + }} + /> + ); +}; + const AdminActionButton = ({ label, onClick, symbol, + type = "button", }: { label: string; - onClick: () => void; + onClick?: () => void; symbol: JSX.Element | undefined; + type?: HTMLButtonElement["type"]; }) => { return ( @@ -352,16 +361,18 @@ function ResourceSummarySubForm({ @@ -369,12 +380,37 @@ function ResourceSummarySubForm({ + +
+ +
+ + - + +
+
+ @@ -404,7 +440,7 @@ function ResourceSummarySubForm({ @@ -446,7 +482,7 @@ const ResourceDescriptionSubForm = () => {