diff --git a/apps/edr-freight-web/portal/src/pages/accounts/SignupPage.tsx b/apps/edr-freight-web/portal/src/pages/accounts/SignupPage.tsx index 35ff521ed..1b13f7cfc 100644 --- a/apps/edr-freight-web/portal/src/pages/accounts/SignupPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/accounts/SignupPage.tsx @@ -34,8 +34,6 @@ import { ControlledPhoneField, isValidPhone } from "@/components/PhoneField"; import { api } from "@/services/api"; import { extractApiError } from "@/utils/result"; -const EDR_LOGO = "/assets/edr-logo.png"; - const passwordRequirements = [ { label: "At least 8 characters", test: (v: string) => v.length >= 8 }, { label: "One uppercase letter", test: (v: string) => /[A-Z]/.test(v) }, @@ -244,259 +242,270 @@ export default function SignupPage() { return ( -
- {stage === "form" ? ( -
-
-

- Create account -

-

- Register to access EDR Freight services. +

+ { stage === "form" ? ( + +
+

+ Create account +

+ < p className = "text-sm leading-relaxed text-gray-500" > + Register to access EDR Freight services.

-
+
- - - + + - - + - - + < ControlledPhoneField + control = { control } + name = "phone" + label = "Phone" + required + disabled = { sending } + /> -
- - Send verification code via - - setChannel(v as OtpChannel)} - data={[ - { - value: "phone", - label: ( - - Phone - +
+ + Send verification code via + + < SegmentedControl + fullWidth + disabled = { sending } + value = { channel } + onChange = {(v) => setChannel(v as OtpChannel) +} +data = { + [ + { + value: "phone", + label: ( + + Phone + ), - }, - { - value: "email", - label: ( - - Email - +}, +{ + value: "email", + label: ( + + Email + ), }, ]} /> -
+
-
- + - {passwordValue.length > 0 ? ( -
- {passwordRequirements.map((req) => { - const met = req.test(passwordValue); - return ( -
- 0 ? ( +
+ { + passwordRequirements.map((req) => { + const met = req.test(passwordValue); + return ( +
+ - {met ? ( - - ) : ( - - )} - - + ): ( + + ) + } + + < span + className = {`text-xs ${met ? "text-primary" : "text-gray-500"}` +} > - {req.label} - -
+ { req.label } + +
); })} -
+
) : null} -
+
- - {error ? ( - } +{ + error ? ( + } > - {error} - + { error } + ) : null} - + Continue + -

- Already have an account?{" "} - -

- - + < p className = "text-center text-sm text-gray-500" > + Already have an account ? { " "} + < button + type = "button" +onClick = {() => navigate("/login")} +className = "font-semibold text-primary hover:underline" + > + Sign In + +

+ + ) : ( - -
- - - -
-
-

- Verify your {otpChannel === "email" ? "email" : "phone"} -

-

- We sent a 6-digit code to{" "} - - {otpChannel === "email" - ? maskEmail(pendingData?.email ?? "") - : maskPhone(pendingData?.phone ?? "")} - - . Enter it to finish creating your account. + +

+ + + +
+ < div className = "space-y-1.5 text-center" > +

+ Verify your { otpChannel === "email" ? "email" : "phone" } +

+ < p className = "text-sm leading-relaxed text-gray-500" > + We sent a 6 - digit code to{ " " } + + { otpChannel === "email" + ? maskEmail(pendingData?.email ?? "") + : maskPhone(pendingData?.phone ?? "")} + + .Enter it to finish creating your account.

-
+
- {otpError ? ( - } +{ + otpError ? ( + } > - {otpError} - + { otpError } + ) : null} - - - Verification code - - - + + + Verification code + + < PinInput +length = { 6} +type = "number" +oneTimeCode +value = { otpCode } +placeholder = "0" +disabled = { verifying } +styles = {{ input: { textAlign: "center" } }} +onChange = { setOtpCode } + /> + - + < Button +color = "edr-green" +fullWidth +loading = { verifying } +disabled = { verifying || otpCode.trim().length !== 6} +onClick = { confirmOtp } + > + Verify & amp; create account + -
- - -
- + Back + + < Button +variant = "subtle" +color = "edr-green" +leftSection = {< RotateCw size = { 14} />} +disabled = { resendIn > 0 || sending || verifying} +onClick = { resendOtp } + > + { resendIn > 0 ? `Resend in ${resendIn}s` : "Resend code"} + + + )} - -
+ + ); } diff --git a/apps/edr-freight-web/portal/src/services/auth.service.ts b/apps/edr-freight-web/portal/src/services/auth.service.ts index 58b81c5ba..3f9ef4e53 100644 --- a/apps/edr-freight-web/portal/src/services/auth.service.ts +++ b/apps/edr-freight-web/portal/src/services/auth.service.ts @@ -54,7 +54,7 @@ export const authService = { }, checkAvailability: async (params: CheckAvailabilityPayload) => { - const res = await client.get>( + const res = await client.get( URL_CONSTANTS.USERS.CHECK_AVAILABILITY, { params }, );