upd: loading saat melakukan aksi pada detail pengaduan
- mencegah 2x klik NO Issues
This commit is contained in:
@@ -93,6 +93,7 @@ function DetailDataPengaduan({
|
|||||||
const [keterangan, setKeterangan] = useState("");
|
const [keterangan, setKeterangan] = useState("");
|
||||||
const [host, setHost] = useState<User | null>(null);
|
const [host, setHost] = useState<User | null>(null);
|
||||||
const [permissions, setPermissions] = useState<JsonValue[]>([]);
|
const [permissions, setPermissions] = useState<JsonValue[]>([]);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchHost() {
|
async function fetchHost() {
|
||||||
@@ -111,6 +112,7 @@ function DetailDataPengaduan({
|
|||||||
|
|
||||||
const handleKonfirmasi = async (cat: "terima" | "tolak") => {
|
const handleKonfirmasi = async (cat: "terima" | "tolak") => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
const res = await apiFetch.api.pengaduan["update-status"].post({
|
const res = await apiFetch.api.pengaduan["update-status"].post({
|
||||||
id: data?.id,
|
id: data?.id,
|
||||||
status:
|
status:
|
||||||
@@ -184,6 +186,8 @@ function DetailDataPengaduan({
|
|||||||
message: "Failed to update pengaduan",
|
message: "Failed to update pengaduan",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -218,6 +222,7 @@ function DetailDataPengaduan({
|
|||||||
color="red"
|
color="red"
|
||||||
disabled={keterangan.length < 1}
|
disabled={keterangan.length < 1}
|
||||||
onClick={() => handleKonfirmasi("tolak")}
|
onClick={() => handleKonfirmasi("tolak")}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Tolak
|
Tolak
|
||||||
</Button>
|
</Button>
|
||||||
@@ -242,6 +247,7 @@ function DetailDataPengaduan({
|
|||||||
variant="filled"
|
variant="filled"
|
||||||
color="green"
|
color="green"
|
||||||
onClick={() => handleKonfirmasi("terima")}
|
onClick={() => handleKonfirmasi("terima")}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Ya
|
Ya
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user