Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mahid797 committed Feb 3, 2025
2 parents 31314be + ff5c802 commit 802b91f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Client/src/app/documents/components/CreateLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function CreateLink({ onClose, open, documentId }: CreateLinkProp
requiredUserDetailsOption: 1,
};

const { values, setValues, validateAll, getError } = useValidatedFormData<LinkFormValues>({
const { values, setValues, validateAll, getError, handleBlur } = useValidatedFormData<LinkFormValues>({
initialValues: initialFormValues,
validationRules
});
Expand Down Expand Up @@ -144,6 +144,7 @@ export default function CreateLink({ onClose, open, documentId }: CreateLinkProp
const { loading, handleSubmit, error, toast } = useFormSubmission({
onSubmit: async () => {
const hasError = validateAll();

if (hasError) {
throw new Error('Please correct any errors before generating a link.');
}
Expand Down Expand Up @@ -232,6 +233,7 @@ export default function CreateLink({ onClose, open, documentId }: CreateLinkProp
<SharingOptionsAccordion
getError={getError}
formValues={values}
handleBlur={handleBlur}
handleInputChange={handleInputChange}
isPasswordVisible={isPasswordVisible}
setIsPasswordVisible={setIsPasswordVisible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface SharingOptionsAccordionProps {
expirationType: string;
getError: (fieldName: keyof LinkFormValues) => string;
handleExpirationChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
handleBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
}

const SharingOptionsAccordion = ({
Expand All @@ -25,6 +26,7 @@ const SharingOptionsAccordion = ({
isPasswordVisible,
setIsPasswordVisible,
expirationType,
handleBlur,
handleExpirationChange,
}: SharingOptionsAccordionProps) => {
return (
Expand Down Expand Up @@ -77,7 +79,6 @@ const SharingOptionsAccordion = ({
mb={4}
ml={13}>
<FormInput

id='password'
minWidth={420}
value={formValues.password}
Expand All @@ -94,6 +95,7 @@ const SharingOptionsAccordion = ({
type={isPasswordVisible ? 'text' : 'password'}
disabled={!formValues.requirePassword}
errorMessage={getError('password')}
onBlur={handleBlur}
/>
<IconButton
size='large'
Expand Down

0 comments on commit 802b91f

Please sign in to comment.