Skip to content

Commit 7d44264

Browse files
committed
feat: add loading edit org
1 parent 0e459e8 commit 7d44264

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

components/Organization/UpdateOrganization.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ interface IProps {
99
setOrg: Function
1010
setOrgEdit: Function
1111
editType: 'name' | 'address'
12+
loading: boolean
13+
setLoading: Function
1214
}
1315

1416
interface UpdateOrganizationForm {
1517
name?: string
1618
address?: string
1719
}
1820

19-
const UpdateOrganization = ({ user, setError, setOrg, setOrgEdit, editType }: IProps): JSX.Element => {
21+
const UpdateOrganization = ({ user, setError, setOrg, setOrgEdit, editType, loading, setLoading }: IProps): JSX.Element => {
2022
const { register, handleSubmit, reset } = useForm<UpdateOrganizationForm>({})
2123

2224
const onSubmit = async (params: UpdateOrganizationForm): Promise<void> => {
25+
setLoading(true)
2326
const res = await fetch('/api/organization', {
2427
method: 'PUT',
2528
headers: {
@@ -36,6 +39,7 @@ const UpdateOrganization = ({ user, setError, setOrg, setOrgEdit, editType }: IP
3639
const data = await res.json()
3740
setOrg(data.organization)
3841
reset()
42+
setLoading(false)
3943
setOrgEdit('')
4044
} else {
4145
const json = await res.json()
@@ -62,7 +66,7 @@ const UpdateOrganization = ({ user, setError, setOrg, setOrgEdit, editType }: IP
6266
className={style.text_input}
6367
autoFocus
6468
/>
65-
<Button className="ml" type="submit">
69+
<Button className="ml" type="submit" loading={loading}>
6670
Update
6771
</Button>
6872
</div>

components/Organization/ViewOrganization.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const ViewOrganization = ({ user, orgMembers, setOrgMembers, organization }: IPr
104104
setOrg={setOrg}
105105
setOrgEdit={setOrgEdit}
106106
editType={orgEdit as 'name' | 'address'}
107+
loading={loading}
108+
setLoading={setLoading}
107109
/>
108110
)}
109111
</>

0 commit comments

Comments
 (0)