Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display issue with TitledBox in Project Form #1658

Merged
merged 8 commits into from
Oct 15, 2024
97 changes: 61 additions & 36 deletions client/src/components/ProjectForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,39 +239,34 @@ export default function ProjectForm({
<TitledBox
title={editMode ? 'Editing Project' : 'Project Information'}
badge={isEdit ? editIcon() : addIcon()}
/>
) : (
<TitledBox title={'Project Information'} />
)}
<form
id="project-form"
onSubmit={handleSubmit((data) => {
isEdit ? submitEditProject(data) : submitNewProject(data);
})}
>
{arr.map((input) => (
<ValidatedTextField
key={input.name}
register={register}
isEdit={isEdit}
editMode={editMode}
locationType={locationType}
locationRadios={locationRadios}
errors={errors}
input={input}
/>
))}
<ChangesModal
open={isModalOpen}
onClose={handleClose}
destination={'/projects'}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
handleClose={handleClose}
/>
</form>
{auth.user.accessLevel === 'admin' ? (
<Box>
>
<form
id="project-form"
onSubmit={handleSubmit((data) => {
isEdit ? submitEditProject(data) : submitNewProject(data);
})}
>
{arr.map((input) => (
<ValidatedTextField
key={input.name}
register={register}
isEdit={isEdit}
editMode={editMode}
locationType={locationType}
locationRadios={locationRadios}
errors={errors}
input={input}
/>
))}
<ChangesModal
open={isModalOpen}
onClose={handleClose}
destination={'/projects'}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
handleClose={handleClose}
/>
</form>{' '}
<Grid container justifyContent="space-evenly" sx={{ my: 3 }}>
<Grid item xs="auto">
<StyledButton
Expand All @@ -281,7 +276,7 @@ export default function ProjectForm({
!isEdit ? 'secondary' : !editMode ? 'contained' : 'secondary'
}
cursor="pointer"
disabled={isEdit && !isLoading ? !editMode : false}
disabled={isEdit && isLoading ? !editMode : false}
>
{isLoading ? <CircularProgress /> : 'Save'}
</StyledButton>
Expand All @@ -300,9 +295,39 @@ export default function ProjectForm({
</StyledButton>
</Grid>
</Grid>
</Box>
</TitledBox>
) : (
''
<TitledBox title={'Project Information'}>
{' '}
<form
id="project-form"
onSubmit={handleSubmit((data) => {
isEdit ? submitEditProject(data) : submitNewProject(data);
})}
>
{arr.map((input) => (
<ValidatedTextField
key={input.name}
register={register}
isEdit={isEdit}
editMode={editMode}
locationType={locationType}
locationRadios={locationRadios}
errors={errors}
input={input}
/>
))}
<ChangesModal
open={isModalOpen}
onClose={handleClose}
destination={'/projects'}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
handleClose={handleClose}
/>
</form>
{''}
</TitledBox>
)}
</Box>
) : (
Expand Down
Loading