mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-29 13:13:54 +08:00
[offers][feat] add get one profile endpoint
This commit is contained in:
@ -9,7 +9,7 @@ function Test() {
|
||||
limit: 5,
|
||||
location: 'Singapore, Singapore',
|
||||
offset: 0,
|
||||
sortBy: '-totalYoe',
|
||||
sortBy: '-monthYearReceived',
|
||||
yoeCategory: 1,
|
||||
},
|
||||
]);
|
||||
|
@ -38,7 +38,7 @@ function Test() {
|
||||
],
|
||||
"experiences": [
|
||||
{
|
||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
||||
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||
"durationInMonths": 24,
|
||||
"jobType": "FULLTIME",
|
||||
"level": "Junior",
|
||||
@ -66,7 +66,7 @@ function Test() {
|
||||
"offers": [
|
||||
{
|
||||
"comments": "",
|
||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
||||
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||
"job": {
|
||||
"base": {
|
||||
"currency": "SGD",
|
||||
@ -95,7 +95,7 @@ function Test() {
|
||||
},
|
||||
{
|
||||
"comments": "",
|
||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
||||
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||
"job": {
|
||||
"base": {
|
||||
"currency": "SGD",
|
||||
@ -126,6 +126,14 @@ function Test() {
|
||||
});
|
||||
};
|
||||
|
||||
const data = trpc.useQuery([
|
||||
`offers.profile.listOne`,
|
||||
{
|
||||
profileId: "cl92wc64a004gw3hgq4pfln2m"
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
return (
|
||||
// <ul>
|
||||
// {createdData.map((x) => {
|
||||
@ -136,8 +144,11 @@ function Test() {
|
||||
<div>
|
||||
{createdData}
|
||||
</div>
|
||||
<button type="button" onClick={handleClick}>Click me</button>
|
||||
</>
|
||||
<button type="button" onClick={handleClick}>Click Me!</button>
|
||||
<div>{JSON.stringify(data.data)}</div>
|
||||
|
||||
{/* <button type="button" onClick}>Get One</button> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,59 @@ const education = z.object({
|
||||
type: z.string().optional(),
|
||||
})
|
||||
|
||||
export const offersProfileRouter = createRouter().mutation(
|
||||
export const offersProfileRouter = createRouter()
|
||||
.query('listOne', {
|
||||
input: z.object({
|
||||
profileId: z.string(),
|
||||
}),
|
||||
async resolve({ ctx, input }) {
|
||||
return await ctx.prisma.offersProfile.findFirst({
|
||||
include: {
|
||||
background: {
|
||||
include: {
|
||||
educations: true,
|
||||
experiences: {
|
||||
include: {
|
||||
company: true,
|
||||
monthlySalary: true,
|
||||
totalCompensation: true
|
||||
}
|
||||
},
|
||||
specificYoes: true
|
||||
}
|
||||
},
|
||||
discussion: {
|
||||
include: {
|
||||
replies: true,
|
||||
replyingTo: true
|
||||
}
|
||||
},
|
||||
offers: {
|
||||
include: {
|
||||
OffersFullTime: {
|
||||
include: {
|
||||
baseSalary: true,
|
||||
bonus: true,
|
||||
stocks: true,
|
||||
totalCompensation: true
|
||||
}
|
||||
},
|
||||
OffersIntern: {
|
||||
include: {
|
||||
monthlySalary: true
|
||||
}
|
||||
},
|
||||
company: true
|
||||
}
|
||||
}
|
||||
},
|
||||
where: {
|
||||
id: input.profileId
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
.mutation(
|
||||
'create',
|
||||
{
|
||||
input: z.object({
|
||||
@ -59,7 +111,7 @@ export const offersProfileRouter = createRouter().mutation(
|
||||
experiences: z.array(experience),
|
||||
specificYoes: z.array(z.object({
|
||||
domain: z.string(),
|
||||
yoe: z.number()
|
||||
yoe: z.number(),
|
||||
})),
|
||||
totalYoe: z.number().optional(),
|
||||
}),
|
||||
@ -136,10 +188,12 @@ export const offersProfileRouter = createRouter().mutation(
|
||||
},
|
||||
specificYoes: {
|
||||
create:
|
||||
input.background.specificYoes.map((x) => ({
|
||||
domain: x.domain,
|
||||
yoe: x.yoe
|
||||
}))
|
||||
input.background.specificYoes.map((x) => {
|
||||
return {
|
||||
domain: x.domain,
|
||||
yoe: x.yoe
|
||||
}
|
||||
})
|
||||
},
|
||||
totalYoe: input.background.totalYoe,
|
||||
}
|
||||
@ -226,7 +280,7 @@ export const offersProfileRouter = createRouter().mutation(
|
||||
throw Prisma.PrismaClientKnownRequestError
|
||||
})
|
||||
},
|
||||
profileName: randomUUID(),
|
||||
profileName: randomUUID().substring(0,10),
|
||||
},
|
||||
include: {
|
||||
background: {
|
||||
|
Reference in New Issue
Block a user