Fix profile

Deskripsi:
- Fix load image saat di buka
This commit is contained in:
2024-12-11 13:58:32 +08:00
parent 67a66edd19
commit 9ceb4867e3
10 changed files with 40 additions and 24 deletions

View File

@@ -9,15 +9,13 @@ import {
ComponentGlobal_NotifikasiGagal,
ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global";
import { gmailRegex } from "@/app_modules/katalog/component/regular_expressions";
import { Button } from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import funCreateNewProfile from "../../fun/fun_create_profile";
import { MODEL_PROFILE } from "../../model/interface";
import { validRegex } from "@/app_modules/katalog/component";
import { envs } from "@/lib/envs";
import { TokenProvider, TokenStorage } from "@/app/lib/token";
export function Profile_ComponentCreateNewProfile({
value,
@@ -40,7 +38,8 @@ export function Profile_ComponentCreateNewProfile({
};
if (_.values(newData).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (!newData.email.match(validRegex)) return null;
if (!newData.email.match(gmailRegex))
return ComponentGlobal_NotifikasiPeringatan("Format email salah");
if (filePP == null)
return ComponentGlobal_NotifikasiPeringatan("Lengkapi foto profile");

View File

@@ -6,6 +6,8 @@ import {
ComponentGlobal_BoxUploadImage,
ComponentGlobal_ErrorInput,
} from "@/app_modules/_global/component";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import {
AspectRatio,
Avatar,
@@ -22,10 +24,8 @@ import {
} from "@mantine/core";
import { IconAt, IconCamera, IconUpload } from "@tabler/icons-react";
import { useState } from "react";
import { validRegex } from "../../component";
import { Profile_ComponentCreateNewProfile } from "../_component";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import { gmailRegex } from "../../component/regular_expressions";
import { Profile_ComponentCreateNewProfile } from "../_component";
export default function CreateProfile() {
const [filePP, setFilePP] = useState<File | null>(null);
@@ -40,9 +40,6 @@ export default function CreateProfile() {
jenisKelamin: "",
});
// Maksimal ukuran file dalam byte (2 MB)
const MAX_SIZE = 2 * 1024 * 1024; // 2 MB
return (
<>
<Stack px={"sm"} spacing={40}>

View File

@@ -4,14 +4,14 @@ import { Button, Loader, Select, Stack, TextInput } from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { MainColor } from "@/app_modules/_global/color/color_pallet";
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { validRegex } from "../../component/regular_expressions";
import { gmailRegex, validRegex } from "../../component/regular_expressions";
import { Profile_funEditById } from "../fun/update/fun_edit_profile_by_id";
import { MODEL_PROFILE } from "../model/interface";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const router = useRouter();
@@ -24,8 +24,10 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const body = dataProfile;
// console.log(body)
if (_.values(body).includes("")) return null;
if (!body.email.match(validRegex)) return null;
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
if (!body.email.match(gmailRegex))
return ComponentGlobal_NotifikasiPeringatan("Format email salah");
await Profile_funEditById(body).then((res) => {
if (res.status === 200) {
@@ -126,7 +128,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
dataProfile?.email === "" ? (
<ComponentGlobal_ErrorInput text="Masukan email " />
) : dataProfile?.email?.length > 0 &&
!dataProfile?.email.match(validRegex) ? (
!dataProfile?.email.match(gmailRegex) ? (
<ComponentGlobal_ErrorInput text="Invalid email" />
) : (
""

View File

@@ -30,7 +30,10 @@ export default function Profile_UpdateFotoBackground({
src={
image
? image
: APIs.GET({ fileId: profile.imageBackgroundId as any })
: APIs.GET({
fileId: profile.imageBackgroundId as any,
size: "400",
})
}
/>
</AspectRatio>

View File

@@ -27,7 +27,11 @@ export default function UploadFotoProfile({
<Image
style={{ maxHeight: 250 }}
alt="Avatar"
src={image ? image : APIs.GET({ fileId: profile.imageId as any })}
src={
image
? image
: APIs.GET({ fileId: profile.imageId as any, size: "400" })
}
/>
</AspectRatio>
</ComponentGlobal_BoxUploadImage>