Fix file image
Deskripsi: - Ukuran file yang di ambil dari server wibu di batasi menjadi maksimal hanya 500kb
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.";
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user