Skip to content

Commit

Permalink
Added error message
Browse files Browse the repository at this point in the history
  • Loading branch information
grafitto committed Feb 10, 2022
1 parent df8a351 commit 7b28485
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/react/Settings/components/CollectionSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ const CollectionSettings = ({
const collectionSettingsObject = collectionSettings.toJS();
const templatesObject: ClientTemplateSchema[] = templates.toJS();

const { register, handleSubmit, watch, setValue, getValues } = useForm({
const {
register,
handleSubmit,
watch,
setValue,
getValues,
formState: { errors },
} = useForm({
defaultValues: collectionSettingsObject,
});

Expand All @@ -57,7 +64,7 @@ const CollectionSettings = ({
register('newNameGeneration');
register('ocrServiceEnabled');
register('home_page', {
validate: (val: string) => validateHomePageRoute(val),
validate: (val: string) => validateHomePageRoute(val) || 'Invalid route',
});

const save = async (newCollectionSettings: Settings) => {
Expand Down Expand Up @@ -113,7 +120,7 @@ const CollectionSettings = ({
</div>
</ToggleChildren>
</SettingsFormElement>

{errors.home_page && <p className="alert alert-danger">Invalid home page url value</p>}
<SettingsFormElement label="Default view">
<div className="col-xs-12 col-lg-3 col-no-gutters">
<select name="defaultLibraryView" className="form-control" ref={register}>
Expand Down

0 comments on commit 7b28485

Please sign in to comment.