Merge pull request #187 from bipproduction/join

Fix ukuran file
This commit is contained in:
Bagasbanuna02
2024-12-12 00:53:47 +08:00
committed by GitHub
26 changed files with 85 additions and 90 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

View File

@@ -4,7 +4,7 @@ export default async function Page({ params }: { params: { id: string } }) {
let portofolioId = params.id; let portofolioId = params.id;
return ( return (
<> <>
<Map_CreateNewPin portofolioId={portofolioId}/> <Map_CreateNewPin portofolioId={portofolioId} />
</> </>
); );
} }

View File

@@ -1,11 +1,13 @@
import { UploadFotoProfile } from "@/app_modules/katalog/profile"; import { UploadFotoProfile } from "@/app_modules/katalog/profile";
import { Profile_getOneById } from "@/app_modules/katalog/profile/fun/get/get_one_profile"; import { Profile_getOneById } from "@/app_modules/katalog/profile/fun/get/get_one_profile";
export default async function Page({params}: {params: {id: string}}) { export default async function Page({ params }: { params: { id: string } }) {
let profileId = params.id let profileId = params.id;
const dataProfile = await Profile_getOneById(profileId) const dataProfile = await Profile_getOneById(profileId);
return <> return (
<UploadFotoProfile dataProfile={dataProfile as any}/> <>
<UploadFotoProfile dataProfile={dataProfile as any} />
</> </>
} );
}

View File

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

View File

@@ -17,7 +17,7 @@ export function ComponentGlobal_LoaderAvatar({
}) { }) {
const [isImage, setIsImage] = useState<boolean | null>(null); 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(() => { useShallowEffect(() => {
onLoadImage(); onLoadImage();

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,2 +1,3 @@
// Maksimal ukuran file dalam byte (2 MB) // Maksimal ukuran file dalam byte (3 MB)
export const MAX_SIZE = 2 * 1024 * 1024; // 2 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 router = useRouter();
const [isImage, setIsImage] = useState<boolean | null>(null); const [isImage, setIsImage] = useState<boolean | null>(null);
const url = APIs.GET({ fileId: fileId }); const url = APIs.GET({ fileId: fileId, size: "500" });
useShallowEffect(() => { useShallowEffect(() => {
onLoadImage(); onLoadImage();

View File

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

View File

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

View File

@@ -88,8 +88,8 @@ export function UiAdminMap_MapBoxView({
}} }}
src={ src={
e.pinId === null e.pinId === null
? APIs.GET({ fileId: e.Portofolio.logoId }) ? APIs.GET({ fileId: e.Portofolio.logoId, size: "300" })
: APIs.GET({ fileId: e.pinId }) : APIs.GET({ fileId: e.pinId, size: "300" })
} }
/> />
</Stack> </Stack>

View File

@@ -32,7 +32,7 @@ export default function MainCrowd() {
</AspectRatio> */} </AspectRatio> */}
<Image <Image
alt="Logo" alt="Logo"
src={"/aset/investasi/logo-crowd-panjang.png"} src={"/aset/investasi/logo-crowd-panjang-new.png"}
mah={"100%"} mah={"100%"}
styles={{ styles={{
image: { image: {

View File

@@ -22,6 +22,9 @@ import { IconCamera } from "@tabler/icons-react";
import _ from "lodash"; import _ from "lodash";
import { useState } from "react"; import { useState } from "react";
import { Portofolio_ComponentButtonSelanjutnya } from "../component"; 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({ export default function CreatePortofolio({
bidangBisnis, bidangBisnis,
@@ -184,8 +187,16 @@ export default function CreatePortofolio({
const buffer = URL.createObjectURL( const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())]) new Blob([new Uint8Array(await files.arrayBuffer())])
); );
setImg(buffer); if (files.size > MAX_SIZE) {
setFile(files); setImg(null);
setFile(null);
ComponentGlobal_NotifikasiPeringatan(
PemberitahuanMaksimalFile
);
} else {
setImg(buffer);
setFile(files);
}
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@@ -11,6 +11,9 @@ import { IconCamera } from "@tabler/icons-react";
import { useState } from "react"; import { useState } from "react";
import { MODEL_PORTOFOLIO } from "../../model/interface"; import { MODEL_PORTOFOLIO } from "../../model/interface";
import { ComponentPortofolio_ButtonEditLogoBisnis } from "../../component"; 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({ export default function Portofolio_EditLogoBisnis({
dataPorto, dataPorto,
@@ -47,8 +50,15 @@ export default function Portofolio_EditLogoBisnis({
const buffer = URL.createObjectURL( const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())]) 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) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@@ -102,8 +102,8 @@ function MapView({
<Avatar <Avatar
src={ src={
data.pinId === null data.pinId === null
? APIs.GET({ fileId: logoId }) ? APIs.GET({ fileId: logoId , size: "300"})
: APIs.GET({ fileId: data.pinId }) : APIs.GET({ fileId: data.pinId, size: "300" })
} }
alt="Logo" alt="Logo"
style={{ style={{

View File

@@ -96,8 +96,8 @@ export default function Portofolio_UiMapNew({ mapboxToken }: { mapboxToken: stri
<Avatar <Avatar
src={ src={
dataPorto?.pinId === null dataPorto?.pinId === null
? APIs.GET({ fileId: String(dataPorto?.logoId) }) ? APIs.GET({ fileId: String(dataPorto?.logoId), size: "300" })
: APIs.GET({ fileId: String(dataPorto?.pinId) }) : APIs.GET({ fileId: String(dataPorto?.pinId), size: "300" })
} }
alt="Logo" alt="Logo"
style={{ style={{

View File

@@ -26,6 +26,7 @@ import { IconAt, IconCamera, IconUpload } from "@tabler/icons-react";
import { useState } from "react"; import { useState } from "react";
import { gmailRegex } from "../../component/regular_expressions"; import { gmailRegex } from "../../component/regular_expressions";
import { Profile_ComponentCreateNewProfile } from "../_component"; import { Profile_ComponentCreateNewProfile } from "../_component";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
export default function CreateProfile() { export default function CreateProfile() {
const [filePP, setFilePP] = useState<File | null>(null); const [filePP, setFilePP] = useState<File | null>(null);
@@ -88,7 +89,7 @@ export default function CreateProfile() {
if (files.size > MAX_SIZE) { if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan( ComponentGlobal_NotifikasiPeringatan(
"Ukuran file terlalu besar. Maksimal 2 MB." PemberitahuanMaksimalFile
); );
} else { } else {
setImgPP(buffer); setImgPP(buffer);
@@ -150,7 +151,7 @@ export default function CreateProfile() {
if (files.size > MAX_SIZE) { if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan( ComponentGlobal_NotifikasiPeringatan(
"Ukuran file terlalu besar. Maksimal 2 MB." PemberitahuanMaksimalFile
); );
} else { } else {
setImgBG(buffer); setImgBG(buffer);

View File

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

View File

@@ -16,7 +16,7 @@ import {
Stack, Stack,
Text, Text,
TextInput, TextInput,
Title Title,
} from "@mantine/core"; } from "@mantine/core";
import { IconCamera } from "@tabler/icons-react"; import { IconCamera } from "@tabler/icons-react";
import _ from "lodash"; import _ from "lodash";
@@ -29,6 +29,8 @@ import Map, {
} from "react-map-gl"; } from "react-map-gl";
import { ComponentMap_ButtonSavePin } from "../_component"; import { ComponentMap_ButtonSavePin } from "../_component";
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long"; import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
export function UiMap_CreatePin({ export function UiMap_CreatePin({
mapboxToken, mapboxToken,
@@ -141,9 +143,12 @@ export function UiMap_CreatePin({
const buffer = URL.createObjectURL( const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())]) new Blob([new Uint8Array(await files.arrayBuffer())])
); );
if (files.size > 2000000) {
if (files.size > MAX_SIZE) {
setImg(null);
setFile(null);
ComponentGlobal_NotifikasiPeringatan( ComponentGlobal_NotifikasiPeringatan(
"Maaf, Ukuran file terlalu besar, maximum 2mb", PemberitahuanMaksimalFile,
3000 3000
); );
} else { } else {

View File

@@ -27,6 +27,8 @@ import { defaultMapZoom } from "../lib/default_lat_long";
import { MODEL_MAP } from "../lib/interface"; import { MODEL_MAP } from "../lib/interface";
import { APIs, DIRECTORY_ID } from "@/app/lib"; import { APIs, DIRECTORY_ID } from "@/app/lib";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
export function UiMap_CustomPin({ export function UiMap_CustomPin({
dataMap, dataMap,
@@ -72,8 +74,8 @@ export function UiMap_CustomPin({
radius={"100%"} radius={"100%"}
src={ src={
data.pinId === null data.pinId === null
? APIs.GET({ fileId: data.Portofolio.logoId }) ? APIs.GET({ fileId: data.Portofolio.logoId, size: "300" })
: APIs.GET({ fileId: data.pinId }) : APIs.GET({ fileId: data.pinId, size: "300" })
} }
style={{ style={{
border: `2px solid ${AccentColor.skyblue}`, border: `2px solid ${AccentColor.skyblue}`,
@@ -90,9 +92,9 @@ export function UiMap_CustomPin({
const buffer = URL.createObjectURL( const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())]) new Blob([new Uint8Array(await files.arrayBuffer())])
); );
if (files.size > 2000000) { if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan( ComponentGlobal_NotifikasiPeringatan(
"Maaf, Ukuran file terlalu besar, maximum 2mb", PemberitahuanMaksimalFile,
3000 3000
); );
} else { } else {
@@ -155,8 +157,8 @@ export function UiMap_CustomPin({
imgPin imgPin
? imgPin ? imgPin
: data.pinId === null : data.pinId === null
? APIs.GET({ fileId: data.Portofolio.logoId }) ? APIs.GET({ fileId: data.Portofolio.logoId, size: "300" })
: APIs.GET({ fileId: data.pinId }) : APIs.GET({ fileId: data.pinId, size: "300" })
} }
style={{ style={{
border: `2px solid ${AccentColor.softblue}`, border: `2px solid ${AccentColor.softblue}`,

View File

@@ -33,6 +33,8 @@ import Map, {
import { ComponentMap_ButtonUpdateDataMap } from "../_component"; import { ComponentMap_ButtonUpdateDataMap } from "../_component";
import { defaultMapZoom } from "../lib/default_lat_long"; import { defaultMapZoom } from "../lib/default_lat_long";
import { MODEL_MAP } from "../lib/interface"; import { MODEL_MAP } from "../lib/interface";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
export function UiMap_EditMap({ export function UiMap_EditMap({
mapboxToken, mapboxToken,
@@ -85,8 +87,8 @@ export function UiMap_EditMap({
<Avatar <Avatar
src={ src={
data.pinId === null data.pinId === null
? APIs.GET({ fileId: dataMap.Portofolio.logoId }) ? APIs.GET({ fileId: dataMap.Portofolio.logoId, size: "400" })
: APIs.GET({ fileId: data.pinId }) : APIs.GET({ fileId: data.pinId, size: "400" })
} }
alt="Logo" alt="Logo"
style={{ style={{
@@ -141,44 +143,6 @@ export function UiMap_EditMap({
)} )}
</ComponentGlobal_BoxUploadImage> </ComponentGlobal_BoxUploadImage>
{/* {img ? (
<AspectRatio ratio={1 / 1} mah={300}>
<Paper
style={{
border: `2px solid ${AccentColor.blue}`,
backgroundColor: AccentColor.darkblue,
padding: "10px",
borderRadius: "10px",
}}
>
<Image
radius={"sm"}
alt="Photo"
src={img ? img : "/aset/no-img.png"}
maw={250}
/>
</Paper>
</AspectRatio>
) : (
<AspectRatio ratio={1 / 1} mah={300}>
<Paper
style={{
border: `2px solid ${AccentColor.blue}`,
backgroundColor: AccentColor.darkblue,
padding: "10px",
borderRadius: "10px",
}}
>
<Image
radius={"sm"}
alt="Photo"
src={RouterMap.api_foto + data.imageId}
maw={250}
/>
</Paper>
</AspectRatio>
)} */}
<Center> <Center>
<FileButton <FileButton
onChange={async (files: any | null) => { onChange={async (files: any | null) => {
@@ -186,9 +150,9 @@ export function UiMap_EditMap({
const buffer = URL.createObjectURL( const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())]) new Blob([new Uint8Array(await files.arrayBuffer())])
); );
if (files.size > 2000000) { if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan( ComponentGlobal_NotifikasiPeringatan(
"Maaf, Ukuran file terlalu besar, maximum 2mb", PemberitahuanMaksimalFile,
3000 3000
); );
} else { } else {

View File

@@ -91,8 +91,8 @@ export function UiMap_MapBoxView({
}} }}
src={ src={
e.pinId === null e.pinId === null
? APIs.GET({ fileId: e.Portofolio.logoId }) ? APIs.GET({ fileId: e.Portofolio.logoId, size: "300" })
: APIs.GET({ fileId: e.pinId }) : APIs.GET({ fileId: e.pinId, size: "300" })
} }
/> />
</Stack> </Stack>
@@ -110,7 +110,7 @@ export function UiMap_MapBoxView({
opened={openDrawer} opened={openDrawer}
close={() => setOpenDrawer(false)} close={() => setOpenDrawer(false)}
mapId={mapId} mapId={mapId}
component={<ComponentMap_DetailData mapId={mapId} />} component={<ComponentMap_DetailData mapId={mapId} />}
/> />
</> </>
); );

View File

@@ -94,8 +94,8 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) {
}} }}
src={ src={
e.pinId === null e.pinId === null
? APIs.GET({ fileId: e.logoId }) ? APIs.GET({ fileId: e.logoId, size: "300" })
: APIs.GET({ fileId: e.pinId }) : APIs.GET({ fileId: e.pinId, size: "300" })
} }
/> />
</Stack> </Stack>