Skip to content

Commit

Permalink
better error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoshenka committed Mar 19, 2024
1 parent 634302d commit 7fbb82c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/profile/AboutInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isValidAddress, isValidBio } from './validations'
import { AvatarSetup } from '@/components/profile/AvatarSetup'
import { AvatarFragment } from '@/utils/types/profile'
import { LocationAutocompleteInput } from '@/components/core/LocationAutocompleteInput'
import { REQUIRED_FIELD_ERROR } from '@/utils/validate'
import { ADDRESS_ERROR } from '@/utils/validate'
import { AddressFragment } from '@/utils/types/location'

interface AboutInputProps {
Expand Down Expand Up @@ -49,7 +49,7 @@ export const AboutInput = ({
'Precise location will not be public. If nomadic, what city do you spend the biggest chunk of time?'
}
error={!isValidAddress(address)}
errorMessage={REQUIRED_FIELD_ERROR}
errorMessage={ADDRESS_ERROR}
/>
</SetupStepContainer>
)
Expand Down
4 changes: 2 additions & 2 deletions components/profile/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
isValidName,
} from './validations'
import { LocationAutocompleteInput } from '@/components/core/LocationAutocompleteInput'
import { REQUIRED_FIELD_ERROR } from '@/utils/validate'
import { ADDRESS_ERROR } from '@/utils/validate'
import { AddressFragment } from '@/utils/types/location'

interface RegistrationFormProps {
Expand Down Expand Up @@ -119,7 +119,7 @@ export const RegistrationForm = ({ onSubmit }: RegistrationFormProps) => {
'Precise location will not be public. If nomadic, what city do you spend the biggest chunk of time?'
}
error={canShowAddressError && !isValidAddress(address)}
errorMessage={REQUIRED_FIELD_ERROR}
errorMessage={ADDRESS_ERROR}
/>
</InputContainer>
</InputGroup>
Expand Down
2 changes: 2 additions & 0 deletions utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const REQUIRED_FIELD_ERROR = 'This field is required'
export const INVALID_FIELD_ERROR = 'This field is invalid'
export const REQUIRED_SECTION_ERROR = 'This section is required'
export const PHOTO_REQUIRED_ERROR = 'At least one photo is required'
export const ADDRESS_ERROR =
'Please enter a valid address that includes a city and country'

export const REQUIRED_FIELDS_TOAST_ERROR =
'Oops! It seems that one or more fields require your attention.'
Expand Down

0 comments on commit 7fbb82c

Please sign in to comment.