diff --git a/app/features/art/ArtRepository.server.ts b/app/features/art/ArtRepository.server.ts new file mode 100644 index 000000000..15475d704 --- /dev/null +++ b/app/features/art/ArtRepository.server.ts @@ -0,0 +1,15 @@ +import { db } from "~/db/sql"; + +export function unlinkUserFromArt({ + userId, + artId, +}: { + userId: number; + artId: number; +}) { + return db + .deleteFrom("ArtUserMetadata") + .where("artId", "=", artId) + .where("userId", "=", userId) + .execute(); +} diff --git a/app/features/art/art-schemas.server.ts b/app/features/art/art-schemas.server.ts index f95143130..d6667c98b 100644 --- a/app/features/art/art-schemas.server.ts +++ b/app/features/art/art-schemas.server.ts @@ -1,5 +1,6 @@ import { z } from "zod"; import { + _action, checkboxValueToDbBoolean, dbBoolean, falsyToNull, @@ -43,5 +44,16 @@ export const editArtSchema = z.object({ }); export const deleteArtSchema = z.object({ + _action: _action("DELETE_ART"), id, }); + +export const unlinkArtSchema = z.object({ + _action: _action("UNLINK_ART"), + id, +}); + +export const userArtPageActionSchema = z.union([ + deleteArtSchema, + unlinkArtSchema, +]); diff --git a/app/features/art/components/ArtGrid.tsx b/app/features/art/components/ArtGrid.tsx index 393d37c76..35ed2197e 100644 --- a/app/features/art/components/ArtGrid.tsx +++ b/app/features/art/components/ArtGrid.tsx @@ -9,6 +9,7 @@ import { FormWithConfirm } from "~/components/FormWithConfirm"; import { Pagination } from "~/components/Pagination"; import { EditIcon } from "~/components/icons/Edit"; import { TrashIcon } from "~/components/icons/Trash"; +import { UnlinkIcon } from "~/components/icons/Unlink"; import { useIsMounted } from "~/hooks/useIsMounted"; import { usePagination } from "~/hooks/usePagination"; import { useSearchParamState } from "~/hooks/useSearchParamState"; @@ -191,8 +192,11 @@ function ImagePreview({ {t("common:actions.edit")}