- PC: Loader chat
- QC: Auth , Profile, portofolio & user search
## No Issuue
git commit -m
This commit is contained in:
2024-05-16 10:03:34 +08:00
parent c57e495d68
commit 66b9902d97
74 changed files with 1336 additions and 622 deletions

View File

@@ -34,6 +34,7 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
import { useForm } from "@mantine/form";
import { useTimeout } from "@mantine/hooks";
import { validRegex } from "../../component/regular_expressions";
export default function CreateProfile({ userId }: { userId: any }) {
const [filePP, setFilePP] = useState<File | null>(null);
@@ -210,7 +211,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
label="Email"
placeholder="Contoh: User@gmail.com"
error={
value.email.length > 0 && !value.email.includes("@")
value.email.length > 0 && !value.email.match(validRegex)
? "Invalid email"
: ""
}
@@ -225,6 +226,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
withAsterisk
label="Alamat"
placeholder="Alamat lengkap"
error={value.alamat.length > 100 ? "Max 100 karakter" : ""}
onChange={(val) => {
setValue({
...value,
@@ -232,6 +234,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
});
}}
/>
<Select
withAsterisk
label="Jenis Kelamin"
@@ -247,6 +250,7 @@ export default function CreateProfile({ userId }: { userId: any }) {
});
}}
/>
<ButtonAction
value={value as any}
userId={userId}
@@ -283,8 +287,8 @@ function ButtonAction({
};
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (!body.email.includes("@"))
return ComponentGlobal_NotifikasiPeringatan("Invalid Email");
if (!body.email.match(validRegex)) return null;
if (body.alamat.length > 100) return null;
const gambarPP = new FormData();
gambarPP.append("filePP", filePP as any);

View File

@@ -17,6 +17,8 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
import { MODEL_PROFILE } from "../model/interface";
import { Profile_funEditById } from "../fun/update/fun_edit_profile_by_id";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { validRegex } from "../../component/regular_expressions";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const router = useRouter();
@@ -29,7 +31,10 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const body = dataProfile;
// console.log(body)
if (_.values(body).includes("")) return toast("Lengkapi data");
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
if (!body.email.match(validRegex)) return null;
if (body.alamat.length > 100) return null;
await Profile_funEditById(body).then((res) => {
if (res.status === 200) {
@@ -100,7 +105,8 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
label="Email"
placeholder="email"
error={
dataProfile?.email?.length > 0 && !dataProfile?.email.includes("@")
dataProfile?.email?.length > 0 &&
!dataProfile?.email.match(validRegex)
? "Invalid email"
: ""
}
@@ -118,6 +124,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
label="Alamat"
placeholder="alamat"
value={dataProfile.alamat}
error={dataProfile.alamat.length > 100 ? "Max 100 karakter" : ""}
onChange={(val) => {
setDataProfile({
...dataProfile,

View File

@@ -5,6 +5,8 @@ import { MODEL_PROFILE } from "../model/interface";
import _ from "lodash";
import { v4 } from "uuid";
import fs from "fs";
import { revalidatePath } from "next/cache";
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
export default async function funCreateNewProfile(
req: MODEL_PROFILE,
@@ -22,6 +24,10 @@ export default async function funCreateNewProfile(
if (findEmail) return { status: 400, message: "Email telah digunakan" };
const gambarProfile: any = gambarPP.get("filePP");
if (gambarProfile === "null")
return { status: 400, message: "Lengkapi Foto Profile" };
const fileName = gambarProfile.name;
const fileExtension = _.lowerCase(gambarProfile.name.split(".").pop());
const fRandomName = v4(fileName) + "." + fileExtension;
@@ -42,6 +48,9 @@ export default async function funCreateNewProfile(
fs.writeFileSync(`./public/profile/foto/${uploadPP.url}`, uploadPP_Folder);
const gambarBackground: any = gambarBG.get("fileBG");
if (gambarBackground === "null")
return { status: 400, message: "Lengkapi Foto Background" };
const fileNameBG = gambarBackground.name;
const fileExtensionBG = _.lowerCase(gambarBackground.name.split(".").pop());
const fRandomNameBG = v4(fileNameBG) + "." + fileExtensionBG;
@@ -65,8 +74,6 @@ export default async function funCreateNewProfile(
uploadBG_Folder
);
const createProfile = await prisma.profile.create({
data: {
userId: body.userId,
@@ -80,6 +87,7 @@ export default async function funCreateNewProfile(
});
if (!createProfile) return { status: 400, message: "Gagal membuat profile" };
revalidatePath(RouterHome.main_home);
return {
status: 201,