diff --git a/client/src/components/ProjectForm.jsx b/client/src/components/ProjectForm.jsx
index b21e8b4ed..6b92721c7 100644
--- a/client/src/components/ProjectForm.jsx
+++ b/client/src/components/ProjectForm.jsx
@@ -11,6 +11,7 @@ import {
FormControl,
FormControlLabel,
RadioGroup,
+ Paper,
} from '@mui/material';
import { styled } from '@mui/material/styles';
@@ -235,102 +236,105 @@ export default function ProjectForm({
{projectName}
- {auth.user.accessLevel === 'admin' ||
- auth.user.accessLevel == 'superadmin' ? (
-
- {' '}
-
-
-
- {isLoading ? : 'Save'}
-
+
+
+
+
+ {isLoading ? : 'Save'}
+
+
+
+
+ Close
+
+
-
-
- Close
-
-
-
-
- ) : (
-
- {' '}
-
+
+ )}
+
);
}
diff --git a/client/src/components/parts/form/ValidatedTextField.jsx b/client/src/components/parts/form/ValidatedTextField.jsx
index a8ac35499..162f1b464 100644
--- a/client/src/components/parts/form/ValidatedTextField.jsx
+++ b/client/src/components/parts/form/ValidatedTextField.jsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { Box, Grid, InputLabel, TextField } from "@mui/material";
+import { Box, Grid, InputLabel, TextField } from '@mui/material';
/**
* A validated text field component for forms.
@@ -24,61 +24,75 @@ function ValidatedTextField({
locationRadios,
input,
}) {
-
const validationRules = {};
- // Validation rules for Google Drive URL
- if (input.required) {
- validationRules.required = `${input.label || input.name} is required`
+ // Handle required validation
+ if (input.required !== false) {
+ validationRules.required = `${input.label || input.name} is required`;
+ }
+
+ // Handle custom validation function if provided
+ if (input.validate) {
+ validationRules.validate = input.validate;
}
- if(input.name === 'googleDriveUrl'){
+
+ // Validation rules for Google Drive URL
+ if (input.name === 'googleDriveUrl') {
validationRules.pattern = {
value: /^https:\/\/drive\.google\.com\/.+$/,
- message: "Invalid Google Drive URL", // Pattern validation for Google Drive URL
+ message: 'Invalid Google Drive URL',
};
}
+ // Handle location field validation based on type
if (input.name === 'location') {
if (locationType === 'remote') {
validationRules.pattern = {
value: input.value,
- message: input.errorMessage || "Invalid remote location URL",
+ message: input.errorMessage || 'Invalid remote location URL',
};
} else {
validationRules.pattern = {
value: input.addressValue,
- message: input.addressError || "Invalid physical address",
+ message: input.addressError || 'Invalid physical address',
};
}
+ } else if (input.value && input.name !== 'googleDriveUrl') {
+ // Handle other pattern validations
+ validationRules.pattern = {
+ value: input.value,
+ message:
+ input.errorMessage || `${input.label} is not in the correct format`,
+ };
}
-
+
const registerObj = {
...register(input.name, validationRules),
- }
+ };
return (
-
-
-
-
- {input.label}
-
+
+
+
+
+ {input.label}
+
+
+ {input.name === 'location' && locationRadios}
- {input.name === 'location' && locationRadios}
-
-
-
+
+
);
-};
+}
-export default ValidatedTextField;
\ No newline at end of file
+export default ValidatedTextField;