Skip to content

Commit

Permalink
Merge pull request #349 from ertush/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
ertush authored Mar 25, 2024
2 parents f3d4957 + ed18a4a commit 1b6b748
Show file tree
Hide file tree
Showing 6 changed files with 1,623 additions and 832 deletions.
22 changes: 15 additions & 7 deletions components/Forms/CommunityUnitsForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
})

.then(async resp => {
if (resp.status == 200 || resp.status == 204) {
if (resp.ok) {

setSubmitting(false)

alert.success(`${props?.name} Basic Details Updated successfully`, {
containerStyle: {
Expand All @@ -151,10 +150,12 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
})

} else {
// const detail = await resp.json()
const detail = await resp.json()

const error = Array.isArray(Object.values(detail)) && Object.values(detail).length == 1 ? detail[Object.keys(detail)[0]][0] : ''

setFormError(error)

setSubmitting(false)
// setFormError(Array.isArray(Object.values(detail)) && Object.values(detail).length == 1 && typeof Object.values(detail)[0] == 'string' && detail[0][0])
alert.error('Unable to save Community Units Basic details')
}
})
Expand All @@ -163,6 +164,10 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
catch (e) {
alert.error('Error Occured: ' + e.message)
}
finally {
setSubmitting(false)

}



Expand All @@ -182,6 +187,8 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
onSubmit={handleFormSubmit}
>



{formError && <Alert severity="error" sx={{ width: '100%', marginY: '15px' }}>{formError}</Alert>}

{/* CHU Name */}
Expand Down Expand Up @@ -589,7 +596,7 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
</div>
<div className="sticky top-0 right-10 w-full flex justify-end">
<button
className=" bg-gray-500 rounded p-2 text-white flex text-md font-semibold mt-3"
className="bg-gray-500 rounded p-2 text-white flex text-md font-semibold mt-3"
onClick={handleAddContact}
>
{`Add Contact`}
Expand All @@ -603,6 +610,7 @@ function EditCommunityUnitsBasicDeatilsForm(props) {

<button
type="submit"
disabled={submitting}
className="flex items-center justify-end space-x-2 bg-gray-500 rounded p-1 px-2"
>
<span className="text-medium font-semibold text-white">
Expand All @@ -616,7 +624,7 @@ function EditCommunityUnitsBasicDeatilsForm(props) {
</span>
{
submitting &&
<span className='text-white'>Saving </span>
<span className='text-white'>Saving.. </span>
}

</button>
Expand Down
Loading

0 comments on commit 1b6b748

Please sign in to comment.