import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import Header from "../../components/Header";
import Layout from "../../components/Layout";
import apiOdoo from "../../helpers/apiOdoo";
import {
getAuth,
setAuth as setAuthCookie
} from "../../helpers/auth";
export default function MyProfile() {
const [auth, setAuth] = useState({
name: '',
email: '',
phone: '',
mobile: ''
});
useEffect(() => {
setAuth(getAuth());
}, []);
const update = async (e) => {
e.preventDefault();
let update = await apiOdoo('PUT', `/api/v1/user/${auth.id}`, {
name: auth.name,
phone: auth.phone,
mobile: auth.mobile,
token: auth.token
});
setAuthCookie(update.user);
toast.success('Berhasil mengubah profil', { duration: 1500 });
};
const handleInput = (e) => {
let authToUpdate = auth;
authToUpdate[e.target.name] = e.target.value;
setAuth({ ...authToUpdate });
}
return (
<>
>
);
}