Fix: tampilan status dan detail status sudah terintegrasi API
- create dan buntton status sudah terintegrasi

### No Issue
This commit is contained in:
2025-10-06 16:00:20 +08:00
parent f3a3acc747
commit ba878d4d08
11 changed files with 395 additions and 96 deletions

View File

@@ -1,20 +1,54 @@
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
import {
apiDonationDelete,
apiDonationUpdateStatus,
} from "@/service/api-client/api-donation";
import { router } from "expo-router";
import { useState } from "react";
import Toast from "react-native-toast-message";
export default function Donation_ButtonStatusSection({
id,
status,
}: {
id: string;
status: string;
}) {
const handleBatalkanReview = () => {
const [isLoading, setLoading] = useState(false);
const [isLoadingDelete, setLoadingDelete] = useState(false);
const handleBatalkanReview = async () => {
AlertDefaultSystem({
title: "Batalkan Review",
message: "Apakah Anda yakin ingin batalkan review ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
setLoading(true);
const response = await apiDonationUpdateStatus({
id: id,
status: "draft",
});
if (!response.success) {
Toast.show({
type: "info",
text1: response.message,
});
return;
}
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoading(false);
}
},
});
};
@@ -25,9 +59,33 @@ export default function Donation_ButtonStatusSection({
message: "Apakah Anda yakin ingin ajukan review ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
setLoading(true);
const response = await apiDonationUpdateStatus({
id: id,
status: "review",
});
if (!response.success) {
Toast.show({
type: "info",
text1: response.message,
});
return;
}
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoading(false);
}
},
});
};
@@ -38,9 +96,33 @@ export default function Donation_ButtonStatusSection({
message: "Apakah Anda yakin ingin edit kembali ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
setLoading(true);
const response = await apiDonationUpdateStatus({
id: id,
status: "draft",
});
if (!response.success) {
Toast.show({
type: "info",
text1: response.message,
});
return;
}
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoading(false);
}
},
});
};
@@ -51,9 +133,30 @@ export default function Donation_ButtonStatusSection({
message: "Apakah Anda yakin ingin menghapus data ini?",
textLeft: "Batal",
textRight: "Hapus",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
setLoadingDelete(true);
const response = await apiDonationDelete({ id: id });
if (!response.success) {
Toast.show({
type: "info",
text1: response.message,
});
return;
}
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoadingDelete(false);
}
},
});
};
@@ -62,6 +165,7 @@ export default function Donation_ButtonStatusSection({
return (
<>
<ButtonCustom
isLoading={isLoadingDelete}
backgroundColor="red"
textColor="white"
onPress={handleOpenDeleteAlert}
@@ -78,7 +182,7 @@ export default function Donation_ButtonStatusSection({
case "review":
return (
<ButtonCustom onPress={handleBatalkanReview}>
<ButtonCustom isLoading={isLoading} onPress={handleBatalkanReview}>
Batalkan Review
</ButtonCustom>
);
@@ -88,7 +192,7 @@ export default function Donation_ButtonStatusSection({
<>
<Grid>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleAjukanReview}>
<ButtonCustom isLoading={isLoading} onPress={handleAjukanReview}>
Ajukan Review
</ButtonCustom>
</Grid.Col>
@@ -104,7 +208,7 @@ export default function Donation_ButtonStatusSection({
<>
<Grid>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleEditKembali}>
<ButtonCustom isLoading={isLoading} onPress={handleEditKembali}>
Edit Kembali
</ButtonCustom>
</Grid.Col>