[offers][feat] add get one profile endpoint

pull/356/head
Stuart Long Chay Boon 2 years ago
parent 3c90c2f7e9
commit 6ff3842d5e

@ -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,7 +144,10 @@ 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) => {
return {
domain: x.domain, domain: x.domain,
yoe: x.yoe 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: {

Loading…
Cancel
Save