Fix file image

Deskripsi:
- Ukuran file yang di ambil dari server wibu di batasi menjadi maksimal hanya 500kb
This commit is contained in:
2024-12-12 00:49:10 +08:00
parent 01c0e87cd0
commit 9046316b9e
24 changed files with 84 additions and 89 deletions

View File

@@ -4,6 +4,7 @@ import { Button, FileButton } from "@mantine/core";
import { IconCamera } from "@tabler/icons-react";
import { MainColor } from "../color";
import { MAX_SIZE } from "../lib";
import { PemberitahuanMaksimalFile } from "../lib/max_size";
import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
export function ComponentGlobal_ButtonUploadFileImage({
@@ -22,9 +23,7 @@ export function ComponentGlobal_ButtonUploadFileImage({
);
if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan(
"Ukuran file terlalu besar. Maksimal 2 MB."
);
ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
} else {
onSetFile(files);
onSetImage(buffer);

View File

@@ -17,7 +17,7 @@ export function ComponentGlobal_LoaderAvatar({
}) {
const [isImage, setIsImage] = useState<boolean | null>(null);
const url = APIs.GET({ fileId: fileId, size: imageSize });
const url = APIs.GET({ fileId: fileId, size: imageSize ? imageSize : "400" });
useShallowEffect(() => {
onLoadImage();

View File

@@ -24,7 +24,7 @@ export function ComponentGlobal_LoadImage({
const [isImage, setIsImage] = useState<boolean | null>(null);
const [isLoading, setIsLoading] = useState(false);
const url = APIs.GET({ fileId: fileId });
const url = APIs.GET({ fileId: fileId, size: "500" });
useShallowEffect(() => {
onLoadImage();

View File

@@ -15,7 +15,7 @@ export function ComponentGlobal_LoadImageCustom({
height: number;
}) {
const [isImage, setIsImage] = useState<boolean | null>(null);
const url = APIs.GET({ fileId: fileId });
const url = APIs.GET({ fileId: fileId, size: "500" });
useShallowEffect(() => {
onLoadImage();

View File

@@ -16,7 +16,7 @@ export function ComponentGlobal_LoadImageLandscape({
const router = useRouter();
const [isImage, setIsImage] = useState<boolean | null>(null);
const [isLoading, setLoading] = useState(false);
const url = APIs.GET({ fileId: fileId });
const url = APIs.GET({ fileId: fileId, size: "500" });
useShallowEffect(() => {
onLoadImage();

View File

@@ -22,7 +22,7 @@ export function ComponentGlobal_NotUserLoadImage({
const [isImage, setIsImage] = useState<boolean | null>(null);
const [isLoading, setIsLoading] = useState(false);
const url = APIs.GET({ fileId: fileId });
const url = APIs.GET({ fileId: fileId , size: "500" });
useShallowEffect(() => {
onLoadImage();

View File

@@ -1,2 +1,3 @@
// Maksimal ukuran file dalam byte (2 MB)
export const MAX_SIZE = 2 * 1024 * 1024; // 2 MB
// Maksimal ukuran file dalam byte (3 MB)
export const MAX_SIZE = 3 * 1024 * 1024; // 3 MB
export const PemberitahuanMaksimalFile = "Ukuran file terlalu besar. Maksimal 3 MB.";

View File

@@ -23,7 +23,7 @@ export function UIGlobal_NotUserImagePreview({ fileId }: { fileId: string }) {
const router = useRouter();
const [isImage, setIsImage] = useState<boolean | null>(null);
const url = APIs.GET({ fileId: fileId });
const url = APIs.GET({ fileId: fileId, size: "500" });
useShallowEffect(() => {
onLoadImage();