From b52f15a937a0cc4b90fddd76c42638a22a3b7cb6 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Mon, 24 Oct 2022 23:00:37 +0800 Subject: [PATCH 1/4] [portal][ui] add error message to checkbox input --- .../ui/src/CheckboxInput/CheckboxInput.tsx | 106 ++++++++++-------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/packages/ui/src/CheckboxInput/CheckboxInput.tsx b/packages/ui/src/CheckboxInput/CheckboxInput.tsx index edeb9d3a..fec43b7e 100644 --- a/packages/ui/src/CheckboxInput/CheckboxInput.tsx +++ b/packages/ui/src/CheckboxInput/CheckboxInput.tsx @@ -7,6 +7,7 @@ type Props = Readonly<{ defaultValue?: boolean; description?: string; disabled?: boolean; + errorMessage?: string; label: string; name?: string; onChange?: ( @@ -21,6 +22,7 @@ function CheckboxInput( defaultValue, description, disabled = false, + errorMessage, label, name, value, @@ -30,59 +32,67 @@ function CheckboxInput( ) { const id = useId(); const descriptionId = useId(); + const errorId = useId(); return ( -
-
- { - onChange?.(event.target.checked, event); - } - : undefined - } - /> -
-
- - {description && ( -

+

+
+ - {description} -

- )} + defaultChecked={defaultValue} + disabled={disabled} + id={id} + name={name} + type="checkbox" + onChange={(event) => { + if (!onChange) { + return; + } + + onChange(event.target.checked, event); + }} + /> +
+
+ + {description && ( +

+ {description} +

+ )} +
+ {errorMessage && ( +

+ {errorMessage} +

+ )}
); } From 64670923e15a080356edba62caa4f71879fa9ee0 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Mon, 24 Oct 2022 23:00:50 +0800 Subject: [PATCH 2/4] [resumes][feat] add error message to submit form --- apps/portal/src/pages/resumes/submit.tsx | 66 ++++++++++++++---------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/apps/portal/src/pages/resumes/submit.tsx b/apps/portal/src/pages/resumes/submit.tsx index c851cafa..7901056b 100644 --- a/apps/portal/src/pages/resumes/submit.tsx +++ b/apps/portal/src/pages/resumes/submit.tsx @@ -86,10 +86,16 @@ export default function SubmitResumeForm({ setValue, reset, watch, + clearErrors, formState: { errors, isDirty, dirtyFields }, } = useForm({ defaultValues: { + additionalInfo: '', + experience: '', isChecked: false, + location: '', + role: '', + title: '', ...initFormDetails, }, }); @@ -296,7 +302,7 @@ export default function SubmitResumeForm({ options={ROLES} placeholder=" " required={true} - onChange={(val) => setValue('role', val)} + onChange={(val) => onValueChange('role', val)} /> setValue('location', val)} + onChange={(val) => onValueChange('location', val)} /> {/* Upload resume form */} {isNewForm && ( @@ -335,6 +341,16 @@ export default function SubmitResumeForm({ : 'border-slate-300', 'flex cursor-pointer justify-center rounded-md border-2 border-dashed bg-slate-100 py-4', )}> +
{resumeFile == null ? ( @@ -345,29 +361,15 @@ export default function SubmitResumeForm({ {resumeFile.name}

)} -
- -
+

PDF up to {FILE_SIZE_LIMIT_MB}MB

@@ -394,8 +396,18 @@ export default function SubmitResumeForm({ setValue('isChecked', val)} + onChange={(val) => { + if (val) { + clearErrors('isChecked'); + } + setValue('isChecked', val); + }} /> )} From 0d53dab7a835f40cd974c91abb6c17bd593372df Mon Sep 17 00:00:00 2001 From: Zhang Ziqing <69516975+ziqing26@users.noreply.github.com> Date: Mon, 24 Oct 2022 23:18:23 +0800 Subject: [PATCH 3/4] [offers][fix] fix landing page description (#424) * [offers][fix] fix landing page width * [offers][fix] fix landing page typo * [offers][chore] fix British English in landing page * [offers][chore] fix description in landing page --- .../src/components/offers/OffersNavigation.ts | 2 +- .../offers/landing/LeftTextCard.tsx | 9 ++-- .../offers/landing/RightTextCard.tsx | 9 ++-- .../offers/profile/ProfileComments.tsx | 31 +------------ apps/portal/src/components/offers/types.ts | 2 + .../src/pages/offers/{home.tsx => browse.tsx} | 0 apps/portal/src/pages/offers/index.tsx | 44 +++++++++---------- .../pages/offers/profile/[offerProfileId].tsx | 5 ++- 8 files changed, 39 insertions(+), 63 deletions(-) rename apps/portal/src/pages/offers/{home.tsx => browse.tsx} (100%) diff --git a/apps/portal/src/components/offers/OffersNavigation.ts b/apps/portal/src/components/offers/OffersNavigation.ts index 9b340cec..0c43c644 100644 --- a/apps/portal/src/components/offers/OffersNavigation.ts +++ b/apps/portal/src/components/offers/OffersNavigation.ts @@ -1,7 +1,7 @@ import type { ProductNavigationItems } from '~/components/global/ProductNavigation'; const navigation: ProductNavigationItems = [ - { href: '/offers/home', name: 'Home' }, + { href: '/offers/browse', name: 'Browse' }, { href: '/offers/submit', name: 'Analyse your offers' }, ]; diff --git a/apps/portal/src/components/offers/landing/LeftTextCard.tsx b/apps/portal/src/components/offers/landing/LeftTextCard.tsx index 27886018..329a58f5 100644 --- a/apps/portal/src/components/offers/landing/LeftTextCard.tsx +++ b/apps/portal/src/components/offers/landing/LeftTextCard.tsx @@ -1,5 +1,7 @@ import type { ReactNode } from 'react'; +import { HOME_URL } from '~/components/offers/types'; + type LeftTextCardProps = Readonly<{ description: string; icon: ReactNode; @@ -8,7 +10,6 @@ type LeftTextCardProps = Readonly<{ title: string; }>; -const baseUrl = '/offers/home'; export default function LeftTextCard({ description, icon, @@ -21,7 +22,7 @@ export default function LeftTextCard({
- + {icon}
@@ -32,8 +33,8 @@ export default function LeftTextCard({

{description}

diff --git a/apps/portal/src/components/offers/landing/RightTextCard.tsx b/apps/portal/src/components/offers/landing/RightTextCard.tsx index 551c246a..9028ad16 100644 --- a/apps/portal/src/components/offers/landing/RightTextCard.tsx +++ b/apps/portal/src/components/offers/landing/RightTextCard.tsx @@ -1,5 +1,7 @@ import type { ReactNode } from 'react'; +import { HOME_URL } from '~/components/offers/types'; + type RightTextCarddProps = Readonly<{ description: string; icon: ReactNode; @@ -8,7 +10,6 @@ type RightTextCarddProps = Readonly<{ title: string; }>; -const baseUrl = '/offers/home'; export default function RightTextCard({ description, icon, @@ -21,7 +22,7 @@ export default function RightTextCard({
- + {icon}
@@ -32,8 +33,8 @@ export default function RightTextCard({

{description}

diff --git a/apps/portal/src/components/offers/profile/ProfileComments.tsx b/apps/portal/src/components/offers/profile/ProfileComments.tsx index ebed5bfd..b26f78ae 100644 --- a/apps/portal/src/components/offers/profile/ProfileComments.tsx +++ b/apps/portal/src/components/offers/profile/ProfileComments.tsx @@ -175,36 +175,7 @@ export default function ProfileComments({ ) : (
Please log in before commenting on this profile.
)} -
-