'use client' import React, { useState } from "react"; import axios from "axios"; import authAxios from "@/utils/axios"; const ChangePassword = () => { const [oldPassword, setOldPassword] = useState(""); const [newPassword, setNewPassword] = useState(""); const [confirmNewPassword, setConfirmNewPassword] = useState(""); const [error, setError] = useState(""); const [success, setSuccess] = useState(""); const handleSubmit = async (e) => { e.preventDefault(); if (!oldPassword || !newPassword || !confirmNewPassword) { setError("All fields are required."); return; } if (newPassword !== confirmNewPassword) { setError("New passwords do not match."); return; } setError(""); try { const response = await authAxios.post( "/account/change-password/", { old_password: oldPassword, new_password: newPassword, confirm_new_password: confirmNewPassword, } ); if (response.data.status) { setSuccess("Password updated successfully."); } else { setError(response.data.message || "Something went wrong."); } } catch (err) { setError("Failed to change password. Please try again."); } }; return (