upd: loading button
Deskripsi: - tambah folder bar - rename file pada dokumen divisi No Issues
This commit is contained in:
@@ -65,6 +65,7 @@ type PropsPath = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function DocumentDivision() {
|
export default function DocumentDivision() {
|
||||||
|
const [loadingRename, setLoadingRename] = useState(false)
|
||||||
const [isShare, setShare] = useState(false)
|
const [isShare, setShare] = useState(false)
|
||||||
const { token, decryptToken } = useAuthSession()
|
const { token, decryptToken } = useAuthSession()
|
||||||
const { id } = useLocalSearchParams<{ id: string }>()
|
const { id } = useLocalSearchParams<{ id: string }>()
|
||||||
@@ -201,6 +202,7 @@ export default function DocumentDivision() {
|
|||||||
|
|
||||||
async function handleRename() {
|
async function handleRename() {
|
||||||
try {
|
try {
|
||||||
|
setLoadingRename(true)
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiDocumentRename({ user: hasil, ...bodyRename });
|
const response = await apiDocumentRename({ user: hasil, ...bodyRename });
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -214,7 +216,8 @@ export default function DocumentDivision() {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||||
} finally {
|
} finally {
|
||||||
setRename(false);
|
setLoadingRename(false)
|
||||||
|
setRename(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,7 +541,7 @@ export default function DocumentDivision() {
|
|||||||
isVisible={isRename}
|
isVisible={isRename}
|
||||||
setVisible={() => { setRename(false) }}
|
setVisible={() => { setRename(false) }}
|
||||||
onSubmit={() => { handleRename() }}
|
onSubmit={() => { handleRename() }}
|
||||||
disableSubmit={bodyRename.name == ""}
|
disableSubmit={bodyRename.name == "" || loadingRename}
|
||||||
>
|
>
|
||||||
<View>
|
<View>
|
||||||
<InputForm
|
<InputForm
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ export default function HeaderRightDocument({ path }: { path: string }) {
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const update = useSelector((state: any) => state.dokumenUpdate)
|
const update = useSelector((state: any) => state.dokumenUpdate)
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [loadingFolder, setLoadingFolder] = useState(false)
|
||||||
|
|
||||||
async function handleCreateFolder() {
|
async function handleCreateFolder() {
|
||||||
try {
|
try {
|
||||||
|
setLoadingFolder(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiCreateFolderDocument({ data: { user: hasil, name, path, idDivision: id } })
|
const response = await apiCreateFolderDocument({ data: { user: hasil, name, path, idDivision: id } })
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -39,6 +41,7 @@ export default function HeaderRightDocument({ path }: { path: string }) {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||||
} finally {
|
} finally {
|
||||||
|
setLoadingFolder(false)
|
||||||
setNewFolder(false)
|
setNewFolder(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +151,7 @@ export default function HeaderRightDocument({ path }: { path: string }) {
|
|||||||
title="Buat Folder Baru"
|
title="Buat Folder Baru"
|
||||||
isVisible={newFolder}
|
isVisible={newFolder}
|
||||||
setVisible={() => { setNewFolder(false) }}
|
setVisible={() => { setNewFolder(false) }}
|
||||||
disableSubmit={name == ""}
|
disableSubmit={name == "" || loadingFolder}
|
||||||
onSubmit={() => { handleCreateFolder() }}
|
onSubmit={() => { handleCreateFolder() }}
|
||||||
>
|
>
|
||||||
<View>
|
<View>
|
||||||
|
|||||||
Reference in New Issue
Block a user