Decs:
- Perubahan Minor
This commit is contained in:
2023-10-05 12:00:54 +08:00
parent 20016ff0c2
commit cc031fea8a
2 changed files with 11 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ export default function EditProfile({ data }: { data: any }) {
const router = useRouter(); const router = useRouter();
//Get data profile //Get data profile
const [profile, setProfile] = useState(data); const [profile, setProfile] = useState(data)
useShallowEffect(() => { useShallowEffect(() => {
loadDataProfile(setProfile); loadDataProfile(setProfile);
}, []); }, []);
@@ -39,6 +39,7 @@ export default function EditProfile({ data }: { data: any }) {
myConsole(val); myConsole(val);
if (val.status == 200) { if (val.status == 200) {
toast("Data tersimpan"); toast("Data tersimpan");
loadDataProfile(setProfile)
return router.push("/dev/katalog/view"); return router.push("/dev/katalog/view");
} else { } else {
return toast("Gagal update !!!"); return toast("Gagal update !!!");
@@ -46,17 +47,19 @@ export default function EditProfile({ data }: { data: any }) {
}); });
} }
if(!profile) return <></>
return ( return (
<> <>
{/* {JSON.stringify(profile)} */} {/* {JSON.stringify(profile)} */}
<Stack px={"sm"}> <Stack px={"sm"}>
<TextInput label="Username" disabled value={profile.User.username} /> <TextInput label="Username" disabled value={profile?.User.username} />
<TextInput label="Nomor" disabled value={profile.User.nomor} /> <TextInput label="Nomor" disabled value={profile?.User.nomor} />
<TextInput <TextInput
label="Nama" label="Nama"
placeholder="username" placeholder="username"
value={profile.name} value={profile?.name}
onChange={(val) => { onChange={(val) => {
setProfile({ setProfile({
...profile, ...profile,
@@ -68,7 +71,7 @@ export default function EditProfile({ data }: { data: any }) {
<TextInput <TextInput
label="Email" label="Email"
placeholder="email" placeholder="email"
value={profile.email} value={profile?.email}
onChange={(val) => { onChange={(val) => {
myConsole(val.target.value); myConsole(val.target.value);
setProfile({ setProfile({
@@ -81,7 +84,7 @@ export default function EditProfile({ data }: { data: any }) {
<TextInput <TextInput
label="Alamat" label="Alamat"
placeholder="alamat" placeholder="alamat"
value={profile.alamat} value={profile?.alamat}
onChange={(val) => { onChange={(val) => {
myConsole(val.target.value); myConsole(val.target.value);
setProfile({ setProfile({
@@ -93,7 +96,7 @@ export default function EditProfile({ data }: { data: any }) {
<Select <Select
label="Jenis Kelamin" label="Jenis Kelamin"
value={profile.jenisKelamin} value={profile?.jenisKelamin}
data={[ data={[
{ value: "Laki-laki", label: "Laki-laki" }, { value: "Laki-laki", label: "Laki-laki" },
{ value: "Perempuan", label: "Perempuan" }, { value: "Perempuan", label: "Perempuan" },

View File

@@ -47,7 +47,7 @@ export default function KatalogView({data}: {data: any}) {
if (profile?.imagesId === undefined || profile?.imagesId === null) { if (profile?.imagesId === undefined || profile?.imagesId === null) {
myConsole("Waiting data"); myConsole("Waiting data");
} else { } else {
getFotoProfile(profile?.imagesId).then((res) => setFoto(res?.url)); getFotoProfile(profile.imagesId).then((res) => setFoto(res?.url));
} }
myConsole(profile?.imagesId); myConsole(profile?.imagesId);
}, [profile?.imagesId]); }, [profile?.imagesId]);