[offers][chore] standardise input fields for delete and get profile

This commit is contained in:
Stuart Long Chay Boon
2022-10-12 23:03:00 +08:00
parent 9595aabccf
commit e8ef133a88
2 changed files with 7 additions and 7 deletions

View File

@ -126,12 +126,12 @@ function Test() {
}); });
}; };
const profileId = 'cl93vo4w9009ow35mx7gemrzb'; // Remember to change this filed after testing deleting const profileId = 'cl93vnvs1007aw35m9ppn7dsy'; // Remember to change this filed after testing deleting
const data = trpc.useQuery([ const data = trpc.useQuery([
`offers.profile.listOne`, `offers.profile.listOne`,
{ {
profileId, profileId,
token: '6c8d53530163bb765c42bd9f441aa7e345f607c4e1892edbc64e5bbbbe7ee916', token: 'e5e1951c9c301ab59bf4cad641e2e7b56c3db58aa852cee755b6ff8dd316cda6',
}, },
]); ]);
@ -139,8 +139,8 @@ function Test() {
const handleDelete = (id: string) => { const handleDelete = (id: string) => {
deleteMutation.mutate({ deleteMutation.mutate({
id, profileId: id,
token: '6c8d53530163bb765c42bd9f441aa7e345f607c4e1892edbc64e5bbbbe7ee916', token: 'e5e1951c9c301ab59bf4cad641e2e7b56c3db58aa852cee755b6ff8dd316cda6',
}); });
}; };

View File

@ -400,13 +400,13 @@ export const offersProfileRouter = createRouter()
}) })
.mutation('delete', { .mutation('delete', {
input: z.object({ input: z.object({
id: z.string(), profileId: z.string(),
token: z.string(), token: z.string(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const profileToDelete = await ctx.prisma.offersProfile.findFirst({ const profileToDelete = await ctx.prisma.offersProfile.findFirst({
where: { where: {
id: input.id, id: input.profileId,
}, },
}); });
const profileEditToken = profileToDelete?.editToken; const profileEditToken = profileToDelete?.editToken;
@ -414,7 +414,7 @@ export const offersProfileRouter = createRouter()
if (profileEditToken === input.token) { if (profileEditToken === input.token) {
return await ctx.prisma.offersProfile.delete({ return await ctx.prisma.offersProfile.delete({
where: { where: {
id: input.id, id: input.profileId,
}, },
}); });
} }