Skip to content

Commit

Permalink
make comment error instant
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkang-0 committed May 23, 2024
1 parent 1f45a95 commit c7832f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/onboarding/legal-credentials/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useEffect, useMemo } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { zodResolver } from '@hookform/resolvers/zod';
import { useRouter } from 'next/navigation';
import { FormProvider, useForm } from 'react-hook-form';
Expand Down Expand Up @@ -35,6 +35,7 @@ export default function Page() {
const onboarding = useGuardedOnboarding();
const { backlinkHref, ebbTo, pageProgress } = useOnboardingNavigation();
const { push } = useRouter();
const [commentError, setCommentError] = useState('');

// scroll to top
useScrollToTop();
Expand Down Expand Up @@ -228,8 +229,13 @@ export default function Page() {
<TextAreaInput
placeholder="There are some extenuating circumstances with..."
defaultValue={field.value ?? ''}
error={fieldState.error?.message}
error={fieldState.error?.message ?? commentError}
onChange={newValue => {
setCommentError(
newValue.length > 400
? 'Please keep it within 400 characters'
: '',
);
onboarding.updateProfile({
legal_credential_comment: newValue,
});
Expand Down

0 comments on commit c7832f4

Please sign in to comment.