diff --git a/api/src/services/ik/rewardablePuzzle/rewardablePuzzleService.ts b/api/src/services/ik/rewardablePuzzle/rewardablePuzzleService.ts index 751054a0a..aff5ad09c 100644 --- a/api/src/services/ik/rewardablePuzzle/rewardablePuzzleService.ts +++ b/api/src/services/ik/rewardablePuzzle/rewardablePuzzleService.ts @@ -46,9 +46,13 @@ export const editRewardablePuzzle: MutationResolvers['editRewardablePuzzle'] = const prevRewardable = await db.rewardable.findUnique({ where: { id: rewardableId }, - select: { name: true, slug: true }, + select: { name: true, slug: true, trashedAt: true }, }) + if (prevRewardable?.trashedAt) { + throw new Error("Cannot edit a puzzle that's in the trash") + } + const steps = formatCreateSteps(input.puzzle.steps) const slug = prevRewardable?.name === input.name diff --git a/api/src/services/ik/rewardables/rewardables.ts b/api/src/services/ik/rewardables/rewardables.ts index 350cba247..a732de915 100644 --- a/api/src/services/ik/rewardables/rewardables.ts +++ b/api/src/services/ik/rewardables/rewardables.ts @@ -20,6 +20,9 @@ export const rewardableBySlug: QueryResolvers['rewardableBySlug'] = ({ slug, type, }, + trashedAt: { + equals: null, + }, }, }) } @@ -57,6 +60,7 @@ export const rewardablesBySortType: QueryResolvers['rewardablesBySortType'] = ({ where: { sortType, listPublicly: true, + trashedAt: { equals: null }, }, }) } @@ -73,7 +77,13 @@ export const rewardablesCollection: QueryResolvers['rewardablesCollection'] = ? count : smallestPaginationCount - const typesFilter = types.map((type) => ({ type, listPublicly: true })) + const typesFilter = types.map((type) => ({ + type, + listPublicly: true, + trashedAt: { + equals: null, + }, + })) const totalCount = await db.rewardable.count({ where: { OR: typesFilter }, }) diff --git a/web/src/components/ProfileCell/ProfileCell.tsx b/web/src/components/ProfileCell/ProfileCell.tsx index 22773efa6..32e1e380f 100644 --- a/web/src/components/ProfileCell/ProfileCell.tsx +++ b/web/src/components/ProfileCell/ProfileCell.tsx @@ -12,6 +12,7 @@ import type { UserRewardablesQuery, } from 'types/graphql' +import { routes } from '@redwoodjs/router' import { useQuery, CellSuccessProps, @@ -79,6 +80,7 @@ const USER_REWARDABLES_QUERY = gql` query UserRewardablesQuery($userId: String!) { userRewardables(userId: $userId) { id + trashedAt name slug nfts { @@ -120,6 +122,13 @@ export const Success = ({ variables: { userId: user?.id }, }) + const liveRewardables = data?.userRewardables.filter( + (rewardable) => !rewardable.trashedAt + ) + const trashedRewardables = data?.userRewardables.filter( + (rewardable) => rewardable.trashedAt + ) + return (
@@ -312,31 +321,55 @@ export const Success = ({
-
-
-
-

Your Puzzles & Packs

-
+ {(!!liveRewardables?.length || !!trashedRewardables?.length) && ( +
+
+
+

Your Puzzles & Packs

+
-
-
- {data?.userRewardables.map((rewardable) => ( - - ))} +
+ {!!liveRewardables?.length && ( +
+ {liveRewardables?.map((rewardable) => ( + + ))} +
+ )} + + {!!trashedRewardables?.length && ( + <> +

Puzzles and packs in trash

+
+ {trashedRewardables?.map((rewardable) => ( + + ))} +
+ + )}
-
+ )}
) }