mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 04:33:42 +08:00
[offers][feat] add isValidToken endpoint
This commit is contained in:
@ -205,6 +205,22 @@ function Test() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
trpc.useQuery(
|
||||||
|
[
|
||||||
|
`offers.profile.isValidToken`,
|
||||||
|
{
|
||||||
|
profileId: 'cl9scdzuh0000tt727ipone1k',
|
||||||
|
token:
|
||||||
|
'aa628d0db3ad7a5f84895537d4cca38edd0a9b8b96d869cddeb967fccf068c08',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{
|
||||||
|
onError(err) {
|
||||||
|
setError(err.shape?.message || '');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const replies = trpc.useQuery(
|
const replies = trpc.useQuery(
|
||||||
['offers.comments.getComments', { profileId }],
|
['offers.comments.getComments', { profileId }],
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,21 @@ const education = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const offersProfileRouter = createRouter()
|
export const offersProfileRouter = createRouter()
|
||||||
|
.query('isValidToken', {
|
||||||
|
input: z.object({
|
||||||
|
profileId: z.string(),
|
||||||
|
token: z.string(),
|
||||||
|
}),
|
||||||
|
async resolve({ ctx, input }) {
|
||||||
|
const profile = await ctx.prisma.offersProfile.findFirst({
|
||||||
|
where: {
|
||||||
|
id: input.profileId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return profile?.editToken === input.token
|
||||||
|
}
|
||||||
|
})
|
||||||
.query('listOne', {
|
.query('listOne', {
|
||||||
input: z.object({
|
input: z.object({
|
||||||
profileId: z.string(),
|
profileId: z.string(),
|
||||||
|
Reference in New Issue
Block a user