mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-31 06:03:55 +08:00
[offers][feat] add get one profile endpoint
This commit is contained in:
@ -9,7 +9,7 @@ function Test() {
|
|||||||
limit: 5,
|
limit: 5,
|
||||||
location: 'Singapore, Singapore',
|
location: 'Singapore, Singapore',
|
||||||
offset: 0,
|
offset: 0,
|
||||||
sortBy: '-totalYoe',
|
sortBy: '-monthYearReceived',
|
||||||
yoeCategory: 1,
|
yoeCategory: 1,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -38,7 +38,7 @@ function Test() {
|
|||||||
],
|
],
|
||||||
"experiences": [
|
"experiences": [
|
||||||
{
|
{
|
||||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||||
"durationInMonths": 24,
|
"durationInMonths": 24,
|
||||||
"jobType": "FULLTIME",
|
"jobType": "FULLTIME",
|
||||||
"level": "Junior",
|
"level": "Junior",
|
||||||
@ -66,7 +66,7 @@ function Test() {
|
|||||||
"offers": [
|
"offers": [
|
||||||
{
|
{
|
||||||
"comments": "",
|
"comments": "",
|
||||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||||
"job": {
|
"job": {
|
||||||
"base": {
|
"base": {
|
||||||
"currency": "SGD",
|
"currency": "SGD",
|
||||||
@ -95,7 +95,7 @@ function Test() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"comments": "",
|
"comments": "",
|
||||||
"companyId": "cl92ly8xm0000w3mwh5ymyqmx",
|
"companyId": "cl92szctf0008i9nfxk54bhxn",
|
||||||
"job": {
|
"job": {
|
||||||
"base": {
|
"base": {
|
||||||
"currency": "SGD",
|
"currency": "SGD",
|
||||||
@ -126,6 +126,14 @@ function Test() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const data = trpc.useQuery([
|
||||||
|
`offers.profile.listOne`,
|
||||||
|
{
|
||||||
|
profileId: "cl92wc64a004gw3hgq4pfln2m"
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// <ul>
|
// <ul>
|
||||||
// {createdData.map((x) => {
|
// {createdData.map((x) => {
|
||||||
@ -136,8 +144,11 @@ function Test() {
|
|||||||
<div>
|
<div>
|
||||||
{createdData}
|
{createdData}
|
||||||
</div>
|
</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(),
|
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',
|
'create',
|
||||||
{
|
{
|
||||||
input: z.object({
|
input: z.object({
|
||||||
@ -59,7 +111,7 @@ export const offersProfileRouter = createRouter().mutation(
|
|||||||
experiences: z.array(experience),
|
experiences: z.array(experience),
|
||||||
specificYoes: z.array(z.object({
|
specificYoes: z.array(z.object({
|
||||||
domain: z.string(),
|
domain: z.string(),
|
||||||
yoe: z.number()
|
yoe: z.number(),
|
||||||
})),
|
})),
|
||||||
totalYoe: z.number().optional(),
|
totalYoe: z.number().optional(),
|
||||||
}),
|
}),
|
||||||
@ -136,10 +188,12 @@ export const offersProfileRouter = createRouter().mutation(
|
|||||||
},
|
},
|
||||||
specificYoes: {
|
specificYoes: {
|
||||||
create:
|
create:
|
||||||
input.background.specificYoes.map((x) => ({
|
input.background.specificYoes.map((x) => {
|
||||||
domain: x.domain,
|
return {
|
||||||
yoe: x.yoe
|
domain: x.domain,
|
||||||
}))
|
yoe: x.yoe
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
totalYoe: input.background.totalYoe,
|
totalYoe: input.background.totalYoe,
|
||||||
}
|
}
|
||||||
@ -226,7 +280,7 @@ export const offersProfileRouter = createRouter().mutation(
|
|||||||
throw Prisma.PrismaClientKnownRequestError
|
throw Prisma.PrismaClientKnownRequestError
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
profileName: randomUUID(),
|
profileName: randomUUID().substring(0,10),
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
background: {
|
background: {
|
||||||
|
Reference in New Issue
Block a user