Skip to content

Commit 7e4400f

Browse files
committed
[FIX] Fixing Merchant Details Edit
1 parent 7f129f9 commit 7e4400f

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

  • app/(dashboard)/admin/merchant/[id]

app/(dashboard)/admin/merchant/[id]/page.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,24 @@ const handleInputChange = (
9292
setFormData((prev) => ({ ...prev, [name]: value }));
9393
};
9494

95-
const handleSubmit = async (e: React.FormEvent) => {
96-
e.preventDefault();
97-
try {
98-
const response = await apiClient.put(`/api/merchants/${id}`, {
99-
method: "PUT",
100-
headers: { "Content-Type": "application/json" },
101-
body: JSON.stringify(formData),
102-
});
103-
104-
if (!response.ok) {
105-
throw new Error("Failed to update merchant");
106-
}
95+
const handleSubmit = async (e: React.FormEvent) => {
96+
e.preventDefault();
97+
try {
98+
// This is the correct way to use apiClient.put
99+
// It should just take the URL and the data object
100+
const response = await apiClient.put(`/api/merchants/${id}`, formData);
107101

108-
toast.success("Merchant updated successfully");
109-
fetchMerchant(); // Refresh data
110-
} catch (error) {
111-
console.error("Error updating merchant:", error);
112-
toast.error("Failed to update merchant");
102+
if (!response.ok) {
103+
throw new Error("Failed to update merchant");
113104
}
114-
};
105+
106+
toast.success("Merchant updated successfully");
107+
fetchMerchant(); // Refresh data
108+
} catch (error) {
109+
console.error("Error updating merchant:", error);
110+
toast.error("Failed to update merchant");
111+
}
112+
};
115113

116114
const handleDelete = async () => {
117115
if (!confirm("Are you sure you want to delete this merchant?")) {

0 commit comments

Comments
 (0)