diff --git a/src/frontend/src/components/organisation/Validation/OrganisationAddValidation.tsx b/src/frontend/src/components/organisation/Validation/OrganisationAddValidation.tsx index 891daebbb8..0d947418f4 100644 --- a/src/frontend/src/components/organisation/Validation/OrganisationAddValidation.tsx +++ b/src/frontend/src/components/organisation/Validation/OrganisationAddValidation.tsx @@ -4,6 +4,9 @@ interface OrganisationValues { description: string; url: string; type: number; + odk_central_url: string; + odk_central_user: string; + odk_central_password: string; } interface ValidationErrors { logo?: string; @@ -11,6 +14,9 @@ interface ValidationErrors { description?: string; url?: string; type?: string; + odk_central_url?: string; + odk_central_user?: string; + odk_central_password?: string; } function isValidUrl(url: string) { @@ -25,21 +31,28 @@ function isValidUrl(url: string) { function OrganisationAddValidation(values: OrganisationValues) { const errors: ValidationErrors = {}; - // if (!values?.logo) { - // errors.logo = 'Logo is Required.'; - // } if (!values?.name) { errors.name = 'Name is Required.'; } + if (!values?.description) { errors.description = 'Description is Required.'; } + if (!values?.url) { errors.url = 'Organization Url is Required.'; } else if (!isValidUrl(values.url)) { errors.url = 'Invalid URL.'; } + if (values?.odk_central_url && !isValidUrl(values.odk_central_url)) { + errors.odk_central_url = 'Invalid URL.'; + } + + // if (!values?.logo) { + // errors.logo = 'Logo is Required.'; + // } + return errors; } diff --git a/src/frontend/src/models/organisation/organisationModel.ts b/src/frontend/src/models/organisation/organisationModel.ts index 50e913c78e..4472b8e4b6 100644 --- a/src/frontend/src/models/organisation/organisationModel.ts +++ b/src/frontend/src/models/organisation/organisationModel.ts @@ -28,12 +28,3 @@ export interface GetOrganisationDataModel { logo: string; url: string; } -export interface PostOrganisationDataModel { - name: string; - slug: string; - description: string; - type: number; - id: number; - logo: string; - url: string; -} diff --git a/src/frontend/src/views/CreateOrganisation.tsx b/src/frontend/src/views/CreateOrganisation.tsx index 16d51dd54e..4ed89c1714 100644 --- a/src/frontend/src/views/CreateOrganisation.tsx +++ b/src/frontend/src/views/CreateOrganisation.tsx @@ -132,6 +132,69 @@ const CreateOrganisationForm = () => { FormHelperTextProps={inputFormStyles()} /> + + + + ODK Central URL (Optional) + + + { + handleCustomChange('odk_central_url', e.target.value); + }} + fullWidth + multiline + rows={1} + helperText={errors.odk_central_url} + FormHelperTextProps={inputFormStyles()} + /> + + + + + ODK Central User (Optional) + + + { + handleCustomChange('odk_central_user', e.target.value); + }} + fullWidth + multiline + rows={1} + helperText={errors.odk_central_user} + FormHelperTextProps={inputFormStyles()} + /> + + + + + ODK Central Password (Optional) + + + { + handleCustomChange('odk_central_password', e.target.value); + }} + fullWidth + multiline + rows={1} + helperText={errors.odk_central_password} + FormHelperTextProps={inputFormStyles()} + /> +