Skip to content

Commit 643bf86

Browse files
authored
Merge pull request #14 from NUGRAHA18/account-delete
Account delete
2 parents 22d5a6d + e3115b6 commit 643bf86

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
base_url=yourAPI
1+
2+
#VITE_API_URL=https://smartfarming.teknohole.com

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist-ssr
2525
*.njsproj
2626
*.sln
2727
*.sw?
28+
.vercel

src/pages/account/delete-account-page.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ const DeleteAccountPage = () => {
6969
setErrorMessage("Gagal: Token akses tidak ditemukan.");
7070
}
7171
} catch (error) {
72-
setErrorMessage(
73-
error.message || "Login Gagal. Cek username & password Anda.",
74-
);
72+
const serverMessage =
73+
error.detail || error.message || "Username atau Password salah.";
74+
const finalMessage =
75+
typeof serverMessage === "object"
76+
? JSON.stringify(serverMessage)
77+
: serverMessage;
78+
79+
setErrorMessage(finalMessage);
7580
} finally {
7681
setLoading(false);
7782
}
@@ -160,6 +165,8 @@ const DeleteAccountPage = () => {
160165
<User className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 w-4 h-4 z-10" />
161166
<Input
162167
type="text"
168+
name="username"
169+
autoComplete="username"
163170
placeholder="Masukkan username..."
164171
value={username}
165172
onChange={(e) => setUsername(e.target.value)}

src/pages/legal/privacy-policy-page.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const PrivacyPolicyPage = () => {
1212
const fetchTerms = async () => {
1313
try {
1414
const response = await getTermsService();
15-
// Ambil string content
1615
let rawText = response.data?.content || response.content || "";
1716

1817
if (rawText) {

src/router.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ const router = createBrowserRouter([
7474
],
7575
},
7676
// Catch all routes
77+
{
78+
path: "/privacy-policy",
79+
element: <PrivacyPolicyPage />,
80+
},
81+
{
82+
path: "/delete-account",
83+
element: <DeleteAccountPage />,
84+
},
7785
{
7886
path: "*",
7987
element: <NotFoundPage />,

src/services/account-service.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import axios from "axios";
22

3-
const API_BASE_URL = import.meta.env.base_url;
3+
const API_BASE_URL = import.meta.env.VITE_API_URL;
44

55
const getApiUrl = () => {
6-
const isLocal = window.location.hostname === "localhost";
7-
return isLocal || API_BASE_URL || "/api-proxy";
6+
return API_BASE_URL || "/api-proxy";
87
};
98

109
export const loginService = async (username, password) => {

vercel.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rewrites": [
3+
{
4+
"source": "/(.*)",
5+
"destination": "/"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)