- src/app/(support)/delete-account/page.tsx
- src/app/(support)/support-center/page.tsx
- src/app/api/helper/support-center/route.ts

### No Issue
This commit is contained in:
2025-11-18 14:02:17 +08:00
parent 32619ee9b3
commit fcad857422
3 changed files with 75 additions and 41 deletions

View File

@@ -20,6 +20,7 @@ export default function DeleteAccount() {
const [data, setData] = useState({
description: "",
});
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
// Hanya di client, setelah mount
@@ -31,15 +32,32 @@ export default function DeleteAccount() {
}, []);
const handlerSubmit = async () => {
if (!phoneNumber || !data.description) {
if (!phoneNumber) {
return notifications.show({
title: "Error",
message: "Please fill in description & phone number",
message: "Please check your phone number",
color: "red",
});
}
if (!data.description) {
return notifications.show({
title: "Error",
message: "Please fill in description with 'Delete Account'",
color: "red",
});
}
if (data.description !== "Delete Account") {
return notifications.show({
title: "Error",
message: "Please fill in description with 'Delete Account'",
color: "red",
});
}
try {
setIsLoading(true);
const response = await fetch("/api/helper/delete-account", {
method: "POST",
headers: {
@@ -67,12 +85,14 @@ export default function DeleteAccount() {
if (!result.success) {
notifications.show({
title: "Error",
message: result.error,
message: result.error || "Failed to delete account.",
color: "red",
});
}
} catch (error) {
console.log(error);
} finally {
setIsLoading(false);
}
};
@@ -121,7 +141,7 @@ export default function DeleteAccount() {
/>
</Grid.Col>
<Grid.Col span={4}>
<Button onClick={handlerSubmit} w={"100%"}>
<Button onClick={handlerSubmit} w={"100%"} loading={isLoading}>
Submit
</Button>
</Grid.Col>