Fix file image
Deskripsi: - Ukuran file yang di ambil dari server wibu di batasi menjadi maksimal hanya 500kb
This commit is contained in:
@@ -22,6 +22,9 @@ import { IconCamera } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { Portofolio_ComponentButtonSelanjutnya } from "../component";
|
||||
import { MAX_SIZE } from "@/app_modules/_global/lib";
|
||||
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export default function CreatePortofolio({
|
||||
bidangBisnis,
|
||||
@@ -184,8 +187,16 @@ export default function CreatePortofolio({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
if (files.size > MAX_SIZE) {
|
||||
setImg(null);
|
||||
setFile(null);
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
} else {
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ import { IconCamera } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { MODEL_PORTOFOLIO } from "../../model/interface";
|
||||
import { ComponentPortofolio_ButtonEditLogoBisnis } from "../../component";
|
||||
import { MAX_SIZE } from "@/app_modules/_global/lib";
|
||||
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export default function Portofolio_EditLogoBisnis({
|
||||
dataPorto,
|
||||
@@ -47,8 +50,15 @@ export default function Portofolio_EditLogoBisnis({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
} else {
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ function MapView({
|
||||
<Avatar
|
||||
src={
|
||||
data.pinId === null
|
||||
? APIs.GET({ fileId: logoId })
|
||||
: APIs.GET({ fileId: data.pinId })
|
||||
? APIs.GET({ fileId: logoId , size: "300"})
|
||||
: APIs.GET({ fileId: data.pinId, size: "300" })
|
||||
}
|
||||
alt="Logo"
|
||||
style={{
|
||||
|
||||
@@ -96,8 +96,8 @@ export default function Portofolio_UiMapNew({ mapboxToken }: { mapboxToken: stri
|
||||
<Avatar
|
||||
src={
|
||||
dataPorto?.pinId === null
|
||||
? APIs.GET({ fileId: String(dataPorto?.logoId) })
|
||||
: APIs.GET({ fileId: String(dataPorto?.pinId) })
|
||||
? APIs.GET({ fileId: String(dataPorto?.logoId), size: "300" })
|
||||
: APIs.GET({ fileId: String(dataPorto?.pinId), size: "300" })
|
||||
}
|
||||
alt="Logo"
|
||||
style={{
|
||||
|
||||
@@ -26,6 +26,7 @@ import { IconAt, IconCamera, IconUpload } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { gmailRegex } from "../../component/regular_expressions";
|
||||
import { Profile_ComponentCreateNewProfile } from "../_component";
|
||||
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
|
||||
|
||||
export default function CreateProfile() {
|
||||
const [filePP, setFilePP] = useState<File | null>(null);
|
||||
@@ -88,7 +89,7 @@ export default function CreateProfile() {
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
"Ukuran file terlalu besar. Maksimal 2 MB."
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
} else {
|
||||
setImgPP(buffer);
|
||||
@@ -150,7 +151,7 @@ export default function CreateProfile() {
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
"Ukuran file terlalu besar. Maksimal 2 MB."
|
||||
PemberitahuanMaksimalFile
|
||||
);
|
||||
} else {
|
||||
setImgBG(buffer);
|
||||
|
||||
Reference in New Issue
Block a user