fix create profile
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { ComponentGlobal_ErrorInput } from "@/app_modules/_global/component";
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_ErrorInput,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
|
||||
import { apiGetUserById } from "@/app_modules/_global/lib/api_user";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { Select, Stack, TextInput } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconAt } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { emailRegex } from "../../component/regular_expressions";
|
||||
import { Profile_ComponentCreateNewProfile } from "../_component";
|
||||
import Profile_ViewUploadBackground from "./view_upload_background";
|
||||
import Profile_ViewUploadFoto from "./view_upload_foto";
|
||||
import { masterJenisKelamin } from "@/app_modules/_global/lib/master_jenis_kelamin";
|
||||
|
||||
export default function CreateProfile() {
|
||||
const [filePP, setFilePP] = useState<File | null>(null);
|
||||
@@ -24,8 +30,43 @@ export default function CreateProfile() {
|
||||
jenisKelamin: "",
|
||||
});
|
||||
|
||||
const [userLoginId, setUserLoginId] = useState<any | null>();
|
||||
const [dataProfile, setDataProfile] = useState<any | null>();
|
||||
// const router = useRouter();
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleGetUserLoginId();
|
||||
}, []);
|
||||
|
||||
async function handleGetUserLoginId() {
|
||||
try {
|
||||
const response = await apiNewGetUserIdByToken();
|
||||
if (response.success) {
|
||||
// console.log("response", response);
|
||||
setUserLoginId(response.userId);
|
||||
const responseProfile = await apiGetUserById({
|
||||
id: response.userId,
|
||||
});
|
||||
// console.log("responseProfile", responseProfile?.data);
|
||||
if (responseProfile?.success) {
|
||||
setDataProfile(responseProfile?.data);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error get user login id", error);
|
||||
}
|
||||
}
|
||||
|
||||
// console.log("userLoginId", userLoginId);
|
||||
// console.log("dataProfile", dataProfile);
|
||||
|
||||
if (!dataProfile) return <CustomSkeleton height={400} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
{dataProfile?.Profile ? (
|
||||
<ComponentGlobal_BoxInformation informasi="Anda telah memiliki Profile, Kembali ke Home" />
|
||||
) : (
|
||||
<Stack px={"sm"} spacing={40}>
|
||||
<Profile_ViewUploadFoto
|
||||
imgPP={imgPP}
|
||||
@@ -131,6 +172,7 @@ export default function CreateProfile() {
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user