Compare commits
7 Commits
api/25-aug
...
api-portof
| Author | SHA1 | Date | |
|---|---|---|---|
| 41a4a94255 | |||
| 88527d5bb6 | |||
| 40441c929f | |||
| d3c4f04e07 | |||
| 4fc2c90702 | |||
| 2227aaa99f | |||
| 7cddc7abe3 |
@@ -1,9 +1,33 @@
|
||||
import { LandscapeFrameUploaded, ViewWrapper } from "@/components";
|
||||
import { CenterCustom, TextCustom, ViewWrapper } from "@/components";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import { Image } from "expo-image";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import React, { useState } from "react";
|
||||
|
||||
export default function PreviewImage() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
return (
|
||||
<ViewWrapper>
|
||||
<LandscapeFrameUploaded />
|
||||
{id ? (
|
||||
<Image
|
||||
onLoad={() => {
|
||||
setIsLoading(false);
|
||||
}}
|
||||
source={
|
||||
isLoading
|
||||
? require("@/assets/images/loading.gif")
|
||||
: API_STRORAGE.GET({ fileId: id as string })
|
||||
}
|
||||
contentFit="contain"
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
/>
|
||||
) : (
|
||||
<CenterCustom>
|
||||
<TextCustom>File not found</TextCustom>
|
||||
</CenterCustom>
|
||||
)}
|
||||
</ViewWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Spacing,
|
||||
StackCustom,
|
||||
TextCustom,
|
||||
ViewWrapper
|
||||
ViewWrapper,
|
||||
} from "@/components";
|
||||
import { IconEdit } from "@/components/_Icon";
|
||||
import Collaboration_BoxDetailSection from "@/screens/Collaboration/BoxDetailSection";
|
||||
|
||||
@@ -22,6 +22,7 @@ export default function Application() {
|
||||
|
||||
async function onLoadData() {
|
||||
const response = await apiUser(user?.id as string);
|
||||
console.log("User >>", JSON.stringify(response.data, null, 2));
|
||||
setData(response.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import {
|
||||
BoxButtonOnFooter,
|
||||
AvatarComp,
|
||||
BaseBox,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
Grid,
|
||||
CenterCustom,
|
||||
InformationBox,
|
||||
LandscapeFrameUploaded,
|
||||
SelectCustom,
|
||||
Spacing,
|
||||
StackCustom,
|
||||
@@ -14,48 +14,106 @@ import {
|
||||
ViewWrapper,
|
||||
} from "@/components";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import dummyMasterBidangBisnis from "@/lib/dummy-data/master-bidang-bisnis";
|
||||
import dummyMasterSubBidangBisnis from "@/lib/dummy-data/master-sub-bidang-bisnis";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Text, TouchableOpacity, View } from "react-native";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import Portofolio_ButtonCreate from "@/screens/Portofolio/ButtonCreatePortofolio";
|
||||
import {
|
||||
apiMasterBidangBisnis,
|
||||
apiMasterSubBidangBisnis,
|
||||
} from "@/service/api-client/api-master";
|
||||
import {
|
||||
IMasterBidangBisnis,
|
||||
IMasterSubBidangBisnis,
|
||||
} from "@/types/Type-Master";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
import { Image } from "expo-image";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import PhoneInput, { ICountry } from "react-native-international-phone-number";
|
||||
import { Avatar } from "react-native-paper";
|
||||
|
||||
export default function PortofolioCreate() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
|
||||
const [inputValue, setInputValue] = useState<string>("");
|
||||
const [data, setData] = useState({
|
||||
name: "",
|
||||
bidang_usaha: "",
|
||||
sub_bidang_usaha: "",
|
||||
alamat: "",
|
||||
nomor_telepon: "",
|
||||
namaBisnis: "",
|
||||
masterBidangBisnisId: "",
|
||||
// sub_bidang_usaha: "",
|
||||
alamatKantor: "",
|
||||
tlpn: "",
|
||||
deskripsi: "",
|
||||
});
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
|
||||
const [bidangBisnis, setBidangBisnis] = useState<IMasterBidangBisnis[]>([]);
|
||||
const [selectBidangId, setSelectBidangId] = useState<string>("");
|
||||
const [subBidangBisnis, setSubBidangBisnis] = useState<
|
||||
IMasterSubBidangBisnis[]
|
||||
>([]);
|
||||
|
||||
// const [subBidangSelected, setSubBidangSelected] = useState<string[]>([]);
|
||||
const [listSubBidangSelected, setListSubBidangSelected] = useState([
|
||||
{
|
||||
id: "",
|
||||
},
|
||||
]);
|
||||
|
||||
const [dataMedsos, setDataMedsos] = useState({
|
||||
facebook: "",
|
||||
twitter: "",
|
||||
instagram: "",
|
||||
youtube: "",
|
||||
tiktok: "",
|
||||
});
|
||||
|
||||
function handleInputValue(phoneNumber: string) {
|
||||
setInputValue(phoneNumber);
|
||||
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
||||
const fixNumber = inputValue.replace(/\s+/g, "");
|
||||
const realNumber = callingCode + fixNumber;
|
||||
setData({ ...data, tlpn: realNumber });
|
||||
}
|
||||
|
||||
function handleSelectedCountry(country: ICountry) {
|
||||
setSelectedCountry(country);
|
||||
}
|
||||
|
||||
function handleSave() {
|
||||
console.log("Selanjutnya");
|
||||
router.replace(`/maps/create`);
|
||||
}
|
||||
useEffect(() => {
|
||||
onLoadMaster();
|
||||
}, []);
|
||||
|
||||
const buttonSave = (
|
||||
<BoxButtonOnFooter>
|
||||
<ButtonCustom onPress={handleSave}>Selanjutnya</ButtonCustom>
|
||||
</BoxButtonOnFooter>
|
||||
);
|
||||
const onLoadMaster = async () => {
|
||||
try {
|
||||
const response = await apiMasterBidangBisnis();
|
||||
setBidangBisnis(response.data);
|
||||
} catch (error) {
|
||||
setBidangBisnis([]);
|
||||
console.log("Error onLoadMasterBidangBisnis", error);
|
||||
}
|
||||
};
|
||||
|
||||
const onLoadMasterSubBidangBisnis = async ({ id }: { id: string }) => {
|
||||
try {
|
||||
const response = await apiMasterSubBidangBisnis({ id: id });
|
||||
setSubBidangBisnis(response.data);
|
||||
} catch (error) {
|
||||
console.log("Error onLoadMasterBidangBisnis", error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ViewWrapper footerComponent={buttonSave}>
|
||||
<ViewWrapper
|
||||
footerComponent={
|
||||
<Portofolio_ButtonCreate
|
||||
id={id as string}
|
||||
data={data}
|
||||
dataMedsos={dataMedsos}
|
||||
imageUri={imageUri}
|
||||
subBidangSelected={listSubBidangSelected}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{/* <TextCustom>Portofolio Create {id}</TextCustom> */}
|
||||
<StackCustom gap={"xs"}>
|
||||
<InformationBox text="Lengkapi data bisnis anda." />
|
||||
@@ -63,51 +121,66 @@ export default function PortofolioCreate() {
|
||||
required
|
||||
label="Nama Bisnis"
|
||||
placeholder="Masukkan nama bisnis"
|
||||
|
||||
onChangeText={(value: any) => setData({ ...data, namaBisnis: value })}
|
||||
/>
|
||||
|
||||
<SelectCustom
|
||||
label="Bidang Usaha"
|
||||
required
|
||||
data={dummyMasterBidangBisnis.map((item) => ({
|
||||
data={bidangBisnis.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))}
|
||||
value={data.bidang_usaha}
|
||||
value={data.masterBidangBisnisId}
|
||||
onChange={(value) => {
|
||||
setData({ ...(data as any), bidang_usaha: value });
|
||||
setData({ ...(data as any), masterBidangBisnisId: value });
|
||||
setSelectBidangId(id as string);
|
||||
onLoadMasterSubBidangBisnis({ id: value as string });
|
||||
}}
|
||||
/>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={10}>
|
||||
<SelectCustom
|
||||
// disabled
|
||||
label="Sub Bidang Usaha"
|
||||
required
|
||||
data={dummyMasterSubBidangBisnis.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))}
|
||||
value={data.sub_bidang_usaha}
|
||||
onChange={(value) => {
|
||||
setData({ ...(data as any), sub_bidang_usaha: value });
|
||||
}}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col
|
||||
span={2}
|
||||
style={{ alignItems: "center", justifyContent: "center" }}
|
||||
>
|
||||
<TouchableOpacity onPress={() => console.log("delete")}>
|
||||
<Ionicons name="trash" size={24} color={MainColor.red} />
|
||||
</TouchableOpacity>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
{/* {listSubBidangSelected.map((item, index) => (
|
||||
<Grid key={index}>
|
||||
<Grid.Col span={10}>
|
||||
<SelectCustom
|
||||
disabled={selectBidangId === ""}
|
||||
label="Sub Bidang Usaha"
|
||||
required
|
||||
data={subBidangBisnis.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))}
|
||||
value={data.sub_bidang_usaha}
|
||||
onChange={(value) => {
|
||||
setData({ ...(data as any), sub_bidang_usaha: value });
|
||||
setListSubBidangSelected([
|
||||
...listSubBidangSelected,
|
||||
{ id: value as string },
|
||||
]);
|
||||
}}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col
|
||||
span={2}
|
||||
style={{ alignItems: "center", justifyContent: "center" }}
|
||||
>
|
||||
<TouchableOpacity onPress={() => console.log("delete")}>
|
||||
<Ionicons name="trash" size={24} color={MainColor.red} />
|
||||
</TouchableOpacity>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<ButtonCenteredOnly onPress={() => console.log("add")}>
|
||||
<ButtonCenteredOnly
|
||||
onPress={() => {
|
||||
setListSubBidangSelected([...listSubBidangSelected, { id: "" }]);
|
||||
}}
|
||||
>
|
||||
Tambah Pilihan
|
||||
</ButtonCenteredOnly>
|
||||
<Spacing />
|
||||
<Spacing /> */}
|
||||
|
||||
{/* <TextCustom>{JSON.stringify(bidangBisnis, null, 2)}</TextCustom> */}
|
||||
|
||||
<View>
|
||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||
@@ -132,6 +205,9 @@ export default function PortofolioCreate() {
|
||||
required
|
||||
label="Alamat Bisnis"
|
||||
placeholder="Masukkan alamat bisnis"
|
||||
onChangeText={(value: any) =>
|
||||
setData({ ...data, alamatKantor: value })
|
||||
}
|
||||
/>
|
||||
|
||||
<TextAreaCustom
|
||||
@@ -150,12 +226,20 @@ export default function PortofolioCreate() {
|
||||
|
||||
{/* Logo */}
|
||||
<InformationBox text="Upload logo bisnis anda untuk di tampilaka pada portofolio." />
|
||||
<LandscapeFrameUploaded />
|
||||
|
||||
<CenterCustom>
|
||||
<Avatar.Image
|
||||
source={imageUri ? { uri: imageUri } : DUMMY_IMAGE.dummy_image}
|
||||
size={200}
|
||||
/>
|
||||
</CenterCustom>
|
||||
<Spacing />
|
||||
<ButtonCenteredOnly
|
||||
icon="upload"
|
||||
onPress={() => {
|
||||
console.log("Upload logo >>", id);
|
||||
router.navigate(`/(application)/(image)/take-picture/${id}`);
|
||||
pickImage({
|
||||
setImageUri,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Upload
|
||||
@@ -167,22 +251,37 @@ export default function PortofolioCreate() {
|
||||
<TextInputCustom
|
||||
label="Tiktok"
|
||||
placeholder="Masukkan username tiktok"
|
||||
onChangeText={(value: any) =>
|
||||
setDataMedsos({ ...dataMedsos, tiktok: value })
|
||||
}
|
||||
/>
|
||||
<TextInputCustom
|
||||
label="Facebook"
|
||||
placeholder="Masukkan username facebook"
|
||||
onChangeText={(value: any) =>
|
||||
setDataMedsos({ ...dataMedsos, facebook: value })
|
||||
}
|
||||
/>
|
||||
<TextInputCustom
|
||||
label="Instagram"
|
||||
placeholder="Masukkan username instagram"
|
||||
onChangeText={(value: any) =>
|
||||
setDataMedsos({ ...dataMedsos, instagram: value })
|
||||
}
|
||||
/>
|
||||
<TextInputCustom
|
||||
label="Twitter"
|
||||
placeholder="Masukkan username twitter"
|
||||
onChangeText={(value: any) =>
|
||||
setDataMedsos({ ...dataMedsos, twitter: value })
|
||||
}
|
||||
/>
|
||||
<TextInputCustom
|
||||
label="Youtube"
|
||||
placeholder="Masukkan username youtube"
|
||||
onChangeText={(value: any) =>
|
||||
setDataMedsos({ ...dataMedsos, youtube: value })
|
||||
}
|
||||
/>
|
||||
<Spacing />
|
||||
</StackCustom>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
BoxButtonOnFooter,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
Grid,
|
||||
SelectCustom,
|
||||
Spacing,
|
||||
StackCustom,
|
||||
TextAreaCustom,
|
||||
TextCustom,
|
||||
TextInputCustom,
|
||||
ViewWrapper,
|
||||
BoxButtonOnFooter,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
Grid,
|
||||
SelectCustom,
|
||||
Spacing,
|
||||
StackCustom,
|
||||
TextAreaCustom,
|
||||
TextCustom,
|
||||
TextInputCustom,
|
||||
ViewWrapper,
|
||||
} from "@/components";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import dummyMasterBidangBisnis from "@/lib/dummy-data/master-bidang-bisnis";
|
||||
@@ -26,7 +26,7 @@ export default function PortofolioEdit() {
|
||||
const [inputValue, setInputValue] = useState<string>("");
|
||||
|
||||
const [data, setData] = useState({
|
||||
name: "",
|
||||
namaBisnis: "",
|
||||
bidang_usaha: "",
|
||||
sub_bidang_usaha: "",
|
||||
alamat: "",
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
import { AlertCustom, DrawerCustom } from "@/components";
|
||||
import { AlertCustom, DrawerCustom, Spacing, StackCustom } from "@/components";
|
||||
import LeftButtonCustom from "@/components/Button/BackButton";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import Portofolio_BusinessLocation from "@/screens/Portofolio/BusinessLocationSection";
|
||||
import Portofolio_ButtonDelete from "@/screens/Portofolio/ButtonDelete";
|
||||
import Portofolio_Data from "@/screens/Portofolio/DataPortofolio";
|
||||
import { drawerItemsPortofolio } from "@/screens/Portofolio/ListPage";
|
||||
import Portofolio_MenuDrawerSection from "@/screens/Portofolio/MenuDrawer";
|
||||
import PorfofolioSection from "@/screens/Portofolio/PorfofolioSection";
|
||||
import Portofolio_SocialMediaSection from "@/screens/Portofolio/SocialMediaSection";
|
||||
import { apiGetOnePortofolio } from "@/service/api-client/api-portofolio";
|
||||
import { GStyles } from "@/styles/global-styles";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Stack, useLocalSearchParams, router } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
router,
|
||||
Stack,
|
||||
useFocusEffect,
|
||||
useLocalSearchParams,
|
||||
} from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
import { TouchableOpacity } from "react-native";
|
||||
|
||||
export default function Portofolio() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const { user } = useAuth();
|
||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [data, setData] = useState<any>();
|
||||
|
||||
const openDrawer = () => {
|
||||
setIsDrawerOpen(true);
|
||||
@@ -22,28 +34,54 @@ export default function Portofolio() {
|
||||
const closeDrawer = () => {
|
||||
setIsDrawerOpen(false);
|
||||
};
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadData(id as string);
|
||||
}, [id])
|
||||
);
|
||||
|
||||
async function onLoadData(id: string) {
|
||||
const response = await apiGetOnePortofolio({ id: id });
|
||||
|
||||
setData(response.data);
|
||||
}
|
||||
|
||||
const userId = user?.id;
|
||||
const userLoginId = data?.Profile?.User?.id;
|
||||
|
||||
console.log("User ID >>", userId);
|
||||
console.log("User Login ID >>", userLoginId);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Header */}
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Portofolio",
|
||||
headerLeft: () => <LeftButtonCustom />,
|
||||
headerRight: () => (
|
||||
<TouchableOpacity onPress={openDrawer}>
|
||||
<Ionicons
|
||||
name="ellipsis-vertical"
|
||||
size={20}
|
||||
color={MainColor.yellow}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
headerStyle: GStyles.headerStyle,
|
||||
headerTitleStyle: GStyles.headerTitleStyle,
|
||||
}}
|
||||
/>
|
||||
<ViewWrapper>
|
||||
{/* Header */}
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Portofolio",
|
||||
headerLeft: () => <LeftButtonCustom />,
|
||||
headerRight: () => (
|
||||
<TouchableOpacity onPress={openDrawer}>
|
||||
<Ionicons
|
||||
name="ellipsis-vertical"
|
||||
size={20}
|
||||
color={MainColor.yellow}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
headerStyle: GStyles.headerStyle,
|
||||
headerTitleStyle: GStyles.headerTitleStyle,
|
||||
}}
|
||||
/>
|
||||
<PorfofolioSection setShowDeleteAlert={setDeleteAlert} />
|
||||
{/* <PorfofolioSection setShowDeleteAlert={setDeleteAlert} data={data} /> */}
|
||||
<StackCustom>
|
||||
<Portofolio_Data data={data} />
|
||||
<Portofolio_BusinessLocation />
|
||||
<Portofolio_SocialMediaSection data={data?.Portofolio_MediaSosial} />
|
||||
<Portofolio_ButtonDelete setShowDeleteAlert={setDeleteAlert} />
|
||||
<Spacing />
|
||||
</StackCustom>
|
||||
</ViewWrapper>
|
||||
|
||||
{/* Drawer Komponen Eksternal */}
|
||||
|
||||
@@ -1,47 +1,28 @@
|
||||
import { BaseBox, Grid, TextCustom, ViewWrapper } from "@/components";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { TextCustom, ViewWrapper } from "@/components";
|
||||
import Portofolio_BoxView from "@/screens/Portofolio/BoxPortofolioView";
|
||||
import { apiGetPortofolio } from "@/service/api-client/api-portofolio";
|
||||
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
export default function ListPortofolio() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [data, setData] = useState<any[]>([]);
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadPortofolio(id as string);
|
||||
}, [id])
|
||||
);
|
||||
|
||||
const onLoadPortofolio = async (id: string) => {
|
||||
const response = await apiGetPortofolio({ id: id });
|
||||
setData(response.data);
|
||||
};
|
||||
return (
|
||||
<ViewWrapper>
|
||||
{Array.from({ length: 10 }).map((_, index) => (
|
||||
<BaseBox
|
||||
key={index}
|
||||
style={{ backgroundColor: MainColor.darkblue }}
|
||||
onPress={() => {
|
||||
console.log("press to Portofolio");
|
||||
router.push(`/portofolio/${id}`);
|
||||
}}
|
||||
>
|
||||
<Grid>
|
||||
<Grid.Col
|
||||
span={10}
|
||||
style={{ justifyContent: "center", backgroundColor: "" }}
|
||||
>
|
||||
<TextCustom bold size="large" truncate={1}>
|
||||
Nama usaha portofolio
|
||||
</TextCustom>
|
||||
<TextCustom size="small" color="yellow">
|
||||
#id-porofolio12345
|
||||
</TextCustom>
|
||||
</Grid.Col>
|
||||
<Grid.Col
|
||||
span={2}
|
||||
style={{ alignItems: "flex-end", justifyContent: "center" }}
|
||||
>
|
||||
<Ionicons
|
||||
name="caret-forward"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</BaseBox>
|
||||
))}
|
||||
{data ? data?.map((item: any, index: number) => (
|
||||
<Portofolio_BoxView key={index} data={item} />
|
||||
)) : <TextCustom>Tidak ada portofolio</TextCustom>}
|
||||
</ViewWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ export default function ProfileEdit() {
|
||||
const handleUpdate = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await apiUpdateProfile({ id: id as string, data });
|
||||
const response = await apiUpdateProfile({
|
||||
id: id as string,
|
||||
data,
|
||||
category: "profile",
|
||||
});
|
||||
if (!response.success) {
|
||||
Toast.show({
|
||||
type: "info",
|
||||
@@ -50,6 +54,8 @@ export default function ProfileEdit() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Sukses",
|
||||
|
||||
@@ -5,16 +5,14 @@ import { MainColor } from "@/constants/color-palet";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { drawerItemsProfile } from "@/screens/Profile/ListPage";
|
||||
import Profile_MenuDrawerSection from "@/screens/Profile/menuDrawerSection";
|
||||
import Profile_PortofolioSection from "@/screens/Profile/PortofolioSection";
|
||||
import ProfileSection from "@/screens/Profile/ProfileSection";
|
||||
import { apiGetPortofolio } from "@/service/api-client/api-portofolio";
|
||||
import { apiProfile } from "@/service/api-client/api-profile";
|
||||
import { GStyles } from "@/styles/global-styles";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
Stack,
|
||||
useFocusEffect,
|
||||
useLocalSearchParams
|
||||
} from "expo-router";
|
||||
import { Stack, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { TouchableOpacity } from "react-native";
|
||||
|
||||
@@ -22,6 +20,7 @@ export default function Profile() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
||||
const [data, setData] = useState<IProfile>();
|
||||
const [dataPortofolio, setDataPortofolio] = useState<any[]>();
|
||||
|
||||
const { logout, isAdmin } = useAuth();
|
||||
|
||||
@@ -36,13 +35,25 @@ export default function Profile() {
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadData(id as string);
|
||||
onLoadPortofolio(id as string);
|
||||
}, [id])
|
||||
);
|
||||
|
||||
async function onLoadData(id: string) {
|
||||
const onLoadData = async (id: string) => {
|
||||
const response = await apiProfile({ id: id });
|
||||
setData(response.data);
|
||||
}
|
||||
};
|
||||
|
||||
const onLoadPortofolio = async (id: string) => {
|
||||
const response = await apiGetPortofolio({ id: id });
|
||||
const lastTwoByDate = response.data
|
||||
.sort(
|
||||
(a: any, b: any) =>
|
||||
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
||||
) // urut desc
|
||||
.slice(0, 2);
|
||||
setDataPortofolio(lastTwoByDate);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -63,9 +74,14 @@ export default function Profile() {
|
||||
headerTitleStyle: GStyles.headerTitleStyle,
|
||||
}}
|
||||
/>
|
||||
{/* Main View */}
|
||||
<ViewWrapper>
|
||||
{/* Header */}
|
||||
<ProfileSection data={data as any} />
|
||||
|
||||
<Profile_PortofolioSection
|
||||
data={dataPortofolio as any}
|
||||
profileId={id as string}
|
||||
/>
|
||||
</ViewWrapper>
|
||||
|
||||
{/* Drawer Komponen Eksternal */}
|
||||
|
||||
@@ -5,40 +5,132 @@ import {
|
||||
ButtonCustom,
|
||||
} from "@/components";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { apiProfile, apiUpdateProfile } from "@/service/api-client/api-profile";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Image } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export default function UpdateBackgroundProfile() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [data, setData] = useState<IProfile>();
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadData(id as string);
|
||||
}, [id])
|
||||
);
|
||||
|
||||
async function onLoadData(id: string) {
|
||||
try {
|
||||
const response = await apiProfile({ id });
|
||||
console.log(
|
||||
"response image id >>",
|
||||
JSON.stringify(response.data.backgroundId, null, 2)
|
||||
);
|
||||
setData(response.data);
|
||||
} catch (error) {
|
||||
console.log("error get profile >>", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onUpload() {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await uploadImageService({
|
||||
imageUri,
|
||||
dirId: DIRECTORY_ID.profile_background,
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
const fileId = response.data.id;
|
||||
const responseUpdate = await apiUpdateProfile({
|
||||
id: id as string,
|
||||
data: { fileId },
|
||||
category: "background",
|
||||
});
|
||||
|
||||
if (!responseUpdate.success) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Info",
|
||||
text2: responseUpdate.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Sukses",
|
||||
text2: "Background berhasil diupdate",
|
||||
});
|
||||
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: error as string,
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const buttonFooter = (
|
||||
<BoxButtonOnFooter>
|
||||
<ButtonCustom
|
||||
isLoading={isLoading}
|
||||
onPress={() => {
|
||||
console.log("Simpan foto background >>", id);
|
||||
router.back();
|
||||
onUpload();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
Update
|
||||
</ButtonCustom>
|
||||
</BoxButtonOnFooter>
|
||||
);
|
||||
|
||||
const image = imageUri ? (
|
||||
<Image
|
||||
source={{ uri: imageUri }}
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
/>
|
||||
) : (
|
||||
<Image
|
||||
source={
|
||||
data?.imageBackgroundId
|
||||
? { uri: API_STRORAGE.GET({ fileId: data.imageBackgroundId }) }
|
||||
: DUMMY_IMAGE.background
|
||||
}
|
||||
style={{ width: "100%", height: "100%", borderRadius: 10 }}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<ViewWrapper footerComponent={buttonFooter}>
|
||||
<BaseBox
|
||||
style={{ alignItems: "center", justifyContent: "center", height: 250 }}
|
||||
>
|
||||
<Image
|
||||
source={DUMMY_IMAGE.background}
|
||||
resizeMode="cover"
|
||||
style={{ width: "100%", height: "100%", borderRadius: 10 }}
|
||||
/>
|
||||
{image}
|
||||
</BaseBox>
|
||||
|
||||
<ButtonCenteredOnly
|
||||
icon="upload"
|
||||
onPress={() => router.navigate(`/(application)/take-picture/${id}`)}
|
||||
onPress={() => {
|
||||
pickImage({
|
||||
setImageUri,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Update
|
||||
</ButtonCenteredOnly>
|
||||
|
||||
@@ -1,47 +1,135 @@
|
||||
import {
|
||||
AvatarCustom,
|
||||
BaseBox,
|
||||
BoxButtonOnFooter,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
} from "@/components";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { apiProfile, apiUpdateProfile } from "@/service/api-client/api-profile";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Image } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export default function UpdatePhotoProfile() {
|
||||
const { id } = useLocalSearchParams();
|
||||
const [data, setData] = useState<IProfile>();
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadData(id as string);
|
||||
}, [id])
|
||||
);
|
||||
|
||||
async function onLoadData(id: string) {
|
||||
try {
|
||||
const response = await apiProfile({ id });
|
||||
setData(response.data);
|
||||
} catch (error) {
|
||||
console.log("error get profile >>", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onUpload() {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await uploadImageService({
|
||||
imageUri,
|
||||
dirId: DIRECTORY_ID.profile_foto,
|
||||
});
|
||||
|
||||
console.log("response upload photo>>", JSON.stringify(response, null, 2));
|
||||
|
||||
if (response.success) {
|
||||
const fileId = response.data.id;
|
||||
const responseUpdate = await apiUpdateProfile({
|
||||
id: id as string,
|
||||
data: { fileId },
|
||||
category: "photo",
|
||||
});
|
||||
|
||||
if (!responseUpdate.success) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Info",
|
||||
text2: responseUpdate.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Sukses",
|
||||
text2: "Photo berhasil diupdate",
|
||||
});
|
||||
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: error as string,
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const buttonFooter = (
|
||||
<BoxButtonOnFooter>
|
||||
<ButtonCustom
|
||||
isLoading={isLoading}
|
||||
onPress={() => {
|
||||
console.log("Simpan foto profile >>", id);
|
||||
router.back();
|
||||
onUpload();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
Update
|
||||
</ButtonCustom>
|
||||
</BoxButtonOnFooter>
|
||||
);
|
||||
|
||||
const image = imageUri ? (
|
||||
<Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
|
||||
) : (
|
||||
<Image
|
||||
source={
|
||||
data?.imageId
|
||||
? { uri: API_STRORAGE.GET({ fileId: data.imageId }) }
|
||||
: DUMMY_IMAGE.avatar
|
||||
}
|
||||
style={{ width: 200, height: 200 }}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<ViewWrapper footerComponent={buttonFooter}>
|
||||
<BaseBox
|
||||
style={{ alignItems: "center", justifyContent: "center", height: 250 }}
|
||||
>
|
||||
<AvatarCustom size="xl" />
|
||||
{image}
|
||||
</BaseBox>
|
||||
|
||||
{/* Upload Image */}
|
||||
<ButtonCenteredOnly
|
||||
icon="upload"
|
||||
onPress={() => {
|
||||
console.log("Update photo >>", id);
|
||||
router.navigate(`/(application)/take-picture/${id}`);
|
||||
pickImage({
|
||||
setImageUri,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Update
|
||||
Upload
|
||||
</ButtonCenteredOnly>
|
||||
|
||||
{/* <Spacing />
|
||||
<ButtonCustom>Test</ButtonCustom> */}
|
||||
</ViewWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
AvatarCustom,
|
||||
BaseBox,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
SelectCustom,
|
||||
@@ -10,16 +10,23 @@ import {
|
||||
} from "@/components";
|
||||
import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter";
|
||||
import InformationBox from "@/components/Box/InformationBox";
|
||||
import LandscapeFrameUploaded from "@/components/Image/LandscapeFrameUploaded";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiCreateProfile } from "@/service/api-client/api-profile";
|
||||
import { router, useFocusEffect } from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import { apiValidationEmail } from "@/service/api-client/api-validation";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
import { router } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Image, View } from "react-native";
|
||||
import { Avatar } from "react-native-paper";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export default function CreateProfile() {
|
||||
const { user } = useAuth();
|
||||
const [imagePhoto, setImagePhoto] = useState<string | null>(null);
|
||||
const [imageBackground, setImageBackground] = useState<string | null>(null);
|
||||
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [data, setData] = useState({
|
||||
@@ -30,17 +37,11 @@ export default function CreateProfile() {
|
||||
jenisKelamin: "",
|
||||
});
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
Toast.show({
|
||||
type: "info",
|
||||
text1: "Lengkapi Profile Anda",
|
||||
text2: "Untuk menjelajahi fitur-fitur yang ada",
|
||||
});
|
||||
}, [])
|
||||
);
|
||||
|
||||
const handlerSave = async () => {
|
||||
let IMG = {
|
||||
imageId: "",
|
||||
imageBackgroundId: "",
|
||||
};
|
||||
if (!data.name || !data.email || !data.alamat || !data.jenisKelamin) {
|
||||
Toast.show({
|
||||
type: "info",
|
||||
@@ -52,7 +53,67 @@ export default function CreateProfile() {
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await apiCreateProfile(data);
|
||||
|
||||
const responseValidateEmail = await apiValidationEmail({
|
||||
email: data.email,
|
||||
});
|
||||
|
||||
if (!responseValidateEmail.success) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: responseValidateEmail.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (imagePhoto) {
|
||||
try {
|
||||
const responseUploadPhoto = await uploadImageService({
|
||||
imageUri: imagePhoto,
|
||||
dirId: DIRECTORY_ID.profile_foto,
|
||||
});
|
||||
|
||||
if (responseUploadPhoto.success) {
|
||||
const fileIdPhoto = responseUploadPhoto.data.id;
|
||||
|
||||
IMG.imageId = fileIdPhoto;
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: error as string,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (imageBackground) {
|
||||
try {
|
||||
const responseUploadBackground = await uploadImageService({
|
||||
imageUri: imageBackground,
|
||||
dirId: DIRECTORY_ID.profile_background,
|
||||
});
|
||||
if (responseUploadBackground.success) {
|
||||
const fileIdBackground = responseUploadBackground.data.id;
|
||||
|
||||
IMG.imageBackgroundId = fileIdBackground;
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: error as string,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const fixData = {
|
||||
...data,
|
||||
...IMG,
|
||||
};
|
||||
|
||||
const response = await apiCreateProfile(fixData);
|
||||
if (response.status === 400) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
@@ -67,9 +128,15 @@ export default function CreateProfile() {
|
||||
text1: "Sukses",
|
||||
text2: "Profile berhasil dibuat",
|
||||
});
|
||||
|
||||
router.push("/(application)/(user)/home");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log("error create profile >>", error);
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal membuat profile",
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -92,11 +159,18 @@ export default function CreateProfile() {
|
||||
<StackCustom>
|
||||
<InformationBox text="Upload foto profile anda." />
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<AvatarCustom size="xl" />
|
||||
<Avatar.Image
|
||||
size={100}
|
||||
source={imagePhoto ? { uri: imagePhoto } : DUMMY_IMAGE.avatar}
|
||||
/>
|
||||
<Spacing />
|
||||
<ButtonCenteredOnly
|
||||
icon="upload"
|
||||
onPress={() => router.navigate(`/take-picture/${user?.id}`)}
|
||||
onPress={() => {
|
||||
pickImage({
|
||||
setImageUri: setImagePhoto,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Upload
|
||||
</ButtonCenteredOnly>
|
||||
@@ -106,11 +180,24 @@ export default function CreateProfile() {
|
||||
|
||||
<View>
|
||||
<InformationBox text="Upload foto latar belakang anda." />
|
||||
<LandscapeFrameUploaded />
|
||||
<Spacing />
|
||||
<BaseBox>
|
||||
<Image
|
||||
source={
|
||||
imageBackground
|
||||
? { uri: imageBackground }
|
||||
: DUMMY_IMAGE.background
|
||||
}
|
||||
style={{ width: "100%", height: 200 }}
|
||||
/>
|
||||
</BaseBox>
|
||||
{/* <Spacing /> */}
|
||||
<ButtonCenteredOnly
|
||||
icon="upload"
|
||||
onPress={() => router.navigate(`/take-picture/${user?.id}`)}
|
||||
onPress={() => {
|
||||
pickImage({
|
||||
setImageUri: setImageBackground,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Upload
|
||||
</ButtonCenteredOnly>
|
||||
|
||||
80
app/(application)/coba/button-upload.tsx
Normal file
80
app/(application)/coba/button-upload.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { ButtonCustom } from "@/components";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { Alert } from "react-native";
|
||||
|
||||
// Daftar ekstensi yang diperbolehkan
|
||||
const ALLOWED_EXTENSIONS = ["jpg", "jpeg", "png"];
|
||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
export default function ButtonUpload({
|
||||
setImageUri,
|
||||
}: {
|
||||
setImageUri: (uri: string) => void;
|
||||
}) {
|
||||
const pickImg = async () => {
|
||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
Alert.alert(
|
||||
"Permission Denied",
|
||||
"You need to grant permission to access your media library"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [4, 3],
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (result.canceled || !result.assets[0]?.uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uri = result.assets[0].uri;
|
||||
const filename = uri.split("/").pop()?.toLowerCase() || "";
|
||||
const match = /\.(\w+)$/.exec(filename);
|
||||
const extension = match ? match[1] : "";
|
||||
|
||||
// Validasi ekstensi
|
||||
if (!extension || !ALLOWED_EXTENSIONS.includes(extension)) {
|
||||
Alert.alert(
|
||||
"File Tidak Valid",
|
||||
"Hanya file JPG, JPEG, dan PNG yang diperbolehkan."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Opsional: Validasi ukuran file (jika metadata tersedia)
|
||||
// Catatan: Di Expo, `file.size` mungkin tidak tersedia di semua platform
|
||||
const asset = result.assets[0];
|
||||
if (asset.fileSize && asset.fileSize > MAX_FILE_SIZE) {
|
||||
Alert.alert("File Terlalu Besar", "Ukuran file maksimal adalah 5MB.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Jika lolos validasi, simpan URI
|
||||
setImageUri(uri);
|
||||
};
|
||||
|
||||
return (
|
||||
<ButtonCustom
|
||||
iconLeft={<Feather name="upload" size={14} color="black" />}
|
||||
style={{
|
||||
width: 120,
|
||||
margin: "auto",
|
||||
}}
|
||||
onPress={() => {
|
||||
pickImage({
|
||||
setImageUri,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Upload
|
||||
</ButtonCustom>
|
||||
);
|
||||
}
|
||||
@@ -1,184 +1,39 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { Stack } from "expo-router";
|
||||
import React from "react";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
StyleSheet,
|
||||
Dimensions,
|
||||
ScrollView,
|
||||
} from "react-native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router, Stack } from "expo-router";
|
||||
import EventDetailScreen from "./double-scroll";
|
||||
import LeftButtonCustom from "@/components/Button/BackButton";
|
||||
import CustomUploadButton from "./upload-button";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import ScreenViewImage from "./screen-view-image";
|
||||
|
||||
const { width } = Dimensions.get("window");
|
||||
|
||||
// Sample Screen Components
|
||||
const HomeScreen = () => (
|
||||
<View style={styles.screen}>
|
||||
<Text style={styles.screenTitle}>Selamat Datang!</Text>
|
||||
<Text style={styles.screenText}>
|
||||
Ini adalah halaman utama aplikasi Anda
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
const SearchScreen = () => (
|
||||
<View style={styles.screen}>
|
||||
<Text style={styles.screenTitle}>Search Screen</Text>
|
||||
<Text style={styles.screenText}>Cari apa yang Anda butuhkan</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
const ProfileScreen = () => (
|
||||
<View style={styles.screen}>
|
||||
<Text style={styles.screenTitle}>Profile Screen</Text>
|
||||
<Text style={styles.screenText}>Informasi profil pengguna</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
const NotificationScreen = () => (
|
||||
<View style={styles.screen}>
|
||||
{Array.from({ length: 10 }).map((_, index) => (
|
||||
<View key={index}>
|
||||
<Text style={styles.screenTitle}>Notifications</Text>
|
||||
<Text style={styles.screenText}>Notifikasi terbaru Anda</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
|
||||
// Custom Tab Component
|
||||
const CustomTab = ({ icon, label, isActive, onPress }: any) => (
|
||||
<TouchableOpacity
|
||||
style={[styles.tabItem, isActive && styles.activeTab]}
|
||||
onPress={onPress}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<View
|
||||
style={[styles.iconContainer, isActive && styles.activeIconContainer]}
|
||||
>
|
||||
<Ionicons name={icon} size={24} color={isActive ? "#fff" : "#666"} />
|
||||
</View>
|
||||
<Text style={[styles.tabLabel, isActive && styles.activeTabLabel]}>
|
||||
{label}
|
||||
</Text>
|
||||
{isActive && <View style={styles.activeIndicator} />}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
// Main Custom Tab Navigator
|
||||
const CustomTabNavigator = () => {
|
||||
const [activeTab, setActiveTab] = React.useState("home");
|
||||
const [showHome, setShowHome] = React.useState(true);
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
id: "search",
|
||||
icon: "search-outline",
|
||||
activeIcon: "search",
|
||||
label: "Event",
|
||||
component: SearchScreen,
|
||||
path: "/event",
|
||||
},
|
||||
{
|
||||
id: "notifications",
|
||||
icon: "notifications-outline",
|
||||
activeIcon: "notifications",
|
||||
label: "Forum",
|
||||
component: NotificationScreen,
|
||||
path: "/forum",
|
||||
},
|
||||
{
|
||||
id: "profile",
|
||||
icon: "person-outline",
|
||||
activeIcon: "person",
|
||||
label: "Katalog",
|
||||
component: ProfileScreen,
|
||||
path: "/profile",
|
||||
},
|
||||
];
|
||||
|
||||
// Function untuk handle tab press
|
||||
const handleTabPress = (tabId: string) => {
|
||||
setActiveTab(tabId);
|
||||
setShowHome(false); // Hide home when any tab is pressed
|
||||
};
|
||||
|
||||
// Determine which component to show
|
||||
const getActiveComponent = () => {
|
||||
if (showHome || activeTab === "home") {
|
||||
return HomeScreen;
|
||||
}
|
||||
// const selectedTab = tabs.find((tab) => tab.id === activeTab);
|
||||
// return selectedTab ? selectedTab.component : HomeScreen;
|
||||
return HomeScreen;
|
||||
};
|
||||
|
||||
const ActiveComponent = getActiveComponent();
|
||||
|
||||
const handleImageUpload = (file: any) => {
|
||||
console.log("Gambar dipilih:", file);
|
||||
// Upload ke server
|
||||
};
|
||||
|
||||
const handlePdfOrPngUpload = (file: any) => {
|
||||
console.log("PDF atau PNG dipilih:", file);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<SafeAreaView edges={["bottom"]} style={styles.container}>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Custom Tab Navigator",
|
||||
title: "Tampilan Percobaan",
|
||||
}}
|
||||
/>
|
||||
<EventDetailScreen />
|
||||
<ScreenViewImage />
|
||||
{/* <ScreenUpload/> */}
|
||||
{/* <EventDetailScreen /> */}
|
||||
|
||||
<CustomUploadButton
|
||||
{/* <CustomUploadButton
|
||||
allowedExtensions={["jpeg", "png"]}
|
||||
buttonTitle="Unggah Gambar (JPEG/PNG)"
|
||||
onFileSelected={handleImageUpload}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
{/* Hanya PDF atau PNG */}
|
||||
<CustomUploadButton
|
||||
{/* <CustomUploadButton
|
||||
allowedExtensions={["pdf"]}
|
||||
buttonTitle="Unggah PDF atau PNG"
|
||||
onFileSelected={handlePdfOrPngUpload}
|
||||
/>
|
||||
/> */}
|
||||
</SafeAreaView>
|
||||
</>
|
||||
// <View style={styles.container}>
|
||||
// {/* Content Area */}
|
||||
// <ScrollView>
|
||||
// <View style={styles.content}>
|
||||
// <ActiveComponent />
|
||||
// </View>
|
||||
// </ScrollView>
|
||||
|
||||
// {/* Custom Tab Bar */}
|
||||
// <View style={styles.tabBar}>
|
||||
// <View style={styles.tabContainer}>
|
||||
// {tabs.map((e) => (
|
||||
// <CustomTab
|
||||
// key={e.id}
|
||||
// icon={activeTab === e.id ? e.activeIcon : e.icon}
|
||||
// label={e.label}
|
||||
// isActive={activeTab === e.id && !showHome}
|
||||
// onPress={() => {
|
||||
// handleTabPress(e.id);
|
||||
// router.push(e.path as any);
|
||||
// }}
|
||||
// />
|
||||
// ))}
|
||||
// </View>
|
||||
// </View>
|
||||
// </View>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
73
app/(application)/coba/screen-upload.tsx
Normal file
73
app/(application)/coba/screen-upload.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import {
|
||||
AvatarCustom,
|
||||
BoxButtonOnFooter,
|
||||
ButtonCustom,
|
||||
StackCustom,
|
||||
ViewWrapper,
|
||||
} from "@/components";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { router } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import ButtonUpload from "./button-upload";
|
||||
|
||||
export default function ScreenUpload() {
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
async function onUpload() {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await uploadImageService({
|
||||
imageUri,
|
||||
dirId: DIRECTORY_ID.profile_foto,
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
await AsyncStorage.setItem("idImage", response.data.id);
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function buttonUpload() {
|
||||
return (
|
||||
<>
|
||||
<BoxButtonOnFooter>
|
||||
<ButtonCustom isLoading={isLoading} onPress={() => onUpload()}>
|
||||
Simpan
|
||||
</ButtonCustom>
|
||||
</BoxButtonOnFooter>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ViewWrapper footerComponent={buttonUpload()}>
|
||||
<StackCustom>
|
||||
<View
|
||||
style={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<AvatarCustom
|
||||
source={imageUri ? { uri: imageUri } : DUMMY_IMAGE.avatar}
|
||||
size="xl"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<ButtonUpload setImageUri={setImageUri} />
|
||||
</StackCustom>
|
||||
</ViewWrapper>
|
||||
</>
|
||||
);
|
||||
}
|
||||
73
app/(application)/coba/screen-view-image.tsx
Normal file
73
app/(application)/coba/screen-view-image.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
import { ButtonCustom, StackCustom, ViewWrapper } from "@/components";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { router, useFocusEffect } from "expo-router";
|
||||
import { useCallback, useState } from "react";
|
||||
import { ActivityIndicator, Image } from "react-native";
|
||||
|
||||
export default function ScreenViewImage() {
|
||||
const [dataId, setDataId] = useState<string | null>(null);
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
AsyncStorage.getItem("idImage").then((id) => {
|
||||
setDataId(id || null);
|
||||
});
|
||||
}, [])
|
||||
);
|
||||
|
||||
return (
|
||||
<ViewWrapper>
|
||||
<StackCustom>
|
||||
{dataId ? (
|
||||
<Image
|
||||
onLoad={() => {
|
||||
<ActivityIndicator size="large" />
|
||||
}}
|
||||
source={{ uri: APIs.GET({ fileId: dataId }) }}
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
margin: "auto",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Image
|
||||
source={DUMMY_IMAGE.avatar}
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
margin: "auto",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ButtonCustom onPress={async () => {
|
||||
await AsyncStorage.removeItem("idImage");
|
||||
router.push("/coba/screen-upload");
|
||||
}}>
|
||||
Upload image
|
||||
</ButtonCustom>
|
||||
</StackCustom>
|
||||
</ViewWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
const APIs = {
|
||||
/**
|
||||
*
|
||||
* @param fileId | file id from wibu storage , atau bisa disimpan di DB
|
||||
* @param size | file size 10 - 1000 , tergantung ukuran file dan kebutuhan saar di tampilkan
|
||||
* @type {string}
|
||||
*/
|
||||
GET: ({ fileId, size }: { fileId: string; size?: string }) =>
|
||||
size
|
||||
? `https://wibu-storage.wibudev.com/api/files/${fileId}-size-${size}`
|
||||
: `https://wibu-storage.wibudev.com/api/files/${fileId}`,
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @returns alamat API dari wibu storage
|
||||
*/
|
||||
GET_NO_PARAMS: "https://wibu-storage.wibudev.com/api/files/",
|
||||
};
|
||||
131
app/(application)/coba/upload-image.tsx
Normal file
131
app/(application)/coba/upload-image.tsx
Normal file
@@ -0,0 +1,131 @@
|
||||
import { apiConfig } from "@/service/api-config";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
Button,
|
||||
Image,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
// Daftar ekstensi yang diperbolehkan
|
||||
const ALLOWED_EXTENSIONS = ["jpg", "jpeg", "png"];
|
||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
export default function UploadImage() {
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
const pickImage = async () => {
|
||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
Alert.alert(
|
||||
"Permission Denied",
|
||||
"You need to grant permission to access your media library"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [1, 1],
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (result.canceled || !result.assets[0]?.uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uri = result.assets[0].uri;
|
||||
const filename = uri.split("/").pop()?.toLowerCase() || "";
|
||||
const match = /\.(\w+)$/.exec(filename);
|
||||
const extension = match ? match[1] : "";
|
||||
|
||||
// Validasi ekstensi
|
||||
if (!extension || !ALLOWED_EXTENSIONS.includes(extension)) {
|
||||
Alert.alert(
|
||||
"File Tidak Valid",
|
||||
"Hanya file JPG, JPEG, dan PNG yang diperbolehkan."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Opsional: Validasi ukuran file (jika metadata tersedia)
|
||||
// Catatan: Di Expo, `file.size` mungkin tidak tersedia di semua platform
|
||||
const asset = result.assets[0];
|
||||
if (asset.fileSize && asset.fileSize > MAX_FILE_SIZE) {
|
||||
Alert.alert("File Terlalu Besar", "Ukuran file maksimal adalah 5MB.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Jika lolos validasi, simpan URI
|
||||
setImageUri(uri);
|
||||
};
|
||||
|
||||
const uploadImage = async () => {
|
||||
if (!imageUri) return;
|
||||
|
||||
setUploading(true);
|
||||
|
||||
const uri = imageUri;
|
||||
const filename = uri.split("/").pop();
|
||||
const match = /\.(\w+)$/.exec(filename || "");
|
||||
const type = match ? `image/${match[1]}` : "image";
|
||||
const dirId = "cmeryhudo016lbpnn3vlhnufq";
|
||||
|
||||
const formData = new FormData();
|
||||
// @ts-ignore: React Native tidak mengenal Blob secara langsung
|
||||
formData.append("file", {
|
||||
uri,
|
||||
name: filename,
|
||||
type,
|
||||
});
|
||||
formData.append("dirId", dirId);
|
||||
|
||||
try {
|
||||
const response = await apiConfig.post("/mobile/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
console.log("Response", JSON.stringify(response.data, null, 2));
|
||||
} catch (error) {
|
||||
console.log("Error", error);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 20, justifyContent: "center" }}>
|
||||
<Button title="Pilih Gambar" onPress={pickImage} />
|
||||
|
||||
{imageUri && (
|
||||
<Image
|
||||
source={{ uri: imageUri }}
|
||||
style={{ width: 300, height: 300, margin: "auto" }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{imageUri && !uploading && (
|
||||
<Button
|
||||
title="Unggah Gambar"
|
||||
onPress={uploadImage}
|
||||
disabled={uploading}
|
||||
/>
|
||||
)}
|
||||
|
||||
{uploading && (
|
||||
<View style={{ marginTop: 20 }}>
|
||||
<ActivityIndicator size="large" color="#0000ff" />
|
||||
<Text>Mengunggah...</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
68
app/(application)/coba/upload-service.ts
Normal file
68
app/(application)/coba/upload-service.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { apiConfig } from "@/service/api-config";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export async function tryUploadService({
|
||||
dirId,
|
||||
imageUri,
|
||||
}: {
|
||||
dirId: string;
|
||||
imageUri: string | null;
|
||||
}) {
|
||||
if (!imageUri) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: "Harap pilih gambar terlebih dahulu",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const uri = imageUri;
|
||||
const filename = uri.split("/").pop();
|
||||
const match = /\.(\w+)$/.exec(filename || "");
|
||||
const type = match ? `image/${match[1]}` : "image";
|
||||
|
||||
const formData = new FormData();
|
||||
// @ts-ignore: React Native tidak mengenal Blob secara langsung
|
||||
formData.append("file", {
|
||||
uri,
|
||||
name: filename,
|
||||
type,
|
||||
});
|
||||
formData.append("dirId", dirId);
|
||||
|
||||
const response = await apiConfig.post("/mobile/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
console.log("Response", JSON.stringify(response.data, null, 2));
|
||||
const { data } = response;
|
||||
|
||||
if (!data.success) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Gagal",
|
||||
text2: data.message,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "File berhasil diunggah",
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "File gagal diunggah",
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
assets/images/dummy/dummy-image.jpg
Normal file
BIN
assets/images/dummy/dummy-image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 395 KiB After Width: | Height: | Size: 30 KiB |
BIN
assets/images/loading.gif
Normal file
BIN
assets/images/loading.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
65
components/Image/AvatarComp.tsx
Normal file
65
components/Image/AvatarComp.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { Href, router } from "expo-router";
|
||||
import { TouchableOpacity } from "react-native";
|
||||
import { Avatar } from "react-native-paper";
|
||||
|
||||
type Size = "base" | "sm" | "md" | "lg" | "xl";
|
||||
|
||||
const sizeMap = {
|
||||
base: 40,
|
||||
sm: 60,
|
||||
md: 80,
|
||||
lg: 100,
|
||||
xl: 120,
|
||||
};
|
||||
|
||||
interface AvatarCompProps {
|
||||
fileId?: string;
|
||||
fileIdDefault?: string;
|
||||
size: Size;
|
||||
onPress?: () => void | any;
|
||||
href?: Href | undefined | any;
|
||||
}
|
||||
|
||||
export default function AvatarComp({
|
||||
fileId,
|
||||
fileIdDefault,
|
||||
size,
|
||||
onPress,
|
||||
href = `/(application)/(image)/preview-image/${fileId}`,
|
||||
}: AvatarCompProps) {
|
||||
const dimension = sizeMap[size];
|
||||
|
||||
const avatarImage = () => {
|
||||
return (
|
||||
<Avatar.Image
|
||||
size={dimension}
|
||||
source={
|
||||
fileId
|
||||
? { uri: API_STRORAGE.GET({ fileId }) }
|
||||
: fileIdDefault
|
||||
? fileIdDefault
|
||||
: DUMMY_IMAGE.avatar
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{onPress || href ? (
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.9}
|
||||
onPress={
|
||||
href && fileId ? () => router.navigate(href as any) : onPress
|
||||
}
|
||||
>
|
||||
{avatarImage()}
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
avatarImage()
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -14,8 +14,8 @@ type Size = "base" | "sm" | "md" | "lg" | "xl";
|
||||
interface AvatarCustomProps {
|
||||
source?: ImageSourcePropType;
|
||||
size?: Size;
|
||||
onPress?: () => void;
|
||||
href?: Href | undefined;
|
||||
onPress?: () => any;
|
||||
href?: Href | undefined | any;
|
||||
}
|
||||
|
||||
const sizeMap = {
|
||||
|
||||
@@ -6,8 +6,8 @@ export default function IconEdit({
|
||||
size,
|
||||
color,
|
||||
}: {
|
||||
size: number;
|
||||
color: string;
|
||||
size?: number;
|
||||
color?: string;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -38,6 +38,7 @@ import StackCustom from "./Stack/StackCustom";
|
||||
import SelectCustom from "./Select/SelectCustom";
|
||||
// Image
|
||||
import AvatarCustom from "./Image/AvatarCustom";
|
||||
import AvatarComp from "./Image/AvatarComp";
|
||||
import LandscapeFrameUploaded from "./Image/LandscapeFrameUploaded";
|
||||
// Divider
|
||||
import Divider from "./Divider/Divider";
|
||||
@@ -69,6 +70,7 @@ export {
|
||||
AlertDefaultSystem,
|
||||
// Image
|
||||
AvatarCustom,
|
||||
AvatarComp,
|
||||
// ShareComponent
|
||||
AvatarUsernameAndOtherComponent,
|
||||
// Button
|
||||
|
||||
20
constants/base-url-api-strorage.ts
Normal file
20
constants/base-url-api-strorage.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
const API_STRORAGE = {
|
||||
/**
|
||||
*
|
||||
* @param fileId | file id from wibu storage , atau bisa disimpan di DB
|
||||
* @param size | file size 10 - 1000 , tergantung ukuran file dan kebutuhan saar di tampilkan
|
||||
* @type {string}
|
||||
*/
|
||||
GET: ({ fileId, size }: { fileId: string; size?: string }) =>
|
||||
size
|
||||
? `https://wibu-storage.wibudev.com/api/files/${fileId}-size-${size}`
|
||||
: `https://wibu-storage.wibudev.com/api/files/${fileId}`,
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @returns alamat API dari wibu storage
|
||||
*/
|
||||
GET_NO_PARAMS: "https://wibu-storage.wibudev.com/api/files/",
|
||||
};
|
||||
|
||||
export default API_STRORAGE;
|
||||
33
constants/directory-id.ts
Normal file
33
constants/directory-id.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
const DIRECTORY_ID = {
|
||||
profile_foto: "cm0x93rgo000jbp5tj8baoaus",
|
||||
profile_background: "cm0x93ze8000lbp5t1a8uc9wl",
|
||||
portofolio_logo: "cm0yjl6ug000310njwmk6j0tx",
|
||||
map_pin: "cm0yjq8up000710njv5klra32",
|
||||
map_image: "cm0yjqnxl000910njplqho07w",
|
||||
|
||||
// Investasi
|
||||
investasi_image: "cm0yjs35h000b10njb35o12h1",
|
||||
investasi_bukti_transfer: "cm0yjsflu000d10njrc3lnqho",
|
||||
investasi_prospektus: "cm1soio74003p38bjyciwf1oy",
|
||||
investasi_dokumen: "cm21g2hxw004d10dpx8j16tt7",
|
||||
investasi_berita: "cm21g2yzc004f10dpbtqdfcjb",
|
||||
|
||||
// Donasi
|
||||
donasi_image: "cm0yk1coh000f10nj597a99kv",
|
||||
donasi_cerita_image: "cm2dvy9bi007v10dpmatb5yiy",
|
||||
donasi_kabar: "cm2dvxo48007t10dpmmustxa2",
|
||||
donasi_bukti_transfer: "cm0yk1pmh000h10njhi6m8b8t",
|
||||
donasi_bukti_trf_pencairan_dana: "cm32s7h1q005yb5kuf5uiv5de",
|
||||
|
||||
// Job
|
||||
job_image: "cm0ypp6zl0003kp7jf59zuvjy",
|
||||
|
||||
// Event
|
||||
event_sponsor: "cm65zlbyf001udvmggnd6i0oh",
|
||||
event_bukti_transfer: "cm65zlehy001wdvmgnobur2zh",
|
||||
|
||||
// Sticker
|
||||
sticker: "cmanquv32002fcesbk49cj07g",
|
||||
};
|
||||
|
||||
export default DIRECTORY_ID;
|
||||
@@ -1,6 +1,7 @@
|
||||
const DUMMY_IMAGE = {
|
||||
avatar: require("@/assets/images/dummy/dummy-user.png"),
|
||||
background: require("@/assets/images/dummy/dummy-image-background.jpg"),
|
||||
dummy_image: require("@/assets/images/dummy/dummy-image.jpg"),
|
||||
};
|
||||
|
||||
export default DUMMY_IMAGE;
|
||||
|
||||
@@ -146,8 +146,8 @@ export default function LoginView() {
|
||||
Login
|
||||
</ButtonCustom>
|
||||
<Spacing />
|
||||
{/* <ButtonCustom onPress={() => router.navigate("/waiting-room")}>
|
||||
Admin ( Delete Soon )
|
||||
{/* <ButtonCustom onPress={() => router.navigate("/(application)/coba")}>
|
||||
Coba
|
||||
</ButtonCustom> */}
|
||||
</View>
|
||||
</ViewWrapper>
|
||||
|
||||
42
screens/Portofolio/BoxPortofolioView.tsx
Normal file
42
screens/Portofolio/BoxPortofolioView.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { BaseBox, Grid, TextCustom } from "@/components";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { router } from "expo-router";
|
||||
|
||||
export default function Portofolio_BoxView({ data }: { data: any }) {
|
||||
return (
|
||||
<>
|
||||
<BaseBox
|
||||
style={{ backgroundColor: MainColor.darkblue }}
|
||||
onPress={() => {
|
||||
router.push(`/portofolio/${data?.id}`);
|
||||
}}
|
||||
>
|
||||
<Grid>
|
||||
<Grid.Col
|
||||
span={10}
|
||||
style={{ justifyContent: "center", backgroundColor: "" }}
|
||||
>
|
||||
<TextCustom bold size="large" truncate={1}>
|
||||
{data && data?.namaBisnis ? data.namaBisnis : "-"}
|
||||
</TextCustom>
|
||||
<TextCustom size="small" color="yellow">
|
||||
#{data && data?.id_Portofolio ? data.id_Portofolio : "-"}
|
||||
</TextCustom>
|
||||
</Grid.Col>
|
||||
<Grid.Col
|
||||
span={2}
|
||||
style={{ alignItems: "flex-end", justifyContent: "center" }}
|
||||
>
|
||||
<Ionicons
|
||||
name="caret-forward"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</BaseBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
121
screens/Portofolio/ButtonCreatePortofolio.tsx
Normal file
121
screens/Portofolio/ButtonCreatePortofolio.tsx
Normal file
@@ -0,0 +1,121 @@
|
||||
import { BoxButtonOnFooter, ButtonCustom } from "@/components";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import { apiPortofolioCreate } from "@/service/api-client/api-portofolio";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import { router } from "expo-router";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
data: any;
|
||||
dataMedsos: any;
|
||||
imageUri: string | null;
|
||||
subBidangSelected: any[];
|
||||
}
|
||||
|
||||
interface ICreatePortofolio {
|
||||
id: string;
|
||||
namaBisnis: string;
|
||||
masterBidangBisnisId: string;
|
||||
alamatKantor: string;
|
||||
tlpn: string;
|
||||
deskripsi: string;
|
||||
fileId: string;
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
instagram: string;
|
||||
tiktok: string;
|
||||
youtube: string;
|
||||
subBidang: any[];
|
||||
}
|
||||
export default function Portofolio_ButtonCreate({
|
||||
id,
|
||||
data,
|
||||
dataMedsos,
|
||||
imageUri,
|
||||
subBidangSelected,
|
||||
}: Props) {
|
||||
const handleCreatePortofolio = async () => {
|
||||
try {
|
||||
let fileId = "";
|
||||
if (imageUri) {
|
||||
const response = await uploadImageService({
|
||||
imageUri: imageUri,
|
||||
dirId: DIRECTORY_ID.portofolio_logo,
|
||||
});
|
||||
|
||||
fileId = response.data.id;
|
||||
}
|
||||
|
||||
// Fix Data
|
||||
const newData: ICreatePortofolio = {
|
||||
id: id,
|
||||
namaBisnis: data.namaBisnis,
|
||||
masterBidangBisnisId: data.masterBidangBisnisId,
|
||||
alamatKantor: data.alamatKantor,
|
||||
tlpn: data.tlpn,
|
||||
deskripsi: data.deskripsi,
|
||||
fileId: fileId,
|
||||
facebook: dataMedsos.facebook,
|
||||
twitter: dataMedsos.twitter,
|
||||
instagram: dataMedsos.instagram,
|
||||
tiktok: dataMedsos.tiktok,
|
||||
youtube: dataMedsos.youtube,
|
||||
subBidang: subBidangSelected,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await apiPortofolioCreate({
|
||||
data: newData,
|
||||
});
|
||||
console.log("Response >>", JSON.stringify(response, null, 2));
|
||||
// return router.replace(`/maps/create`);
|
||||
// return router.push(`/maps/create`);
|
||||
return router.back();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Error",
|
||||
text2: error as string,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// const onCreatePortofolio = async ({ fileId }: { fileId: string }) => {
|
||||
// const newData: ICreatePortofolio = {
|
||||
// namaBisnis: data.namaBisnis,
|
||||
// masterBidangBisnisId: data.masterBidangBisnisId,
|
||||
// alamatKantor: data.alamatKantor,
|
||||
// tlpn: data.tlpn,
|
||||
// deskripsi: data.deskripsi,
|
||||
// fileId: fileId,
|
||||
// facebook: dataMedsos.facebook,
|
||||
// twitter: dataMedsos.twitter,
|
||||
// instagram: dataMedsos.instagram,
|
||||
// tiktok: dataMedsos.tiktok,
|
||||
// youtube: dataMedsos.youtube,
|
||||
// };
|
||||
|
||||
// try {
|
||||
// const response = await apiPortofolioCreate({
|
||||
// id: id,
|
||||
// data: newData,
|
||||
// });
|
||||
// console.log("Response >>", JSON.stringify(response, null, 2));
|
||||
// return response;
|
||||
// } catch (error) {
|
||||
// throw error;
|
||||
// }
|
||||
|
||||
// // router.replace(`/maps/create`);
|
||||
// };
|
||||
|
||||
return (
|
||||
<BoxButtonOnFooter>
|
||||
<ButtonCustom onPress={handleCreatePortofolio}>Selanjutnya</ButtonCustom>
|
||||
</BoxButtonOnFooter>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import {
|
||||
AvatarComp,
|
||||
AvatarCustom,
|
||||
BaseBox,
|
||||
CenterCustom,
|
||||
@@ -10,11 +12,12 @@ import {
|
||||
import DividerCustom from "@/components/Divider/DividerCustom";
|
||||
import { AccentColor } from "@/constants/color-palet";
|
||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { FontAwesome, Ionicons } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { View } from "react-native";
|
||||
|
||||
export default function Portofolio_Data() {
|
||||
export default function Portofolio_Data({ data }: { data: any }) {
|
||||
const { id } = useLocalSearchParams();
|
||||
|
||||
const listData = [
|
||||
@@ -22,60 +25,63 @@ export default function Portofolio_Data() {
|
||||
icon: (
|
||||
<FontAwesome name="building-o" size={ICON_SIZE_SMALL} color="white" />
|
||||
),
|
||||
label: "PT.Bali Interakrtif Perkasa",
|
||||
label: data && data?.namaBisnis ? data.namaBisnis : "-",
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Ionicons name="call-outline" size={ICON_SIZE_SMALL} color="white" />
|
||||
),
|
||||
label: "+6282340374412",
|
||||
label: data && data?.tlpn ? data.tlpn : "-",
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Ionicons name="home-outline" size={ICON_SIZE_SMALL} color="white" />
|
||||
),
|
||||
label: "Jl. Raya Kuta No. 123, Bandung, Indonesia",
|
||||
label: data && data?.alamatKantor ? data.alamatKantor : "-",
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Ionicons name="list-outline" size={ICON_SIZE_SMALL} color="white" />
|
||||
),
|
||||
label: "Teknologia",
|
||||
label:
|
||||
data && data?.MasterBidangBisnis?.name
|
||||
? data.MasterBidangBisnis.name
|
||||
: "-",
|
||||
},
|
||||
];
|
||||
|
||||
const listSubBidang = [
|
||||
{
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="chevron-forward-outline"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
),
|
||||
label: "Security System",
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="chevron-forward-outline"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
),
|
||||
label: "Web Developers",
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="chevron-forward-outline"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
),
|
||||
label: "Mobile Developers",
|
||||
},
|
||||
];
|
||||
// const listSubBidang = [
|
||||
// {
|
||||
// icon: (
|
||||
// <Ionicons
|
||||
// name="chevron-forward-outline"
|
||||
// size={ICON_SIZE_SMALL}
|
||||
// color="white"
|
||||
// />
|
||||
// ),
|
||||
// label: "Security System",
|
||||
// },
|
||||
// {
|
||||
// icon: (
|
||||
// <Ionicons
|
||||
// name="chevron-forward-outline"
|
||||
// size={ICON_SIZE_SMALL}
|
||||
// color="white"
|
||||
// />
|
||||
// ),
|
||||
// label: "Web Developers",
|
||||
// },
|
||||
// {
|
||||
// icon: (
|
||||
// <Ionicons
|
||||
// name="chevron-forward-outline"
|
||||
// size={ICON_SIZE_SMALL}
|
||||
// color="white"
|
||||
// />
|
||||
// ),
|
||||
// label: "Mobile Developers",
|
||||
// },
|
||||
// ];
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -86,7 +92,9 @@ export default function Portofolio_Data() {
|
||||
<TextCustom bold>Data Bisnis</TextCustom>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6} style={{ alignItems: "flex-end" }}>
|
||||
<TextCustom color="yellow">ID: {id}</TextCustom>
|
||||
<TextCustom color="yellow" size={12} bold>
|
||||
ID: {(data && data?.id_Portofolio) || "-"}
|
||||
</TextCustom>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -106,7 +114,11 @@ export default function Portofolio_Data() {
|
||||
}}
|
||||
>
|
||||
<CenterCustom>
|
||||
<AvatarCustom size="xl" />
|
||||
<AvatarComp
|
||||
size="xl"
|
||||
fileId={data?.logoId as any}
|
||||
fileIdDefault={DUMMY_IMAGE.dummy_image}
|
||||
/>
|
||||
</CenterCustom>
|
||||
</ClickableCustom>
|
||||
|
||||
@@ -125,7 +137,7 @@ export default function Portofolio_Data() {
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
))}
|
||||
<View style={{ paddingLeft: 10 }}>
|
||||
{/* <View style={{ paddingLeft: 10 }}>
|
||||
{listSubBidang.map((item, index) => (
|
||||
<Grid key={index}>
|
||||
<Grid.Col span={2} style={{ alignItems: "center" }}>
|
||||
@@ -138,7 +150,7 @@ export default function Portofolio_Data() {
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
))}
|
||||
</View>
|
||||
</View> */}
|
||||
</View>
|
||||
|
||||
<DividerCustom labelPosition="top" color={AccentColor.blue} />
|
||||
@@ -160,10 +172,7 @@ export default function Portofolio_Data() {
|
||||
</Grid>
|
||||
|
||||
<TextCustom style={{ paddingInline: 10 }}>
|
||||
Lorem ipsum, dolor sit amet consectetur adipisicing elit.
|
||||
Doloremque, alias perspiciatis quis enim eos facilis sit est?
|
||||
Doloremque, rerum. Cumque error asperiores harum temporibus
|
||||
cupiditate ullam, id quibusdam! Harum, rerum!
|
||||
{(data && data?.deskripsi) || "-"}
|
||||
</TextCustom>
|
||||
</View>
|
||||
</StackCustom>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Spacing, StackCustom } from "@/components";
|
||||
import Portofolio_BusinessLocation from "./BusinessLocationSection";
|
||||
import Portofolio_Data from "./DataPortofolio";
|
||||
import Portofolio_SocialMediaSection from "./SocialMediaSection";
|
||||
import Portofolio_ButtonDelete from "./ButtonDelete";
|
||||
|
||||
export default function PorfofolioSection({
|
||||
setShowDeleteAlert,
|
||||
}: {
|
||||
setShowDeleteAlert: (value: boolean) => void;
|
||||
}) {
|
||||
return (
|
||||
<StackCustom>
|
||||
<Portofolio_Data />
|
||||
<Portofolio_BusinessLocation />
|
||||
<Portofolio_SocialMediaSection />
|
||||
<Portofolio_ButtonDelete setShowDeleteAlert={setShowDeleteAlert}/>
|
||||
<Spacing/>
|
||||
</StackCustom>
|
||||
);
|
||||
}
|
||||
@@ -3,10 +3,10 @@ import { MainColor } from "@/constants/color-palet";
|
||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
|
||||
export default function Portofolio_SocialMediaSection() {
|
||||
export default function Portofolio_SocialMediaSection({ data }: { data: any }) {
|
||||
const listData = [
|
||||
{
|
||||
label: "Facebook ku bagas",
|
||||
label: data && data?.facebook ? data.facebook : "-",
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="logo-facebook"
|
||||
@@ -16,7 +16,7 @@ export default function Portofolio_SocialMediaSection() {
|
||||
),
|
||||
},
|
||||
{
|
||||
label: "Tiktok ku bagas",
|
||||
label: data && data?.tiktok ? data.tiktok : "-",
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="logo-tiktok"
|
||||
@@ -26,7 +26,7 @@ export default function Portofolio_SocialMediaSection() {
|
||||
),
|
||||
},
|
||||
{
|
||||
label: "Instagram ku bagas",
|
||||
label: data && data?.instagram ? data.instagram : "-",
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="logo-instagram"
|
||||
@@ -36,7 +36,7 @@ export default function Portofolio_SocialMediaSection() {
|
||||
),
|
||||
},
|
||||
{
|
||||
label: "Twitter ku bagas",
|
||||
label: data && data?.twitter ? data.twitter : "-",
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="logo-twitter"
|
||||
@@ -46,7 +46,7 @@ export default function Portofolio_SocialMediaSection() {
|
||||
),
|
||||
},
|
||||
{
|
||||
label: "Youtube ku bagas",
|
||||
label: data && data?.youtube ? data.youtube : "-",
|
||||
icon: (
|
||||
<Ionicons
|
||||
name="logo-youtube"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AvatarCustom, ClickableCustom } from "@/components";
|
||||
import { AvatarComp, ClickableCustom } from "@/components";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import { AccentColor } from "@/constants/color-palet";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { router } from "expo-router";
|
||||
@@ -12,8 +13,6 @@ const AvatarAndBackground = ({
|
||||
imageId: string;
|
||||
}) => {
|
||||
return (
|
||||
// console.log("backgroundId", backgroundId),
|
||||
// console.log("imageId", imageId),
|
||||
<View style={styles.container}>
|
||||
{/* Background Image */}
|
||||
<ClickableCustom
|
||||
@@ -24,24 +23,19 @@ const AvatarAndBackground = ({
|
||||
}}
|
||||
>
|
||||
<ImageBackground
|
||||
source={DUMMY_IMAGE.background}
|
||||
source={
|
||||
backgroundId
|
||||
? { uri: API_STRORAGE.GET({ fileId: backgroundId }) }
|
||||
: DUMMY_IMAGE.background
|
||||
}
|
||||
style={styles.backgroundImage}
|
||||
resizeMode="cover"
|
||||
/>
|
||||
</ClickableCustom>
|
||||
|
||||
{/* Avatar yang sedikit keluar */}
|
||||
|
||||
<View style={styles.avatarOverlap}>
|
||||
<ClickableCustom
|
||||
onPress={() => {
|
||||
router.navigate(
|
||||
`/(application)/(image)/preview-image/${imageId}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<AvatarCustom source={DUMMY_IMAGE.avatar} size="lg" />
|
||||
</ClickableCustom>
|
||||
<AvatarComp size="lg" fileId={imageId} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
45
screens/Profile/PortofolioSection.tsx
Normal file
45
screens/Profile/PortofolioSection.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { BaseBox, CenterCustom, Spacing, TextCustom } from "@/components";
|
||||
import { router } from "expo-router";
|
||||
import { View } from "react-native";
|
||||
import Portofolio_BoxView from "../Portofolio/BoxPortofolioView";
|
||||
|
||||
export default function Profile_PortofolioSection({
|
||||
profileId,
|
||||
data,
|
||||
}: {
|
||||
profileId: string;
|
||||
data: any[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<BaseBox>
|
||||
<View>
|
||||
<TextCustom bold size="large" align="center">
|
||||
Portofolio
|
||||
</TextCustom>
|
||||
<Spacing />
|
||||
|
||||
{data?.length > 0 ? (
|
||||
data?.map((item: any, index) => (
|
||||
<Portofolio_BoxView key={index} data={item} />
|
||||
))
|
||||
) : (
|
||||
<CenterCustom>
|
||||
<TextCustom>Tidak ada portofolio</TextCustom>
|
||||
</CenterCustom>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{data?.length > 0 && (
|
||||
<TextCustom
|
||||
bold
|
||||
align="right"
|
||||
onPress={() => router.push(`/portofolio/${profileId}/list`)}
|
||||
>
|
||||
Lihat semua
|
||||
</TextCustom>
|
||||
)}
|
||||
</BaseBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
import { BaseBox, Grid, Spacing, TextCustom } from "@/components";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import { FontAwesome5, Ionicons } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import _ from "lodash";
|
||||
import { View } from "react-native";
|
||||
import AvatarAndBackground from "./AvatarAndBackground";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import _ from "lodash";
|
||||
|
||||
export default function ProfileSection({ data }: { data: IProfile }) {
|
||||
const { id } = useLocalSearchParams();
|
||||
|
||||
const listData = [
|
||||
{
|
||||
icon: (
|
||||
@@ -47,9 +43,6 @@ export default function ProfileSection({ data }: { data: IProfile }) {
|
||||
return (
|
||||
<>
|
||||
<BaseBox>
|
||||
{/* <TextCustom>
|
||||
{JSON.stringify(data.imageBackgroundId, null, 2)}
|
||||
</TextCustom> */}
|
||||
<AvatarAndBackground
|
||||
backgroundId={data?.imageBackgroundId as any}
|
||||
imageId={data?.imageId as any}
|
||||
@@ -85,57 +78,7 @@ export default function ProfileSection({ data }: { data: IProfile }) {
|
||||
))}
|
||||
</BaseBox>
|
||||
|
||||
<BaseBox>
|
||||
<View>
|
||||
<TextCustom bold size="large" align="center">
|
||||
Portofolio
|
||||
</TextCustom>
|
||||
<Spacing />
|
||||
|
||||
{Array.from({ length: 2 }).map((_, index) => (
|
||||
<BaseBox
|
||||
key={index}
|
||||
style={{ backgroundColor: MainColor.darkblue }}
|
||||
onPress={() => {
|
||||
console.log("press to Portofolio");
|
||||
router.push(`/portofolio/${id}`);
|
||||
}}
|
||||
>
|
||||
<Grid>
|
||||
<Grid.Col
|
||||
span={10}
|
||||
style={{ justifyContent: "center", backgroundColor: "" }}
|
||||
>
|
||||
<TextCustom bold size="large" truncate={1}>
|
||||
Nama usaha portofolio
|
||||
</TextCustom>
|
||||
<TextCustom size="small" color="yellow">
|
||||
#id-porofolio12345
|
||||
</TextCustom>
|
||||
</Grid.Col>
|
||||
<Grid.Col
|
||||
span={2}
|
||||
style={{ alignItems: "flex-end", justifyContent: "center" }}
|
||||
>
|
||||
<Ionicons
|
||||
name="caret-forward"
|
||||
size={ICON_SIZE_SMALL}
|
||||
color="white"
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</BaseBox>
|
||||
))}
|
||||
</View>
|
||||
|
||||
<TextCustom
|
||||
bold
|
||||
align="right"
|
||||
onPress={() => router.push(`/portofolio/${id}/list`)}
|
||||
>
|
||||
Lihat semua
|
||||
</TextCustom>
|
||||
</BaseBox>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
20
service/api-client/api-master.ts
Normal file
20
service/api-client/api-master.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { apiConfig } from "../api-config";
|
||||
|
||||
export async function apiMasterBidangBisnis() {
|
||||
try {
|
||||
const response = await apiConfig.get(`/master/bidang-bisnis`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiMasterSubBidangBisnis({id}: {id: string}) {
|
||||
try {
|
||||
const response = await apiConfig.get(`/master/sub-bidang-bisnis/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
33
service/api-client/api-portofolio.ts
Normal file
33
service/api-client/api-portofolio.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { apiConfig } from "../api-config";
|
||||
|
||||
export async function apiPortofolioCreate({ data }: { data: any }) {
|
||||
try {
|
||||
const response = await apiConfig.post(`/mobile/portofolio`, {
|
||||
data: data,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiGetPortofolio({ id }: { id: string }) {
|
||||
try {
|
||||
const response = await apiConfig.get(`/mobile/portofolio?id=${id}`);
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiGetOnePortofolio({ id }: { id: string }) {
|
||||
try {
|
||||
const response = await apiConfig.get(`/mobile/portofolio/${id}`);
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,13 @@ export async function apiProfile({ id }: { id: string }) {
|
||||
export async function apiUpdateProfile({
|
||||
id,
|
||||
data,
|
||||
category,
|
||||
}: {
|
||||
id: string;
|
||||
data: any;
|
||||
category: "profile" | "photo" | "background";
|
||||
}) {
|
||||
const response = await apiConfig.put(`/mobile/profile/${id}`, {
|
||||
const response = await apiConfig.put(`/mobile/profile/${id}?category=${category}`, {
|
||||
data: data,
|
||||
});
|
||||
return response.data;
|
||||
|
||||
8
service/api-client/api-validation.ts
Normal file
8
service/api-client/api-validation.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { apiConfig } from "../api-config";
|
||||
|
||||
export async function apiValidationEmail({ email }: { email: string }) {
|
||||
const response = await apiConfig.post(`/mobile/validate/email`, {
|
||||
data: email,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import Constants from "expo-constants";
|
||||
const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
||||
export const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
||||
|
||||
export const apiConfig: AxiosInstance = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
@@ -29,7 +29,6 @@ apiConfig.interceptors.request.use(
|
||||
export async function apiVersion() {
|
||||
// console.log("API_BASE_URL", API_BASE_URL);
|
||||
const response = await apiConfig.get("/version");
|
||||
// console.log("Response version", JSON.stringify(response.data, null, 2));
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
54
service/upload-service.ts
Normal file
54
service/upload-service.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { API_BASE_URL } from "@/service/api-config";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import axios from "axios";
|
||||
|
||||
export async function uploadImageService({
|
||||
dirId,
|
||||
imageUri,
|
||||
}: {
|
||||
dirId: string;
|
||||
imageUri: string | null;
|
||||
}) {
|
||||
const token = await AsyncStorage.getItem("authToken");
|
||||
const url = `${API_BASE_URL}/mobile/upload`;
|
||||
|
||||
console.log("url >>", url);
|
||||
|
||||
if (!imageUri) {
|
||||
throw new Error("Harap pilih gambar terlebih dahulu");
|
||||
}
|
||||
|
||||
try {
|
||||
const uri = imageUri;
|
||||
const filename = uri.split("/").pop();
|
||||
const match = /\.(\w+)$/.exec(filename || "");
|
||||
const type = match ? `image/${match[1]}` : "image";
|
||||
|
||||
const formData = new FormData();
|
||||
// @ts-ignore: React Native tidak mengenal Blob secara langsung
|
||||
formData.append("file", {
|
||||
uri,
|
||||
name: filename,
|
||||
type,
|
||||
});
|
||||
formData.append("dirId", dirId);
|
||||
|
||||
const response = await axios.post(url, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
// timeout: 30000,
|
||||
});
|
||||
|
||||
const { data } = response;
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.message);
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
17
types/Type-Master.ts
Normal file
17
types/Type-Master.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export interface IMasterBidangBisnis {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
active: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface IMasterSubBidangBisnis {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
53
utils/pickImage.ts
Normal file
53
utils/pickImage.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { Alert } from "react-native";
|
||||
|
||||
// Daftar ekstensi yang diperbolehkan
|
||||
const ALLOWED_EXTENSIONS = ["jpg", "jpeg", "png"];
|
||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
export default async function pickImage({setImageUri}: {setImageUri: (uri: string) => void}) {
|
||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (status !== "granted") {
|
||||
Alert.alert(
|
||||
"Permission Denied",
|
||||
"You need to grant permission to access your media library"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [4, 3],
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (result.canceled || !result.assets[0]?.uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uri = result.assets[0].uri;
|
||||
const filename = uri.split("/").pop()?.toLowerCase() || "";
|
||||
const match = /\.(\w+)$/.exec(filename);
|
||||
const extension = match ? match[1] : "";
|
||||
|
||||
// Validasi ekstensi
|
||||
if (!extension || !ALLOWED_EXTENSIONS.includes(extension)) {
|
||||
Alert.alert(
|
||||
"File Tidak Valid",
|
||||
"Hanya file JPG, JPEG, dan PNG yang diperbolehkan."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Opsional: Validasi ukuran file (jika metadata tersedia)
|
||||
// Catatan: Di Expo, `file.size` mungkin tidak tersedia di semua platform
|
||||
const asset = result.assets[0];
|
||||
if (asset.fileSize && asset.fileSize > MAX_FILE_SIZE) {
|
||||
Alert.alert("File Terlalu Besar", "Ukuran file maksimal adalah 5MB.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Jika lolos validasi, simpan URI
|
||||
setImageUri(uri);
|
||||
}
|
||||
Reference in New Issue
Block a user