From 18d2a10708ff13deb83aa65814db332c73989420 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Fri, 21 Oct 2022 15:33:07 +0800 Subject: [PATCH 01/23] [resumes][feat] update top upvoted comment count --- apps/portal/src/server/router/resumes/resumes-resume-router.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/portal/src/server/router/resumes/resumes-resume-router.ts b/apps/portal/src/server/router/resumes/resumes-resume-router.ts index bda6464f..fe3b1d57 100644 --- a/apps/portal/src/server/router/resumes/resumes-resume-router.ts +++ b/apps/portal/src/server/router/resumes/resumes-resume-router.ts @@ -213,7 +213,8 @@ export const resumesRouter = createRouter() let topUpvotedCommentCount = 0; for (const resume of resumes) { - let highestVoteCount = 1; + // Set minimum upvote count >= 5 to qualify + let highestVoteCount = 5; // Get Map of {userId, voteCount} for each comment const commentUpvotePairs = []; From 6a665bc9760197dc36a4b7afad32b4b9f173199f Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Fri, 21 Oct 2022 15:46:23 +0800 Subject: [PATCH 02/23] [offers][chore] remove profileName and discussion from editprofile --- .../src/pages/offers/test/createProfile.tsx | 430 +++++++++--------- .../router/offers/offers-profile-router.ts | 46 +- 2 files changed, 243 insertions(+), 233 deletions(-) diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx index ad891ce1..8c3f0ff9 100644 --- a/apps/portal/src/pages/offers/test/createProfile.tsx +++ b/apps/portal/src/pages/offers/test/createProfile.tsx @@ -192,7 +192,7 @@ function Test() { }); }; - const profileId = 'cl9efyn9p004ww3u42mjgl1vn'; // Remember to change this filed after testing deleting + const profileId = 'cl9i68fv60000tthj8t3zkox0'; // Remember to change this filed after testing deleting const data = trpc.useQuery( [ `offers.profile.listOne`, @@ -241,10 +241,10 @@ function Test() { background: { educations: [ { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + backgroundId: 'cl9i68fv60001tthj23g9tuv4', endDate: new Date('2018-09-30T07:58:54.000Z'), field: 'Computer Science', - id: 'cl96stky6002gw32gey2ffawd', + id: 'cl9i68fv60002tthjq4eux7kn', school: 'National University of Singapore', startDate: new Date('2014-09-30T07:58:54.000Z'), type: 'Bachelors', @@ -252,20 +252,20 @@ function Test() { ], experiences: [ { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + backgroundId: 'cl9i68fv60001tthj23g9tuv4', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', + id: 'cl9h0bqug0003txxwgkac0x40', logoUrl: 'https://logo.clearbit.com/meta.com', name: 'Meta', slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', + companyId: 'cl9h0bqug0003txxwgkac0x40', durationInMonths: 24, - id: 'cl96stky6002iw32gpt6t87s2', + id: 'cl9i68fvc0004tthjo5jbr0yg', jobType: 'FULLTIME', level: 'Junior', monthlySalary: null, @@ -274,57 +274,57 @@ function Test() { title: 'Software Engineer', totalCompensation: { currency: 'SGD', - id: 'cl96stky6002jw32g73svfacr', - value: 104100, + id: 'cl9i68fvc0005tthj7r1rhvb1', + value: 100, }, - totalCompensationId: 'cl96stky6002jw32g73svfacr', + totalCompensationId: 'cl9i68fvc0005tthj7r1rhvb1', }, ], - id: 'cl96stky6002fw32g6vj4meyr', - offersProfileId: 'cl96stky5002ew32gx2kale2x', + id: 'cl9i68fv60001tthj23g9tuv4', + offersProfileId: 'cl9i68fv60000tthj8t3zkox0', specificYoes: [ { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + backgroundId: 'cl9i68fv60001tthj23g9tuv4', domain: 'Backend', - id: 'cl96t7890004tw32g5in3px5j', + id: 'cl9i68fvc0008tthjlxslzfo4', yoe: 2, }, { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + backgroundId: 'cl9i68fv60001tthj23g9tuv4', domain: 'Backend', - id: 'cl96tb87x004xw32gnu17jbzv', + id: 'cl9i68fvc0009tthjwol3285l', yoe: 2, }, { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + // BackgroundId: 'cl9i68fv60001tthj23g9tuv4', domain: 'Backend', - id: 'cl976t39z00007iygt3np3cgo', + // Id: 'cl976t39z00007iygt3np3cgo', yoe: 2, }, { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + // BackgroundId: 'cl96stky6002fw32g6vj4meyr', domain: 'Front End', - id: 'cl96stky7002mw32gn4jc7uml', + // Id: 'cl96stky7002mw32gn4jc7uml', yoe: 2, }, { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + // BackgroundId: 'cl96stky6002fw32g6vj4meyr', domain: 'Full Stack', - id: 'cl96stky7002nw32gpprghtxr', + // Id: 'cl96stky7002nw32gpprghtxr', yoe: 2, }, { - backgroundId: 'cl96stky6002fw32g6vj4meyr', + // BackgroundId: 'cl96stky6002fw32g6vj4meyr', domain: 'Backend', - id: 'cl976we5h000p7iygiomdo9fh', + // Id: 'cl976we5h000p7iygiomdo9fh', yoe: 2, }, ], totalYoe: 6, }, createdAt: '2022-10-13T08:28:13.518Z', - discussion: [], - id: 'cl96stky5002ew32gx2kale2x', + // Discussion: [], + id: 'cl9i68fv60000tthj8t3zkox0', isEditable: true, offers: [ { @@ -333,14 +333,14 @@ function Test() { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', + id: 'cl9h0bqug0003txxwgkac0x40', logoUrl: 'https://logo.clearbit.com/meta.com', name: 'Meta', slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', - id: 'cl976t4de00047iygl0zbce11', + companyId: 'cl9h0bqug0003txxwgkac0x40', + id: 'cl9i68fve000ntthj5h9yvqnh', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), @@ -348,37 +348,37 @@ function Test() { offersFullTime: { baseSalary: { currency: 'SGD', - id: 'cl976t4de00067iyg3pjir7k9', + id: 'cl9i68fve000ptthjn55hpoe4', value: 1999999999, }, - baseSalaryId: 'cl976t4de00067iyg3pjir7k9', + baseSalaryId: 'cl9i68fve000ptthjn55hpoe4', bonus: { currency: 'SGD', - id: 'cl976t4de00087iygcnlmh8aw', + id: 'cl9i68fve000rtthjqo2ktljt', value: 1410065407, }, - bonusId: 'cl976t4de00087iygcnlmh8aw', - id: 'cl976t4de00057iygq3ktce3v', + bonusId: 'cl9i68fve000rtthjqo2ktljt', + id: 'cl9i68fve000otthjqk0g01k0', level: 'EXPERT', specialization: 'FRONTEND', stocks: { currency: 'SGD', - id: 'cl976t4df000a7iygkrsgr1xh', + id: 'cl9i68fvf000ttthjt2ode0cc', value: -558038585, }, - stocksId: 'cl976t4df000a7iygkrsgr1xh', + stocksId: 'cl9i68fvf000ttthjt2ode0cc', title: 'Software Engineer', totalCompensation: { currency: 'SGD', - id: 'cl976t4df000c7iyg73ryf5uw', + id: 'cl9i68fvf000vtthjg90s48nj', value: 55555555, }, - totalCompensationId: 'cl976t4df000c7iyg73ryf5uw', + totalCompensationId: 'cl9i68fvf000vtthjg90s48nj', }, - offersFullTimeId: 'cl976t4de00057iygq3ktce3v', + offersFullTimeId: 'cl9i68fve000otthjqk0g01k0', offersIntern: null, offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', + profileId: 'cl9i68fv60000tthj8t3zkox0', }, { comments: '', @@ -386,14 +386,14 @@ function Test() { createdAt: new Date('2022-10-12T16:19:05.196Z'), description: 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', + id: 'cl9h0bqug0003txxwgkac0x40', logoUrl: 'https://logo.clearbit.com/meta.com', name: 'Meta', slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', - id: 'cl96stky80031w32gau9mu1gs', + companyId: 'cl9h0bqug0003txxwgkac0x40', + id: 'cl9i68fvf000ytthj0ltsqt1d', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), @@ -401,200 +401,200 @@ function Test() { offersFullTime: { baseSalary: { currency: 'SGD', - id: 'cl96stky80033w32gxw5goc4z', + id: 'cl9i68fvf0010tthj0iym6woh', value: 84000, }, - baseSalaryId: 'cl96stky80033w32gxw5goc4z', + baseSalaryId: 'cl9i68fvf0010tthj0iym6woh', bonus: { currency: 'SGD', - id: 'cl96stky80035w32gajjwdo1p', + id: 'cl9i68fvf0012tthjioltnspk', value: 123456789, }, - bonusId: 'cl96stky80035w32gajjwdo1p', - id: 'cl96stky80032w32gep9ovgj3', + bonusId: 'cl9i68fvf0012tthjioltnspk', + id: 'cl9i68fvf000ztthjcovbiehc', level: 'Junior', specialization: 'Front End', stocks: { currency: 'SGD', - id: 'cl96stky90037w32gu04t6ybh', + id: 'cl9i68fvf0014tthjz2gff3hs', value: 100, }, - stocksId: 'cl96stky90037w32gu04t6ybh', + stocksId: 'cl9i68fvf0014tthjz2gff3hs', title: 'Software Engineer', totalCompensation: { currency: 'SGD', - id: 'cl96stky90039w32glbpktd0o', + id: 'cl9i68fvf0016tthjrtb7iuvj', value: 104100, }, - totalCompensationId: 'cl96stky90039w32glbpktd0o', - }, - offersFullTimeId: 'cl96stky80032w32gep9ovgj3', - offersIntern: null, - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - comments: '', - company: { - createdAt: new Date('2022-10-12T16:19:05.196Z'), - description: - 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', - logoUrl: 'https://logo.clearbit.com/meta.com', - name: 'Meta', - slug: 'meta', - updatedAt: new Date('2022-10-12T16:19:05.196Z'), - }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', - id: 'cl96stky9003bw32gc3l955vr', - jobType: 'FULLTIME', - location: 'Singapore, Singapore', - monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'LOst out having multiple offers', - offersFullTime: { - baseSalary: { - currency: 'SGD', - id: 'cl96stky9003dw32gcvqbijlo', - value: 1, - }, - baseSalaryId: 'cl96stky9003dw32gcvqbijlo', - bonus: { - currency: 'SGD', - id: 'cl96stky9003fw32goc3zqxwr', - value: 0, - }, - bonusId: 'cl96stky9003fw32goc3zqxwr', - id: 'cl96stky9003cw32g5v10izfu', - level: 'Senior', - specialization: 'Front End', - stocks: { - currency: 'SGD', - id: 'cl96stky9003hw32g1lbbkqqr', - value: 999999, - }, - stocksId: 'cl96stky9003hw32g1lbbkqqr', - title: 'Software Engineer DOG', - totalCompensation: { - currency: 'SGD', - id: 'cl96stky9003jw32gzumcoi7v', - value: 999999, - }, - totalCompensationId: 'cl96stky9003jw32gzumcoi7v', + totalCompensationId: 'cl9i68fvf0016tthjrtb7iuvj', }, - offersFullTimeId: 'cl96stky9003cw32g5v10izfu', + offersFullTimeId: 'cl9i68fvf000ztthjcovbiehc', offersIntern: null, offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - comments: 'this IS SO COOL', - company: { - createdAt: new Date('2022-10-12T16:19:05.196Z'), - description: - 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', - logoUrl: 'https://logo.clearbit.com/meta.com', - name: 'Meta', - slug: 'meta', - updatedAt: new Date('2022-10-12T16:19:05.196Z'), - }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', - id: 'cl976wf28000t7iyga4noyz7s', - jobType: 'FULLTIME', - location: 'Singapore, Singapore', - monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Charmed the guy with my face', - offersFullTime: { - baseSalary: { - currency: 'SGD', - id: 'cl976wf28000v7iygmk1b7qaq', - value: 1999999999, - }, - baseSalaryId: 'cl976wf28000v7iygmk1b7qaq', - bonus: { - currency: 'SGD', - id: 'cl976wf28000x7iyg63w7kcli', - value: 1410065407, - }, - bonusId: 'cl976wf28000x7iyg63w7kcli', - id: 'cl976wf28000u7iyg6euei8e9', - level: 'EXPERT', - specialization: 'FRONTEND', - stocks: { - currency: 'SGD', - id: 'cl976wf28000z7iyg9ivun6ap', - value: 111222333, - }, - stocksId: 'cl976wf28000z7iyg9ivun6ap', - title: 'Software Engineer', - totalCompensation: { - currency: 'SGD', - id: 'cl976wf2800117iygmzsc0xit', - value: 55555555, - }, - totalCompensationId: 'cl976wf2800117iygmzsc0xit', - }, - offersFullTimeId: 'cl976wf28000u7iyg6euei8e9', - offersIntern: null, - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', - }, - { - comments: 'this rocks', - company: { - createdAt: new Date('2022-10-12T16:19:05.196Z'), - description: - 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', - id: 'cl95u79f000007im531ysjg79', - logoUrl: 'https://logo.clearbit.com/meta.com', - name: 'Meta', - slug: 'meta', - updatedAt: new Date('2022-10-12T16:19:05.196Z'), - }, - companyId: 'cl9h0bqu50000txxwkhmshhxz', - id: 'cl96tbb3o0051w32gjrpaiiit', - jobType: 'FULLTIME', - location: 'Singapore, Singapore', - monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), - negotiationStrategy: 'Charmed the guy with my face', - offersFullTime: { - baseSalary: { - currency: 'SGD', - id: 'cl96tbb3o0053w32gz11paaxu', - value: 1999999999, - }, - baseSalaryId: 'cl96tbb3o0053w32gz11paaxu', - bonus: { - currency: 'SGD', - id: 'cl96tbb3o0055w32gpyqgz5hx', - value: 1410065407, - }, - bonusId: 'cl96tbb3o0055w32gpyqgz5hx', - id: 'cl96tbb3o0052w32guguajzin', - level: 'EXPERT', - specialization: 'FRONTEND', - stocks: { - currency: 'SGD', - id: 'cl96tbb3o0057w32gu4nyxguf', - value: 500, - }, - stocksId: 'cl96tbb3o0057w32gu4nyxguf', - title: 'Software Engineer', - totalCompensation: { - currency: 'SGD', - id: 'cl96tbb3o0059w32gm3iy1zk4', - value: 55555555, - }, - totalCompensationId: 'cl96tbb3o0059w32gm3iy1zk4', - }, - offersFullTimeId: 'cl96tbb3o0052w32guguajzin', - offersIntern: null, - offersInternId: null, - profileId: 'cl96stky5002ew32gx2kale2x', + profileId: 'cl9i68fv60000tthj8t3zkox0', }, + // { + // comments: '', + // company: { + // createdAt: new Date('2022-10-12T16:19:05.196Z'), + // description: + // 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', + // id: 'cl9h0bqug0003txxwgkac0x40', + // logoUrl: 'https://logo.clearbit.com/meta.com', + // name: 'Meta', + // slug: 'meta', + // updatedAt: new Date('2022-10-12T16:19:05.196Z'), + // }, + // companyId: 'cl9h0bqug0003txxwgkac0x40', + // id: 'cl96stky9003bw32gc3l955vr', + // jobType: 'FULLTIME', + // location: 'Singapore, Singapore', + // monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), + // negotiationStrategy: 'LOst out having multiple offers', + // offersFullTime: { + // baseSalary: { + // currency: 'SGD', + // id: 'cl96stky9003dw32gcvqbijlo', + // value: 1, + // }, + // baseSalaryId: 'cl96stky9003dw32gcvqbijlo', + // bonus: { + // currency: 'SGD', + // id: 'cl96stky9003fw32goc3zqxwr', + // value: 0, + // }, + // bonusId: 'cl96stky9003fw32goc3zqxwr', + // id: 'cl96stky9003cw32g5v10izfu', + // level: 'Senior', + // specialization: 'Front End', + // stocks: { + // currency: 'SGD', + // id: 'cl96stky9003hw32g1lbbkqqr', + // value: 999999, + // }, + // stocksId: 'cl96stky9003hw32g1lbbkqqr', + // title: 'Software Engineer DOG', + // totalCompensation: { + // currency: 'SGD', + // id: 'cl96stky9003jw32gzumcoi7v', + // value: 999999, + // }, + // totalCompensationId: 'cl96stky9003jw32gzumcoi7v', + // }, + // offersFullTimeId: 'cl96stky9003cw32g5v10izfu', + // offersIntern: null, + // offersInternId: null, + // profileId: 'cl96stky5002ew32gx2kale2x', + // }, + // { + // comments: 'this IS SO COOL', + // company: { + // createdAt: new Date('2022-10-12T16:19:05.196Z'), + // description: + // 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', + // id: 'cl9h0bqug0003txxwgkac0x40', + // logoUrl: 'https://logo.clearbit.com/meta.com', + // name: 'Meta', + // slug: 'meta', + // updatedAt: new Date('2022-10-12T16:19:05.196Z'), + // }, + // companyId: 'cl9h0bqug0003txxwgkac0x40', + // id: 'cl976wf28000t7iyga4noyz7s', + // jobType: 'FULLTIME', + // location: 'Singapore, Singapore', + // monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), + // negotiationStrategy: 'Charmed the guy with my face', + // offersFullTime: { + // baseSalary: { + // currency: 'SGD', + // id: 'cl976wf28000v7iygmk1b7qaq', + // value: 1999999999, + // }, + // baseSalaryId: 'cl976wf28000v7iygmk1b7qaq', + // bonus: { + // currency: 'SGD', + // id: 'cl976wf28000x7iyg63w7kcli', + // value: 1410065407, + // }, + // bonusId: 'cl976wf28000x7iyg63w7kcli', + // id: 'cl976wf28000u7iyg6euei8e9', + // level: 'EXPERT', + // specialization: 'FRONTEND', + // stocks: { + // currency: 'SGD', + // id: 'cl976wf28000z7iyg9ivun6ap', + // value: 111222333, + // }, + // stocksId: 'cl976wf28000z7iyg9ivun6ap', + // title: 'Software Engineer', + // totalCompensation: { + // currency: 'SGD', + // id: 'cl976wf2800117iygmzsc0xit', + // value: 55555555, + // }, + // totalCompensationId: 'cl976wf2800117iygmzsc0xit', + // }, + // offersFullTimeId: 'cl976wf28000u7iyg6euei8e9', + // offersIntern: null, + // offersInternId: null, + // profileId: 'cl96stky5002ew32gx2kale2x', + // }, + // { + // comments: 'this rocks', + // company: { + // createdAt: new Date('2022-10-12T16:19:05.196Z'), + // description: + // 'Meta Platforms, Inc., doing business as Meta and formerly named Facebook, Inc., and TheFacebook, Inc., is an American multinational technology conglomerate based in Menlo Park, California. The company owns Facebook, Instagram, and WhatsApp, among other products and services.', + // id: 'cl9h0bqug0003txxwgkac0x40', + // logoUrl: 'https://logo.clearbit.com/meta.com', + // name: 'Meta', + // slug: 'meta', + // updatedAt: new Date('2022-10-12T16:19:05.196Z'), + // }, + // companyId: 'cl9h0bqug0003txxwgkac0x40', + // id: 'cl96tbb3o0051w32gjrpaiiit', + // jobType: 'FULLTIME', + // location: 'Singapore, Singapore', + // monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), + // negotiationStrategy: 'Charmed the guy with my face', + // offersFullTime: { + // baseSalary: { + // currency: 'SGD', + // id: 'cl96tbb3o0053w32gz11paaxu', + // value: 1999999999, + // }, + // baseSalaryId: 'cl96tbb3o0053w32gz11paaxu', + // bonus: { + // currency: 'SGD', + // id: 'cl96tbb3o0055w32gpyqgz5hx', + // value: 1410065407, + // }, + // bonusId: 'cl96tbb3o0055w32gpyqgz5hx', + // id: 'cl96tbb3o0052w32guguajzin', + // level: 'EXPERT', + // specialization: 'FRONTEND', + // stocks: { + // currency: 'SGD', + // id: 'cl96tbb3o0057w32gu4nyxguf', + // value: 500, + // }, + // stocksId: 'cl96tbb3o0057w32gu4nyxguf', + // title: 'Software Engineer', + // totalCompensation: { + // currency: 'SGD', + // id: 'cl96tbb3o0059w32gm3iy1zk4', + // value: 55555555, + // }, + // totalCompensationId: 'cl96tbb3o0059w32gm3iy1zk4', + // }, + // offersFullTimeId: 'cl96tbb3o0052w32guguajzin', + // offersIntern: null, + // offersInternId: null, + // profileId: 'cl96stky5002ew32gx2kale2x', + // }, ], - profileName: 'ailing bryann stuart ziqing', - token: 'afca11e436d21bde24543718fa957c6c625335439dc504f24ee35eae7b5ef1ba', + // ProfileName: 'ailing bryann stuart ziqing', + token: 'd3509cb890f0bae0a785afdd6c1c074a140706ab1d155ed338ec22dcca5c92f1', userId: null, }); }; diff --git a/apps/portal/src/server/router/offers/offers-profile-router.ts b/apps/portal/src/server/router/offers/offers-profile-router.ts index debf6096..207c6500 100644 --- a/apps/portal/src/server/router/offers/offers-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-profile-router.ts @@ -94,14 +94,14 @@ const education = z.object({ type: z.string().nullish(), }); -const reply = z.object({ - createdAt: z.date().nullish(), - id: z.string().optional(), - messages: z.string().nullish(), - profileId: z.string().nullish(), - replyingToId: z.string().nullish(), - userId: z.string().nullish(), -}); +// Const reply = z.object({ +// createdAt: z.date().nullish(), +// id: z.string().optional(), +// messages: z.string().nullish(), +// profileId: z.string().nullish(), +// replyingToId: z.string().nullish(), +// userId: z.string().nullish(), +// }); export const offersProfileRouter = createRouter() .query('listOne', { @@ -535,11 +535,11 @@ export const offersProfileRouter = createRouter() totalYoe: z.number(), }), createdAt: z.string().optional(), - discussion: z.array(reply), + // Discussion: z.array(reply), id: z.string(), isEditable: z.boolean().nullish(), offers: z.array(offer), - profileName: z.string(), + profileName: z.string().optional(), token: z.string(), userId: z.string().nullish(), }), @@ -552,14 +552,16 @@ export const offersProfileRouter = createRouter() const profileEditToken = profileToUpdate?.editToken; if (profileEditToken === input.token) { - await ctx.prisma.offersProfile.update({ - data: { - profileName: input.profileName, - }, - where: { - id: input.id, - }, - }); + if (input.profileName) { + await ctx.prisma.offersProfile.update({ + data: { + profileName: input.profileName, + }, + where: { + id: input.id, + }, + }); + } await ctx.prisma.offersBackground.update({ data: { @@ -572,6 +574,7 @@ export const offersProfileRouter = createRouter() for (const edu of input.background.educations) { if (edu.id) { + // Update existing education await ctx.prisma.offersEducation.update({ data: { endDate: edu.endDate, @@ -585,6 +588,7 @@ export const offersProfileRouter = createRouter() }, }); } else { + // Create new education await ctx.prisma.offersBackground.update({ data: { educations: { @@ -606,6 +610,7 @@ export const offersProfileRouter = createRouter() for (const exp of input.background.experiences) { if (exp.id) { + // Update existing experience await ctx.prisma.offersExperience.update({ data: { companyId: exp.companyId, @@ -642,6 +647,7 @@ export const offersProfileRouter = createRouter() }); } } else if (!exp.id) { + // Create new experience if ( exp.jobType === 'FULLTIME' && exp.totalCompensation?.currency !== undefined && @@ -760,6 +766,7 @@ export const offersProfileRouter = createRouter() for (const yoe of input.background.specificYoes) { if (yoe.id) { + // Update existing yoe await ctx.prisma.offersSpecificYoe.update({ data: { ...yoe, @@ -769,6 +776,7 @@ export const offersProfileRouter = createRouter() }, }); } else { + // Create new yoe await ctx.prisma.offersBackground.update({ data: { specificYoes: { @@ -787,6 +795,7 @@ export const offersProfileRouter = createRouter() for (const offerToUpdate of input.offers) { if (offerToUpdate.id) { + // Update existing offer await ctx.prisma.offersOffer.update({ data: { comments: offerToUpdate.comments, @@ -894,6 +903,7 @@ export const offersProfileRouter = createRouter() }); } } else { + // Create new offer if ( offerToUpdate.jobType === 'INTERN' && offerToUpdate.offersIntern && From d10377e0f909bd0a1a263e8e1f05fc6fc1071cc2 Mon Sep 17 00:00:00 2001 From: Terence <45381509+Vielheim@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:55:59 +0800 Subject: [PATCH 03/23] [resumes][feat] replying comments (#401) * [resumes][feat] add resume comment parent * [resumes][refactor] Abstract comment edit form and votes to their components * [resumes][feat] Add reply form * [resumes][feat] Render replies * [resumes][feat] add collapsible comments * [resumes][chore] remove comment Co-authored-by: Terence Ho <> --- .../migration.sql | 5 + apps/portal/prisma/schema.prisma | 3 + .../comments/ResumeCommentListItem.tsx | 305 +++++------------- .../comment/ResumeCommentEditForm.tsx | 106 ++++++ .../comment/ResumeCommentReplyForm.tsx | 107 ++++++ .../comment/ResumeCommentVoteButtons.tsx | 129 ++++++++ .../router/resumes/resumes-comments-router.ts | 35 +- .../resumes/resumes-comments-user-router.ts | 22 ++ apps/portal/src/types/resume-comments.d.ts | 2 + 9 files changed, 497 insertions(+), 217 deletions(-) create mode 100644 apps/portal/prisma/migrations/20221020101123_add_resume_comment_parent/migration.sql create mode 100644 apps/portal/src/components/resumes/comments/comment/ResumeCommentEditForm.tsx create mode 100644 apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx create mode 100644 apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx diff --git a/apps/portal/prisma/migrations/20221020101123_add_resume_comment_parent/migration.sql b/apps/portal/prisma/migrations/20221020101123_add_resume_comment_parent/migration.sql new file mode 100644 index 00000000..018ad4cd --- /dev/null +++ b/apps/portal/prisma/migrations/20221020101123_add_resume_comment_parent/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "ResumesComment" ADD COLUMN "parentId" TEXT; + +-- AddForeignKey +ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "ResumesComment"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 48e068ca..7f968286 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -140,6 +140,7 @@ model ResumesComment { id String @id @default(cuid()) userId String resumeId String + parentId String? description String @db.Text section ResumesSection createdAt DateTime @default(now()) @@ -147,6 +148,8 @@ model ResumesComment { resume ResumesResume @relation(fields: [resumeId], references: [id], onDelete: Cascade) votes ResumesCommentVote[] user User @relation(fields: [userId], references: [id], onDelete: Cascade) + parent ResumesComment? @relation("parentComment", fields: [parentId], references: [id]) + children ResumesComment[] @relation("parentComment") } enum ResumesSection { diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx index 833c53c2..6814fda9 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx @@ -1,18 +1,11 @@ import clsx from 'clsx'; -import type { Dispatch, SetStateAction } from 'react'; import { useState } from 'react'; -import type { SubmitHandler } from 'react-hook-form'; -import { useForm } from 'react-hook-form'; -import { - ArrowDownCircleIcon, - ArrowUpCircleIcon, -} from '@heroicons/react/20/solid'; +import { ChevronUpIcon } from '@heroicons/react/20/solid'; import { FaceSmileIcon } from '@heroicons/react/24/outline'; -import { Vote } from '@prisma/client'; -import { Button, TextArea } from '@tih/ui'; - -import { trpc } from '~/utils/trpc'; +import ResumeCommentEditForm from './comment/ResumeCommentEditForm'; +import ResumeCommentReplyForm from './comment/ResumeCommentReplyForm'; +import ResumeCommentVoteButtons from './comment/ResumeCommentVoteButtons'; import ResumeUserBadges from '../badges/ResumeUserBadges'; import ResumeExpandableText from '../shared/ResumeExpandableText'; @@ -23,141 +16,55 @@ type ResumeCommentListItemProps = { userId: string | undefined; }; -type ICommentInput = { - description: string; -}; - export default function ResumeCommentListItem({ comment, userId, }: ResumeCommentListItemProps) { const isCommentOwner = userId === comment.user.userId; const [isEditingComment, setIsEditingComment] = useState(false); - - const [upvoteAnimation, setUpvoteAnimation] = useState(false); - const [downvoteAnimation, setDownvoteAnimation] = useState(false); - - const { - register, - handleSubmit, - setValue, - formState: { errors, isDirty }, - reset, - } = useForm({ - defaultValues: { - description: comment.description, - }, - }); - - const trpcContext = trpc.useContext(); - const commentUpdateMutation = trpc.useMutation( - 'resumes.comments.user.update', - { - onSuccess: () => { - // Comment updated, invalidate query to trigger refetch - trpcContext.invalidateQueries(['resumes.comments.list']); - }, - }, - ); - - // COMMENT VOTES - const commentVotesQuery = trpc.useQuery([ - 'resumes.comments.votes.list', - { commentId: comment.id }, - ]); - const commentVotesUpsertMutation = trpc.useMutation( - 'resumes.comments.votes.user.upsert', - { - onSuccess: () => { - // Comment updated, invalidate query to trigger refetch - trpcContext.invalidateQueries(['resumes.comments.votes.list']); - }, - }, - ); - const commentVotesDeleteMutation = trpc.useMutation( - 'resumes.comments.votes.user.delete', - { - onSuccess: () => { - // Comment updated, invalidate query to trigger refetch - trpcContext.invalidateQueries(['resumes.comments.votes.list']); - }, - }, - ); - - // FORM ACTIONS - const onCancel = () => { - reset({ description: comment.description }); - setIsEditingComment(false); - }; - - const onSubmit: SubmitHandler = async (data) => { - const { id } = comment; - return commentUpdateMutation.mutate( - { - id, - ...data, - }, - { - onSuccess: () => { - setIsEditingComment(false); - }, - }, - ); - }; - - const setFormValue = (value: string) => { - setValue('description', value.trim(), { shouldDirty: true }); - }; - - const onVote = async ( - value: Vote, - setAnimation: Dispatch>, - ) => { - setAnimation(true); - - if (commentVotesQuery.data?.userVote?.value === value) { - return commentVotesDeleteMutation.mutate( - { - commentId: comment.id, - }, - { - onSettled: async () => setAnimation(false), - }, - ); - } - return commentVotesUpsertMutation.mutate( - { - commentId: comment.id, - value, - }, - { - onSettled: async () => setAnimation(false), - }, - ); - }; + const [isReplyingComment, setIsReplyingComment] = useState(false); + const [showReplies, setShowReplies] = useState(true); return ( -
+
+ {/* Image Icon */} {comment.user.image ? ( {comment.user.name ) : ( - + )}
{/* Name and creation time */}
-

+

{comment.user.name ?? 'Reviewer ABC'}

-

+

{isCommentOwner ? '(Me)' : ''}

@@ -174,112 +81,78 @@ export default function ResumeCommentListItem({ {/* Description */} {isEditingComment ? ( -
-
-