mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 20:52:00 +08:00
[offers][chore] standardise input fields for delete and get profile
This commit is contained in:
@ -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([
|
||||
`offers.profile.listOne`,
|
||||
{
|
||||
profileId,
|
||||
token: '6c8d53530163bb765c42bd9f441aa7e345f607c4e1892edbc64e5bbbbe7ee916',
|
||||
token: 'e5e1951c9c301ab59bf4cad641e2e7b56c3db58aa852cee755b6ff8dd316cda6',
|
||||
},
|
||||
]);
|
||||
|
||||
@ -139,8 +139,8 @@ function Test() {
|
||||
|
||||
const handleDelete = (id: string) => {
|
||||
deleteMutation.mutate({
|
||||
id,
|
||||
token: '6c8d53530163bb765c42bd9f441aa7e345f607c4e1892edbc64e5bbbbe7ee916',
|
||||
profileId: id,
|
||||
token: 'e5e1951c9c301ab59bf4cad641e2e7b56c3db58aa852cee755b6ff8dd316cda6',
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -400,13 +400,13 @@ export const offersProfileRouter = createRouter()
|
||||
})
|
||||
.mutation('delete', {
|
||||
input: z.object({
|
||||
id: z.string(),
|
||||
profileId: z.string(),
|
||||
token: z.string(),
|
||||
}),
|
||||
async resolve({ ctx, input }) {
|
||||
const profileToDelete = await ctx.prisma.offersProfile.findFirst({
|
||||
where: {
|
||||
id: input.id,
|
||||
id: input.profileId,
|
||||
},
|
||||
});
|
||||
const profileEditToken = profileToDelete?.editToken;
|
||||
@ -414,7 +414,7 @@ export const offersProfileRouter = createRouter()
|
||||
if (profileEditToken === input.token) {
|
||||
return await ctx.prisma.offersProfile.delete({
|
||||
where: {
|
||||
id: input.id,
|
||||
id: input.profileId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user