From 6bed79f1fdeb779cce6c3090f3e24edbebc9a536 Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Sat, 29 Oct 2022 21:46:22 +0800 Subject: [PATCH 01/18] [offers][fix] change get endpoint to query instead of mutation --- .../src/server/router/offers/offers-user-profile-router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/portal/src/server/router/offers/offers-user-profile-router.ts b/apps/portal/src/server/router/offers/offers-user-profile-router.ts index d0468abb..8a9bcbe4 100644 --- a/apps/portal/src/server/router/offers/offers-user-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-user-profile-router.ts @@ -47,7 +47,7 @@ export const offersUserProfileRouter = createProtectedRouter() }); }, }) - .mutation('getUserProfiles', { + .query('getUserProfiles', { async resolve({ ctx }) { const userId = ctx.session.user.id const result = await ctx.prisma.user.findFirst({ From 763e8f0332d4b7ef966f631e318538d68441b41b Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Sat, 29 Oct 2022 21:51:10 +0800 Subject: [PATCH 02/18] [offers][fix] fix typo of types --- apps/portal/src/types/offers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts index b26995d7..5a95406b 100644 --- a/apps/portal/src/types/offers.d.ts +++ b/apps/portal/src/types/offers.d.ts @@ -188,7 +188,7 @@ export type AddToProfileResponse = { export type UserProfile = { createdAt: Date; id: string; - offers: Array; + offers: Array; profileName: string; token: string; } From a103879b5cb9133f417f076250680fca97faf240 Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Sun, 30 Oct 2022 00:18:17 +0800 Subject: [PATCH 03/18] [offers][feat] add isValidToken endpoint --- .../src/pages/offers/test/createProfile.tsx | 16 ++++++++++++++++ .../router/offers/offers-profile-router.ts | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx index 3901505f..610d4e00 100644 --- a/apps/portal/src/pages/offers/test/createProfile.tsx +++ b/apps/portal/src/pages/offers/test/createProfile.tsx @@ -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( ['offers.comments.getComments', { profileId }], { 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 1e1d1d52..70b3c3cb 100644 --- a/apps/portal/src/server/router/offers/offers-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-profile-router.ts @@ -102,6 +102,21 @@ const education = z.object({ }); 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', { input: z.object({ profileId: z.string(), From f7ff20bb22e8f9895637b2df9333ce8032ae75e3 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 30 Oct 2022 09:23:03 +0800 Subject: [PATCH 04/18] [ui][typeahead] allow typeahead to be cleared --- apps/portal/.eslintrc.js | 3 +++ .../offersSubmission/submissionForm/BackgroundForm.tsx | 4 ++++ .../offersSubmission/submissionForm/OfferDetailsForm.tsx | 4 ++++ apps/portal/src/components/questions/LandingComponent.tsx | 2 ++ .../components/questions/forms/ContributeQuestionForm.tsx | 3 +++ .../questions/forms/CreateQuestionEncounterForm.tsx | 3 +++ apps/portal/src/components/shared/CompaniesTypeahead.tsx | 2 +- apps/portal/src/components/shared/JobTitlesTypahead.tsx | 2 +- apps/portal/src/pages/offers/index.tsx | 2 ++ apps/portal/src/pages/questions/browse.tsx | 3 +++ packages/ui/src/Typeahead/Typeahead.tsx | 6 +----- 11 files changed, 27 insertions(+), 7 deletions(-) diff --git a/apps/portal/.eslintrc.js b/apps/portal/.eslintrc.js index 07b7f196..099e9a60 100644 --- a/apps/portal/.eslintrc.js +++ b/apps/portal/.eslintrc.js @@ -5,4 +5,7 @@ module.exports = { tsconfigRootDir: __dirname, project: ['./tsconfig.json'], }, + rules: { + '@typescript-eslint/ban-ts-comment': 0, + }, }; diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx index 52d0a42e..b3304e1e 100644 --- a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx @@ -97,6 +97,7 @@ function FullTimeJobFields() {
setValue(`background.experiences.0.title`, value) } @@ -104,6 +105,7 @@ function FullTimeJobFields() {
setValue(`background.experiences.0.companyId`, value) } @@ -178,6 +180,7 @@ function InternshipJobFields() {
setValue(`background.experiences.0.title`, value) } @@ -185,6 +188,7 @@ function InternshipJobFields() {
setValue(`background.experiences.0.companyId`, value) } diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx index 5b64586d..9a910de6 100644 --- a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx @@ -70,6 +70,7 @@ function FullTimeOfferDetailsForm({
setValue(`offers.${index}.offersFullTime.title`, value) } @@ -89,6 +90,7 @@ function FullTimeOfferDetailsForm({
setValue(`offers.${index}.companyId`, value) } @@ -277,6 +279,7 @@ function InternshipOfferDetailsForm({
setValue(`offers.${index}.offersIntern.title`, value) } @@ -287,6 +290,7 @@ function InternshipOfferDetailsForm({
setValue(`offers.${index}.companyId`, value) } diff --git a/apps/portal/src/components/questions/LandingComponent.tsx b/apps/portal/src/components/questions/LandingComponent.tsx index cd2ace15..0961187c 100644 --- a/apps/portal/src/components/questions/LandingComponent.tsx +++ b/apps/portal/src/components/questions/LandingComponent.tsx @@ -97,6 +97,7 @@ export default function LandingComponent({ isLabelHidden={true} value={company} onSelect={(value) => { + // @ts-ignore TODO(questions): handle potentially null value. handleChangeCompany(value); }} /> @@ -105,6 +106,7 @@ export default function LandingComponent({ isLabelHidden={true} value={location} onSelect={(value) => { + // @ts-ignore TODO(questions): handle potentially null value. handleChangeLocation(value); }} /> diff --git a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx index ea87d8f5..a1f5777c 100644 --- a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx +++ b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx @@ -81,6 +81,7 @@ export default function ContributeQuestionForm({ { + // @ts-ignore TODO(questions): handle potentially null value. field.onChange(option.value); }} {...field} @@ -119,6 +120,7 @@ export default function ContributeQuestionForm({ render={({ field }) => ( { field.onChange(id); }} @@ -134,6 +136,7 @@ export default function ContributeQuestionForm({ { + // @ts-ignore TODO(questions): handle potentially null value. field.onChange(option.value); }} {...field} diff --git a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx index fbebb6f9..fb00e48b 100644 --- a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx +++ b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx @@ -43,6 +43,7 @@ export default function CreateQuestionEncounterForm({ isLabelHidden={true} placeholder="Other company" suggestedCount={3} + // @ts-ignore TODO(questions): handle potentially null value. onSelect={({ value: company }) => { setSelectedCompany(company); }} @@ -59,6 +60,7 @@ export default function CreateQuestionEncounterForm({ isLabelHidden={true} placeholder="Other location" suggestedCount={3} + // @ts-ignore TODO(questions): handle potentially null value. onSelect={({ value: location }) => { setSelectedLocation(location); }} @@ -75,6 +77,7 @@ export default function CreateQuestionEncounterForm({ isLabelHidden={true} placeholder="Other role" suggestedCount={3} + // @ts-ignore TODO(questions): handle potentially null value. onSelect={({ value: role }) => { setSelectedRole(role); }} diff --git a/apps/portal/src/components/shared/CompaniesTypeahead.tsx b/apps/portal/src/components/shared/CompaniesTypeahead.tsx index 7a48bd10..3b641b35 100644 --- a/apps/portal/src/components/shared/CompaniesTypeahead.tsx +++ b/apps/portal/src/components/shared/CompaniesTypeahead.tsx @@ -8,7 +8,7 @@ type Props = Readonly<{ disabled?: boolean; errorMessage?: string; isLabelHidden?: boolean; - onSelect: (option: TypeaheadOption) => void; + onSelect: (option: TypeaheadOption | null) => void; placeHolder?: string; required?: boolean; }>; diff --git a/apps/portal/src/components/shared/JobTitlesTypahead.tsx b/apps/portal/src/components/shared/JobTitlesTypahead.tsx index b2e80fe9..0d8ca3f4 100644 --- a/apps/portal/src/components/shared/JobTitlesTypahead.tsx +++ b/apps/portal/src/components/shared/JobTitlesTypahead.tsx @@ -7,7 +7,7 @@ import { JobTitleLabels } from './JobTitles'; type Props = Readonly<{ disabled?: boolean; isLabelHidden?: boolean; - onSelect: (option: TypeaheadOption) => void; + onSelect: (option: TypeaheadOption | null) => void; placeHolder?: string; required?: boolean; }>; diff --git a/apps/portal/src/pages/offers/index.tsx b/apps/portal/src/pages/offers/index.tsx index dbfe6323..bb09c36f 100644 --- a/apps/portal/src/pages/offers/index.tsx +++ b/apps/portal/src/pages/offers/index.tsx @@ -37,12 +37,14 @@ export default function OffersHomePage() { setjobTitleFilter(value)} /> in setCompanyFilter(value)} />
diff --git a/apps/portal/src/pages/questions/browse.tsx b/apps/portal/src/pages/questions/browse.tsx index 89ab3c6d..bc471080 100644 --- a/apps/portal/src/pages/questions/browse.tsx +++ b/apps/portal/src/pages/questions/browse.tsx @@ -325,6 +325,7 @@ export default function QuestionsBrowsePage() { isLabelHidden={true} placeholder="Search companies" onSelect={(option) => { + // @ts-ignore TODO(questions): handle potentially null value. onOptionChange({ ...option, checked: true, @@ -357,6 +358,7 @@ export default function QuestionsBrowsePage() { isLabelHidden={true} placeholder="Search roles" onSelect={(option) => { + // @ts-ignore TODO(questions): handle potentially null value. onOptionChange({ ...option, checked: true, @@ -414,6 +416,7 @@ export default function QuestionsBrowsePage() { isLabelHidden={true} placeholder="Search locations" onSelect={(option) => { + // @ts-ignore TODO(offers): fix potentially empty value. onOptionChange({ ...option, checked: true, diff --git a/packages/ui/src/Typeahead/Typeahead.tsx b/packages/ui/src/Typeahead/Typeahead.tsx index 23db4a77..bf16f07c 100644 --- a/packages/ui/src/Typeahead/Typeahead.tsx +++ b/packages/ui/src/Typeahead/Typeahead.tsx @@ -34,7 +34,7 @@ type Props = Readonly<{ value: string, event: React.ChangeEvent, ) => void; - onSelect: (option: TypeaheadOption) => void; + onSelect: (option: TypeaheadOption | null) => void; options: ReadonlyArray; textSize?: TypeaheadTextSize; value?: TypeaheadOption; @@ -102,10 +102,6 @@ export default function Typeahead({ // @ts-ignore value={value} onChange={(newValue) => { - if (newValue == null) { - return; - } - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore onSelect(newValue as TypeaheadOption); From 576f0292a11938835bb6c3847a7462a343728133 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 30 Oct 2022 10:01:54 +0800 Subject: [PATCH 05/18] [portal][misc] s/placeHolder/placeholder --- apps/portal/src/components/shared/CompaniesTypeahead.tsx | 6 +++--- apps/portal/src/components/shared/JobTitlesTypahead.tsx | 6 +++--- apps/portal/src/pages/offers/index.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/portal/src/components/shared/CompaniesTypeahead.tsx b/apps/portal/src/components/shared/CompaniesTypeahead.tsx index 3b641b35..cd54f4e5 100644 --- a/apps/portal/src/components/shared/CompaniesTypeahead.tsx +++ b/apps/portal/src/components/shared/CompaniesTypeahead.tsx @@ -9,7 +9,7 @@ type Props = Readonly<{ errorMessage?: string; isLabelHidden?: boolean; onSelect: (option: TypeaheadOption | null) => void; - placeHolder?: string; + placeholder?: string; required?: boolean; }>; @@ -17,7 +17,7 @@ export default function CompaniesTypeahead({ disabled, onSelect, isLabelHidden, - placeHolder, + placeholder, required, }: Props) { const [query, setQuery] = useState(''); @@ -44,7 +44,7 @@ export default function CompaniesTypeahead({ value: id, })) ?? [] } - placeholder={placeHolder} + placeholder={placeholder} required={required} textSize="inherit" onQueryChange={setQuery} diff --git a/apps/portal/src/components/shared/JobTitlesTypahead.tsx b/apps/portal/src/components/shared/JobTitlesTypahead.tsx index 0d8ca3f4..d266deb4 100644 --- a/apps/portal/src/components/shared/JobTitlesTypahead.tsx +++ b/apps/portal/src/components/shared/JobTitlesTypahead.tsx @@ -8,7 +8,7 @@ type Props = Readonly<{ disabled?: boolean; isLabelHidden?: boolean; onSelect: (option: TypeaheadOption | null) => void; - placeHolder?: string; + placeholder?: string; required?: boolean; }>; @@ -16,7 +16,7 @@ export default function JobTitlesTypeahead({ disabled, onSelect, isLabelHidden, - placeHolder, + placeholder, required, }: Props) { const [query, setQuery] = useState(''); @@ -39,7 +39,7 @@ export default function JobTitlesTypeahead({ noResultsMessage="No available job titles." nullable={true} options={options} - placeholder={placeHolder} + placeholder={placeholder} required={required} textSize="inherit" onQueryChange={setQuery} diff --git a/apps/portal/src/pages/offers/index.tsx b/apps/portal/src/pages/offers/index.tsx index bb09c36f..b3f98ef9 100644 --- a/apps/portal/src/pages/offers/index.tsx +++ b/apps/portal/src/pages/offers/index.tsx @@ -36,14 +36,14 @@ export default function OffersHomePage() {
setjobTitleFilter(value)} /> in setCompanyFilter(value)} /> From 2a4045cbcc2e7ecd97df048b2a2f076cfabd4e41 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Sun, 30 Oct 2022 10:03:41 +0800 Subject: [PATCH 06/18] [resumes][fix] fix filter count bug --- apps/portal/src/pages/resumes/submit.tsx | 3 - .../router/resumes/resumes-resume-router.ts | 71 ------------------- 2 files changed, 74 deletions(-) diff --git a/apps/portal/src/pages/resumes/submit.tsx b/apps/portal/src/pages/resumes/submit.tsx index 2b1a346c..7ef404dc 100644 --- a/apps/portal/src/pages/resumes/submit.tsx +++ b/apps/portal/src/pages/resumes/submit.tsx @@ -171,9 +171,6 @@ export default function SubmitResumeForm({ onSuccess() { if (isNewForm) { trpcContext.invalidateQueries('resumes.resume.findAll'); - trpcContext.invalidateQueries( - 'resumes.resume.getTotalFilterCounts', - ); router.push('/resumes'); gaEvent({ action: 'resumes.submit_button_click', 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 177a9189..ec4a36b4 100644 --- a/apps/portal/src/server/router/resumes/resumes-resume-router.ts +++ b/apps/portal/src/server/router/resumes/resumes-resume-router.ts @@ -113,7 +113,6 @@ export const resumesRouter = createRouter() experience: { in: experienceFilters }, isResolved: isUnreviewed ? false : {}, location: { in: locationFilters }, - role: { in: roleFilters }, title: { contains: searchValue, mode: 'insensitive' }, }, }); @@ -143,7 +142,6 @@ export const resumesRouter = createRouter() }, by: ['experience'], where: { - experience: { in: experienceFilters }, isResolved: isUnreviewed ? false : {}, location: { in: locationFilters }, role: { in: roleFilters }, @@ -171,7 +169,6 @@ export const resumesRouter = createRouter() where: { experience: { in: experienceFilters }, isResolved: isUnreviewed ? false : {}, - location: { in: locationFilters }, role: { in: roleFilters }, title: { contains: searchValue, mode: 'insensitive' }, }, @@ -343,72 +340,4 @@ export const resumesRouter = createRouter() return topUpvotedCommentCount; }, - }) - .query('getTotalFilterCounts', { - async resolve({ ctx }) { - const roleCounts = await ctx.prisma.resumesResume.groupBy({ - _count: { - _all: true, - }, - by: ['role'], - }); - const mappedRoleCounts = Object.fromEntries( - roleCounts.map((rc) => [rc.role, rc._count._all]), - ); - const zeroRoleCounts = Object.fromEntries( - ROLES.filter((r) => !(r.value in mappedRoleCounts)).map((r) => [ - r.value, - 0, - ]), - ); - const processedRoleCounts = { - ...mappedRoleCounts, - ...zeroRoleCounts, - }; - - const experienceCounts = await ctx.prisma.resumesResume.groupBy({ - _count: { - _all: true, - }, - by: ['experience'], - }); - const mappedExperienceCounts = Object.fromEntries( - experienceCounts.map((ec) => [ec.experience, ec._count._all]), - ); - const zeroExperienceCounts = Object.fromEntries( - EXPERIENCES.filter((e) => !(e.value in mappedExperienceCounts)).map( - (e) => [e.value, 0], - ), - ); - const processedExperienceCounts = { - ...mappedExperienceCounts, - ...zeroExperienceCounts, - }; - - const locationCounts = await ctx.prisma.resumesResume.groupBy({ - _count: { - _all: true, - }, - by: ['location'], - }); - const mappedLocationCounts = Object.fromEntries( - locationCounts.map((lc) => [lc.location, lc._count._all]), - ); - const zeroLocationCounts = Object.fromEntries( - LOCATIONS.filter((l) => !(l.value in mappedLocationCounts)).map((l) => [ - l.value, - 0, - ]), - ); - const processedLocationCounts = { - ...mappedLocationCounts, - ...zeroLocationCounts, - }; - - return { - Experience: processedExperienceCounts, - Location: processedLocationCounts, - Role: processedRoleCounts, - }; - }, }); From 6746f5479204c84f29988d824c2c0a3a2fa21284 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 30 Oct 2022 10:07:38 +0800 Subject: [PATCH 07/18] [portal][ui] allow value to be specified for comapnies and job titles typeahead --- apps/portal/src/components/shared/CompaniesTypeahead.tsx | 3 +++ apps/portal/src/components/shared/JobTitlesTypahead.tsx | 3 +++ packages/ui/src/Typeahead/Typeahead.tsx | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/portal/src/components/shared/CompaniesTypeahead.tsx b/apps/portal/src/components/shared/CompaniesTypeahead.tsx index cd54f4e5..619d9a55 100644 --- a/apps/portal/src/components/shared/CompaniesTypeahead.tsx +++ b/apps/portal/src/components/shared/CompaniesTypeahead.tsx @@ -11,6 +11,7 @@ type Props = Readonly<{ onSelect: (option: TypeaheadOption | null) => void; placeholder?: string; required?: boolean; + value?: TypeaheadOption | null; }>; export default function CompaniesTypeahead({ @@ -19,6 +20,7 @@ export default function CompaniesTypeahead({ isLabelHidden, placeholder, required, + value, }: Props) { const [query, setQuery] = useState(''); const companies = trpc.useQuery([ @@ -47,6 +49,7 @@ export default function CompaniesTypeahead({ placeholder={placeholder} required={required} textSize="inherit" + value={value} onQueryChange={setQuery} onSelect={onSelect} /> diff --git a/apps/portal/src/components/shared/JobTitlesTypahead.tsx b/apps/portal/src/components/shared/JobTitlesTypahead.tsx index d266deb4..b5221262 100644 --- a/apps/portal/src/components/shared/JobTitlesTypahead.tsx +++ b/apps/portal/src/components/shared/JobTitlesTypahead.tsx @@ -10,6 +10,7 @@ type Props = Readonly<{ onSelect: (option: TypeaheadOption | null) => void; placeholder?: string; required?: boolean; + value?: TypeaheadOption | null; }>; export default function JobTitlesTypeahead({ @@ -18,6 +19,7 @@ export default function JobTitlesTypeahead({ isLabelHidden, placeholder, required, + value, }: Props) { const [query, setQuery] = useState(''); const options = Object.entries(JobTitleLabels) @@ -42,6 +44,7 @@ export default function JobTitlesTypeahead({ placeholder={placeholder} required={required} textSize="inherit" + value={value} onQueryChange={setQuery} onSelect={onSelect} /> diff --git a/packages/ui/src/Typeahead/Typeahead.tsx b/packages/ui/src/Typeahead/Typeahead.tsx index bf16f07c..bce6fb32 100644 --- a/packages/ui/src/Typeahead/Typeahead.tsx +++ b/packages/ui/src/Typeahead/Typeahead.tsx @@ -37,7 +37,7 @@ type Props = Readonly<{ onSelect: (option: TypeaheadOption | null) => void; options: ReadonlyArray; textSize?: TypeaheadTextSize; - value?: TypeaheadOption; + value?: TypeaheadOption | null; }> & Readonly; @@ -90,6 +90,8 @@ export default function Typeahead({ return (
{ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - onSelect(newValue as TypeaheadOption); + onSelect(newValue as TypeaheadOption | null); }}> Date: Sun, 30 Oct 2022 10:18:29 +0800 Subject: [PATCH 08/18] [resumes][feat] update filter count colour --- apps/portal/src/pages/resumes/index.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/portal/src/pages/resumes/index.tsx b/apps/portal/src/pages/resumes/index.tsx index bae25c3f..444068a0 100644 --- a/apps/portal/src/pages/resumes/index.tsx +++ b/apps/portal/src/pages/resumes/index.tsx @@ -427,12 +427,9 @@ export default function ResumeHomePage() { {filter.options.map((option) => (
+ className="[&>div>div:nth-child(1)>input]:text-primary-600 [&>div>div:nth-child(1)>input]:ring-primary-500 flex items-center px-1 text-sm [&>div>div:nth-child(2)>label]:font-normal"> + + ( + {getFilterCount( + filter.label, + option.label, + )} + ) +
))}
@@ -527,12 +532,9 @@ export default function ResumeHomePage() { {filter.options.map((option) => (
+ className="[&>div>div:nth-child(1)>input]:text-primary-600 [&>div>div:nth-child(1)>input]:ring-primary-500 flex items-center px-1 text-sm [&>div>div:nth-child(2)>label]:font-normal"> + + ({getFilterCount(filter.label, option.label)}) +
))} From 4ee80b90293eb8ab93e60448d555a19daf8ed9cd Mon Sep 17 00:00:00 2001 From: Terence <45381509+Vielheim@users.noreply.github.com> Date: Sun, 30 Oct 2022 10:55:19 +0800 Subject: [PATCH 09/18] [resumes][feat] add ga for comments (#459) Co-authored-by: Terence Ho <> --- .../resumes/comments/ResumeCommentsForm.tsx | 9 +++++++++ .../comments/comment/ResumeCommentReplyForm.tsx | 9 +++++++++ .../comments/comment/ResumeCommentVoteButtons.tsx | 13 +++++++++++++ 3 files changed, 31 insertions(+) diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentsForm.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentsForm.tsx index 6933058b..d15cf82a 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentsForm.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentsForm.tsx @@ -3,6 +3,8 @@ import type { SubmitHandler } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { Button, Dialog, TextArea } from '@tih/ui'; +import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; + import { trpc } from '~/utils/trpc'; type ResumeCommentsFormProps = Readonly<{ @@ -25,6 +27,8 @@ export default function ResumeCommentsForm({ setShowCommentsForm, }: ResumeCommentsFormProps) { const [showDialog, setShowDialog] = useState(false); + const { event: gaEvent } = useGoogleAnalytics(); + const { register, handleSubmit, @@ -50,6 +54,11 @@ export default function ResumeCommentsForm({ trpcContext.invalidateQueries(['resumes.resume.findAll']); trpcContext.invalidateQueries(['resumes.resume.user.findUserStarred']); trpcContext.invalidateQueries(['resumes.resume.user.findUserCreated']); + gaEvent({ + action: 'resumes.comment_submit', + category: 'engagement', + label: 'Submit comment', + }); }, }, ); diff --git a/apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx b/apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx index ea14632a..ef2da04c 100644 --- a/apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx +++ b/apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx @@ -3,6 +3,8 @@ import { useForm } from 'react-hook-form'; import type { ResumesSection } from '@prisma/client'; import { Button, TextArea } from '@tih/ui'; +import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; + import { trpc } from '~/utils/trpc'; type ResumeCommentEditFormProps = { @@ -33,6 +35,7 @@ export default function ResumeCommentReplyForm({ description: '', }, }); + const { event: gaEvent } = useGoogleAnalytics(); const trpcContext = trpc.useContext(); const commentReplyMutation = trpc.useMutation('resumes.comments.user.reply', { @@ -58,6 +61,12 @@ export default function ResumeCommentReplyForm({ { onSuccess: () => { setIsReplyingComment(false); + + gaEvent({ + action: 'resumes.comment_reply', + category: 'engagement', + label: 'Reply comment', + }); }, }, ); diff --git a/apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx b/apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx index 12c3a387..9c2435e6 100644 --- a/apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx +++ b/apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx @@ -7,6 +7,8 @@ import { } from '@heroicons/react/20/solid'; import { Vote } from '@prisma/client'; +import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; + import { trpc } from '~/utils/trpc'; type ResumeCommentVoteButtonsProps = { @@ -20,6 +22,7 @@ export default function ResumeCommentVoteButtons({ }: ResumeCommentVoteButtonsProps) { const [upvoteAnimation, setUpvoteAnimation] = useState(false); const [downvoteAnimation, setDownvoteAnimation] = useState(false); + const { event: gaEvent } = useGoogleAnalytics(); const trpcContext = trpc.useContext(); const router = useRouter(); @@ -35,6 +38,11 @@ export default function ResumeCommentVoteButtons({ onSuccess: () => { // Comment updated, invalidate query to trigger refetch trpcContext.invalidateQueries(['resumes.comments.votes.list']); + gaEvent({ + action: 'resumes.comment_vote', + category: 'engagement', + label: 'Upvote/Downvote comment', + }); }, }, ); @@ -44,6 +52,11 @@ export default function ResumeCommentVoteButtons({ onSuccess: () => { // Comment updated, invalidate query to trigger refetch trpcContext.invalidateQueries(['resumes.comments.votes.list']); + gaEvent({ + action: 'resumes.comment_unvote', + category: 'engagement', + label: 'Unvote comment', + }); }, }, ); From 44b3b66fbdc2bfed7eefc1eb955bc40d6914a5c4 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 30 Oct 2022 11:20:03 +0800 Subject: [PATCH 10/18] [ui] fix outdated types --- apps/storybook/stories/typeahead.stories.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/storybook/stories/typeahead.stories.tsx b/apps/storybook/stories/typeahead.stories.tsx index 7b647d7a..e82c70d3 100644 --- a/apps/storybook/stories/typeahead.stories.tsx +++ b/apps/storybook/stories/typeahead.stories.tsx @@ -59,7 +59,7 @@ export function Basic({ { id: '5', label: 'Tanya Fox', value: '5' }, { id: '6', label: 'Hellen Schmidt', value: '6' }, ]; - const [selectedEntry, setSelectedEntry] = useState( + const [selectedEntry, setSelectedEntry] = useState( people[0], ); const [query, setQuery] = useState(''); @@ -102,7 +102,7 @@ export function Required() { { id: '5', label: 'Tanya Fox', value: '5' }, { id: '6', label: 'Hellen Schmidt', value: '6' }, ]; - const [selectedEntry, setSelectedEntry] = useState( + const [selectedEntry, setSelectedEntry] = useState( people[0], ); const [query, setQuery] = useState(''); @@ -153,7 +153,7 @@ export function Error() { { id: '5', label: 'Tanya Fox', value: '5' }, { id: '6', label: 'Hellen Schmidt', value: '6' }, ]; - const [selectedEntry, setSelectedEntry] = useState( + const [selectedEntry, setSelectedEntry] = useState( people[0], ); const [query, setQuery] = useState(''); @@ -171,7 +171,7 @@ export function Error() { return ( Date: Sun, 30 Oct 2022 11:38:24 +0800 Subject: [PATCH 11/18] [resumes][fix] minor ui fixes --- .../portal/src/components/resumes/browse/ResumeFilterPill.tsx | 4 +++- apps/portal/src/pages/resumes/index.tsx | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/portal/src/components/resumes/browse/ResumeFilterPill.tsx b/apps/portal/src/components/resumes/browse/ResumeFilterPill.tsx index aca89b17..cc1882f2 100644 --- a/apps/portal/src/components/resumes/browse/ResumeFilterPill.tsx +++ b/apps/portal/src/components/resumes/browse/ResumeFilterPill.tsx @@ -15,7 +15,9 @@ export default function ResumeFilterPill({

onClearFilterClick(filter.id)}> Clear

@@ -553,7 +553,7 @@ export default function ResumeHomePage() { ))}

onClearFilterClick(filter.id)}> Clear

From 39b5a51aa2752d5b6d1484d91b147c09436536f2 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 30 Oct 2022 12:01:54 +0800 Subject: [PATCH 12/18] [portal][fix] fix GA loading for products --- .../src/components/global/GoogleAnalytics.tsx | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/portal/src/components/global/GoogleAnalytics.tsx b/apps/portal/src/components/global/GoogleAnalytics.tsx index 984935a6..1d7d4f75 100644 --- a/apps/portal/src/components/global/GoogleAnalytics.tsx +++ b/apps/portal/src/components/global/GoogleAnalytics.tsx @@ -1,5 +1,5 @@ +import Head from 'next/head'; import { useRouter } from 'next/router'; -import Script from 'next/script'; import { createContext, useContext, useEffect } from 'react'; type Context = Readonly<{ @@ -78,25 +78,26 @@ export default function GoogleAnalytics({ children, measurementID }: Props) { return ( {children} - {/* Global Site Tag (gtag.js) - Google Analytics */} -