Compare commits

..

16 Commits

Author SHA1 Message Date
b6d4c0e6a6 API Event
Add:
- api-client/api-event : fetch get one, update data, update status, create event

Fix:
- UI : create , detail dan status: untuk menyambungkan ke API

### No Issue
2025-09-11 17:34:08 +08:00
3854db9330 Event
Fix:
- Create event
- api master tipe event

## NO Issue
2025-09-10 17:43:01 +08:00
fc181bda7c API
User search:
Fix:
-  api get all user
- searching by username

Portofolio:
Fix:
- dot button hanya muncul jika user yang memiliki portofolio tersebut yang melihat

Profile:
Fix:
- dot button muncul hanya untuk user yang memiliki akunnya

### No Issue
2025-09-10 16:33:39 +08:00
fb822d20b6 Portofolio
Fix: API edit detail data

### No Issue
2025-09-10 12:12:11 +08:00
0e708dde0f API Portofolio
Fix:
- edit select sub bidang

### NO Issue
2025-09-03 17:42:17 +08:00
9a915c55d2 Portofolio
Fix:
- Sub bidang bisnis

### No Issu
2025-09-02 18:29:28 +08:00
6887f85e6a Poortofoloio
Fix:
- service/api-client/api-portofolio.ts : api edit detail. logo, medsos

### No Issue
2025-09-01 17:10:25 +08:00
bb95e8ccbd API
Add:
- service/api-client/api-file.ts: upload & delete

Portofolio
Fix:
- user)/portofolio/[id]/create.tsx: Loading submit
- (user)/portofolio/[id]/index.tsx: Delete button recode

Profile
Fix:
- (user)/profile/[id]/update-photo && upload-backgroud: delete image yang kama

### No Issue
2025-09-01 12:11:21 +08:00
41a4a94255 Portofolio
Add:
- ervice/api-client/api-portofolio.ts
- creens/Portofolio/BoxPortofolioView.tsx
- screens/Portofolio/ButtonCreatePortofolio.tsx
- create dan show

### No Issue
2025-08-29 17:42:33 +08:00
88527d5bb6 Image : fix dummy user
### No Issue
2025-08-28 17:02:38 +08:00
40441c929f API Upload Image
Profile:
- (user)/profile/[id]/update-background.tsx : perbaikan api
-  app/(application)/(user)/profile/[id]/update-photo.tsx

Fix:
-   service/upload-service.ts : ganti Toast menjadi throw untuk dapatkna error

### No Issue
2025-08-28 15:18:15 +08:00
d3c4f04e07 Profile
Add:
- Api upload background
- /api-client/api-validation.ts

### No Issue
2025-08-27 17:41:42 +08:00
4fc2c90702 Profile
Add:
- Api background profile

Asset
Add:
- assets/images/loading.gif: untuk loading

### No Issue
2025-08-27 14:38:37 +08:00
2227aaa99f Profile
Fix:
- profile/[id]/edit.tsx: api upload
- profile/[id]/update-photo.tsx: api upload
- service/api-client/api-profile.ts: api profile bisa memilih kategori

Component
Add:
- components/Image/AvatarComp.tsx

### No Issue
2025-08-27 12:16:31 +08:00
7cddc7abe3 API upload image
Add:
- utils/pickImage.ts
- service/upload-service.ts
- constants/directory-id.ts
- constants/base-url-api-strorage.ts

### No Issue
2025-08-26 17:42:59 +08:00
59482ca712 API Profile:
Fix:
- api create, get , edit

Types
Add:
- Type-Profile

### No Issue
2025-08-25 17:59:07 +08:00
77 changed files with 4010 additions and 1023 deletions

View File

@@ -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>
);
}

View File

@@ -8,7 +8,7 @@ import {
Spacing,
StackCustom,
TextCustom,
ViewWrapper
ViewWrapper,
} from "@/components";
import { IconEdit } from "@/components/_Icon";
import Collaboration_BoxDetailSection from "@/screens/Collaboration/BoxDetailSection";

View File

@@ -1,27 +1,57 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BoxWithHeaderSection,
Grid,
ScrollableCustom,
StackCustom,
TextCustom
BoxWithHeaderSection,
Grid,
LoaderCustom,
ScrollableCustom,
StackCustom,
TextCustom,
} from "@/components";
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
import { useAuth } from "@/hooks/use-auth";
import { dummyMasterStatus } from "@/lib/dummy-data/_master/status";
import { useState } from "react";
import { apiEventGetByStatus } from "@/service/api-client/api-event";
import { useFocusEffect } from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
export default function EventStatus() {
const id = "test-id-event";
const { user } = useAuth();
const id = user?.id || "";
const [activeCategory, setActiveCategory] = useState<string | null>(
"publish"
);
const [listData, setListData] = useState([]);
const [loadingGetData, setLoadingGetData] = useState(false);
useFocusEffect(
useCallback(() => {
onLoadData();
}, [activeCategory, id])
);
async function onLoadData() {
try {
setLoadingGetData(true);
const response = await apiEventGetByStatus({
id: id!,
status: activeCategory!,
});
// console.log("Response", JSON.stringify(response.data, null, 2));
setListData(response.data);
} catch (error) {
console.log(error);
} finally {
setLoadingGetData(false);
}
}
const handlePress = (item: any) => {
setActiveCategory(item.value);
// tambahkan logika lain seperti filter dsb.
};
const scrollComponent = (
const tabsComponent = (
<ScrollableCustom
data={dummyMasterStatus.map((e, i) => ({
id: i,
@@ -34,30 +64,36 @@ export default function EventStatus() {
);
return (
<ViewWrapper headerComponent={scrollComponent}>
<BoxWithHeaderSection href={`/event/${id}/${activeCategory}/detail-event`}>
<StackCustom gap={"xs"}>
<Grid>
<Grid.Col span={8}>
<TextCustom truncate bold>
Lorem ipsum,{" "}
<TextCustom color="green">{activeCategory}</TextCustom> dolor
sit amet consectetur adipisicing elit.
</TextCustom>
</Grid.Col>
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
<TextCustom>{new Date().toLocaleDateString()}</TextCustom>
</Grid.Col>
</Grid>
<ViewWrapper headerComponent={tabsComponent}>
{loadingGetData ? (
<LoaderCustom />
) : _.isEmpty(listData) ? (
<TextCustom align="center">Tidak ada data {activeCategory}</TextCustom>
) : (
listData.map((item: any, i) => (
<BoxWithHeaderSection
key={i}
href={`/event/${item.id }/${activeCategory}/detail-event`}
>
<StackCustom gap={"xs"}>
<Grid>
<Grid.Col span={8}>
<TextCustom truncate bold>
{item?.title}
</TextCustom>
</Grid.Col>
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
<TextCustom>
{new Date(item?.tanggal).toLocaleDateString()}
</TextCustom>
</Grid.Col>
</Grid>
<TextCustom truncate={2}>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur
eveniet ab eum ducimus tempore a quia deserunt quisquam. Tempora,
atque. Aperiam minima asperiores dicta perferendis quis adipisci,
dolore optio porro!
</TextCustom>
</StackCustom>
</BoxWithHeaderSection>
<TextCustom truncate={2}>{item?.deskripsi}</TextCustom>
</StackCustom>
</BoxWithHeaderSection>
))
)}
</ViewWrapper>
);
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BaseBox,
DotButton,
@@ -11,17 +12,64 @@ import {
} from "@/components";
import { IMenuDrawerItem } from "@/components/_Interface/types";
import LeftButtonCustom from "@/components/Button/BackButton";
import Event_AlertButtonStatusSection from "@/screens/Event/AlertButtonStatusSection";
import Event_ButtonStatusSection from "@/screens/Event/ButtonStatusSection";
import { menuDrawerDraftEvent } from "@/screens/Event/menuDrawerDraft";
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { apiEventGetOne } from "@/service/api-client/api-event";
import { dateTimeView } from "@/utils/dateTimeView";
import {
router,
Stack,
useFocusEffect,
useLocalSearchParams,
} from "expo-router";
import { useCallback, useState } from "react";
export default function EventDetailStatus() {
const { id, status } = useLocalSearchParams();
const [openDrawer, setOpenDrawer] = useState(false);
const [openAlert, setOpenAlert] = useState(false);
const [openDeleteAlert, setOpenDeleteAlert] = useState(false);
// const [openAlert, setOpenAlert] = useState(false);
const [data, setData] = useState<any>();
useFocusEffect(
useCallback(() => {
onLoadData();
}, [id])
);
async function onLoadData() {
try {
const response = await apiEventGetOne({ id: id as string });
if (response.success) {
setData(response.data);
}
} catch (error) {
console.log("[ERROR]", error);
}
}
const listData = [
{
title: "Lokasi",
value: data?.lokasi || "-",
},
{
title: "Tipe Acara",
value: data?.EventMaster_TipeAcara?.name || "-",
},
{
title: "Tanggal Mulai",
value: dateTimeView({ date: data?.tanggal }) || "-",
},
{
title: "Tanggal Berakhir",
value: dateTimeView({ date: data?.tanggalSelesai }) || "-",
},
{
title: "Deskripsi",
value: data?.deskripsi || "-",
},
];
const handlePress = (item: IMenuDrawerItem) => {
console.log("PATH >> ", item.path);
@@ -45,7 +93,7 @@ export default function EventDetailStatus() {
<BaseBox>
<StackCustom>
<TextCustom bold align="center" size="xlarge">
Judul event {status}
{data?.title || "-"}
</TextCustom>
{listData.map((item, index) => (
<Grid key={index}>
@@ -60,9 +108,8 @@ export default function EventDetailStatus() {
</StackCustom>
</BaseBox>
<Event_ButtonStatusSection
id={id as string}
status={status as string}
onOpenAlert={setOpenAlert}
onOpenDeleteAlert={setOpenDeleteAlert}
/>
<Spacing />
</ViewWrapper>
@@ -70,7 +117,7 @@ export default function EventDetailStatus() {
<DrawerCustom
isVisible={openDrawer}
closeDrawer={() => setOpenDrawer(false)}
height={250}
height={"auto"}
>
<MenuDrawerDynamicGrid
data={menuDrawerDraftEvent({ id: id as string }) as any}
@@ -78,40 +125,6 @@ export default function EventDetailStatus() {
onPressItem={handlePress as any}
/>
</DrawerCustom>
<Event_AlertButtonStatusSection
id={id as string}
status={status as string}
openAlert={openAlert}
setOpenAlert={setOpenAlert}
openDeleteAlert={openDeleteAlert}
setOpenDeleteAlert={setOpenDeleteAlert}
/>
</>
);
}
const listData = [
{
title: "Lokasi",
value:
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur eveniet ab eum ducimus tempore a quia deserunt quisquam. Tempora, atque. Aperiam minima asperiores dicta perferendis quis adipisci, dolore optio porro!",
},
{
title: "Tipe Acara",
value: "Workshop",
},
{
title: "Tanggal Mulai",
value: "Senin, 18 Juli 2025, 10:00 WIB",
},
{
title: "Tanggal Berakhir",
value: "Selasa, 19 Juli 2025, 12:00 WIB",
},
{
title: "Deskripsi",
value:
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur eveniet ab eum ducimus tempore a quia deserunt quisquam. Tempora, atque. Aperiam minima asperiores dicta perferendis quis adipisci, dolore optio porro!",
},
];

View File

@@ -1,106 +1,265 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ButtonCustom,
LoaderCustom,
SelectCustom,
Spacing,
StackCustom,
TextAreaCustom,
TextCustom,
TextInputCustom,
ViewWrapper,
} from "@/components";
import DateTimePickerCustom from "@/components/DateInput/DateTimePickerCustom";
import { masterTypeEvent } from "@/lib/dummy-data/event/master-type-event";
import {
apiEventGetOne,
apiEventUpdateData,
} from "@/service/api-client/api-event";
import { apiMasterEventType } from "@/service/api-client/api-master";
import { DateTimePickerEvent } from "@react-native-community/datetimepicker";
import { router } from "expo-router";
import React, { useState } from "react";
import { Platform } from "react-native";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import React, { useCallback, useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function EventEdit() {
const { id } = useLocalSearchParams();
const [data, setData] = useState<any>();
// {
// title: "",
// lokasi: "",
// deskripsi: "",
// eventMaster_TipeAcaraId: "",
// tanggal: "",
// tanggalSelesai: "",
// authorId: "",
// }
const [listTypeEvent, setListTypeEvent] = useState([]);
const [selectedDate, setSelectedDate] = useState<
Date | DateTimePickerEvent | null
>(null);
>();
const [selectedEndDate, setSelectedEndDate] = useState<
Date | DateTimePickerEvent | null
>(null);
>();
const handlerSubmit = () => {
const [isLoading, setIsLoading] = useState(false);
const [isLoadData, setIsLoadData] = useState(false);
useFocusEffect(
useCallback(() => {
onLoadData();
}, [id])
);
async function onLoadData() {
try {
if (selectedDate) {
console.log("Tanggal yang dipilih:", selectedDate);
console.log(`ISO Format ${Platform.OS}:`, selectedDate.toString());
// Kirim ke API atau proses lanjutan
} else {
console.log("Tanggal belum dipilih");
setIsLoadData(true);
const response = await apiEventGetOne({ id: id as string });
if (response.success) {
setData(response.data);
setSelectedDate(new Date(response.data.tanggal));
setSelectedEndDate(new Date(response.data.tanggalSelesai));
}
if (selectedEndDate) {
console.log("Tanggal yang dipilih:", selectedEndDate);
console.log(`ISO Format ${Platform.OS}:`, selectedEndDate.toString());
// Kirim ke API atau proses lanjutan
} else {
console.log("Tanggal berakhir belum dipilih");
}
console.log("Data berhasil terupdate");
router.back()
} catch (error) {
console.log(error);
console.log("[ERROR]", error);
} finally {
setIsLoadData(false);
}
}
useEffect(() => {
onLoadMasterEventType();
}, []);
const onLoadMasterEventType = async () => {
try {
const response = await apiMasterEventType();
setListTypeEvent(response.data);
} catch (error) {
console.log("Error onLoadMasterEventType", error);
}
};
const buttonSubmit = (
<ButtonCustom title="Update" onPress={handlerSubmit} />
);
const validateDate = () => {
if (
data?.title === "" ||
data?.lokasi === "" ||
data?.deskripsi === "" ||
data?.eventMaster_TipeAcaraId === ""
) {
Toast.show({
type: "info",
text1: "Info",
text2: "Lengkapi semua data",
});
return;
}
const startDate = new Date(selectedDate as any);
const endDate = new Date(selectedEndDate as any);
if (startDate >= endDate) {
Toast.show({
type: "info",
text1: "Info",
text2: "Ubah tanggal berakhirnya event",
});
return;
}
};
const handlerSubmit = async () => {
validateDate();
try {
setIsLoading(true);
const newData = {
...data,
tanggal: new Date(selectedDate as any).toISOString(),
tanggalSelesai: new Date(selectedEndDate as any).toISOString(),
};
const response = await apiEventUpdateData({
id: id as string,
data: newData,
});
if (response.success) {
Toast.show({
type: "success",
text1: response.message,
});
return router.back();
}
} catch (error) {
console.log(error);
} finally {
setIsLoading(false);
}
};
const validateDateRange = (
selectedDate: string | Date,
selectedEndDate: string | Date
): { isValid: boolean; error?: string } => {
const startDate = new Date(selectedDate);
const endDate = new Date(selectedEndDate);
// Cek apakah tanggal valid
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
return {
isValid: false,
error: "Invalid date provided",
};
}
if (startDate >= endDate) {
return {
isValid: false,
error: "Ubah tanggal berakhirnya event",
};
}
return {
isValid: true,
error: undefined,
};
};
return (
<>
<ViewWrapper>
<StackCustom gap={"xs"}>
<TextInputCustom
placeholder="Masukkan nama event"
label="Nama Event"
required
/>
<SelectCustom
label="Tipe Event"
placeholder="Pilih tipe event"
data={masterTypeEvent}
onChange={(value) => console.log(value)}
/>
<TextInputCustom
label="Lokasi"
placeholder="Masukkan lokasi event"
required
/>
{isLoadData ? (
<LoaderCustom />
) : (
<StackCustom gap={"xs"}>
<TextInputCustom
placeholder="Masukkan nama event"
label="Nama Event"
required
value={data?.title}
onChangeText={(value) => setData({ ...data, title: value })}
/>
<SelectCustom
label="Tipe Event"
placeholder="Pilih tipe event"
data={listTypeEvent.map((item: any) => ({
label: item.name,
value: item.id,
}))}
value={data?.eventMaster_TipeAcaraId || ""}
onChange={(value) => {
console.log(value);
setData({ ...data, eventMaster_TipeAcaraId: value });
}}
/>
<TextInputCustom
label="Lokasi"
placeholder="Masukkan lokasi event"
required
value={data?.lokasi}
onChangeText={(value) => setData({ ...data, lokasi: value })}
/>
<DateTimePickerCustom
minimumDate={new Date(Date.now())}
label="Tanggal & Waktu Mulai"
required
value={selectedDate as any}
onChange={(date: any) => {
setSelectedDate(date as any);
}}
/>
<StackCustom gap={0}>
<DateTimePickerCustom
minimumDate={selectedDate as any}
label="Tanggal & Waktu Berakhir"
required
value={selectedEndDate as any}
onChange={(date: any) => {
setSelectedEndDate(date as any);
}}
/>
<DateTimePickerCustom
label="Tanggal & Waktu Mulai"
required
onChange={(date: Date) => {
setSelectedDate(date as any);
}}
value={selectedDate as any}
minimumDate={new Date(Date.now())}
/>
{/* Muncul */}
{validateDateRange(selectedDate as any, selectedEndDate as any)
.isValid ? (
<TextCustom style={{ color: "green" }}>
{
validateDateRange(
selectedDate as any,
selectedEndDate as any
).error
}
</TextCustom>
) : (
<TextCustom style={{ color: "red" }}>
{
validateDateRange(
selectedDate as any,
selectedEndDate as any
).error
}
</TextCustom>
)}
<Spacing />
</StackCustom>
<DateTimePickerCustom
label="Tanggal & Waktu Berakhir"
required
onChange={(date: Date) => {
setSelectedEndDate(date as any);
}}
value={selectedEndDate as any}
/>
<TextAreaCustom
label="Deskripsi"
placeholder="Masukkan deskripsi event"
required
showCount
maxLength={100}
value={data?.deskripsi}
onChangeText={(value) => setData({ ...data, deskripsi: value })}
/>
<TextAreaCustom
label="Deskripsi"
placeholder="Masukkan deskripsi event"
required
showCount
maxLength={100}
/>
{buttonSubmit}
</StackCustom>
<ButtonCustom
isLoading={isLoading}
title="Update"
onPress={handlerSubmit}
/>
</StackCustom>
)}
</ViewWrapper>
</>
);

View File

@@ -1,19 +1,51 @@
import {
ButtonCustom,
SelectCustom,
Spacing,
StackCustom,
TextAreaCustom,
TextCustom,
TextInputCustom,
ViewWrapper,
} from "@/components";
import DateTimePickerCustom from "@/components/DateInput/DateTimePickerCustom";
import { masterTypeEvent } from "@/lib/dummy-data/event/master-type-event";
import { useAuth } from "@/hooks/use-auth";
import { apiEventCreate } from "@/service/api-client/api-event";
import { apiMasterEventType } from "@/service/api-client/api-master";
import { DateTimePickerEvent } from "@react-native-community/datetimepicker";
import { router } from "expo-router";
import React, { useState } from "react";
import { Platform } from "react-native";
import React, { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
interface EventCreateProps {
title?: string;
lokasi?: string;
deskripsi?: string;
eventMaster_TipeAcaraId?: string;
tanggal?: string;
tanggalSelesai?: string;
authorId?: string;
}
export default function EventCreate() {
const [data, setData] = useState<EventCreateProps>();
const [listTypeEvent, setListTypeEvent] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const { user } = useAuth();
useEffect(() => {
onLoadMasterEventType();
}, []);
const onLoadMasterEventType = async () => {
try {
const response = await apiMasterEventType();
setListTypeEvent(response.data);
} catch (error) {
console.log("Error onLoadMasterEventType", error);
}
};
const [selectedDate, setSelectedDate] = useState<
Date | DateTimePickerEvent | null
>(null);
@@ -22,35 +54,76 @@ export default function EventCreate() {
Date | DateTimePickerEvent | null
>(null);
const handlerSubmit = () => {
const handlerSubmit = async () => {
if (
!data?.title ||
!data?.lokasi ||
!data?.deskripsi ||
!data?.eventMaster_TipeAcaraId
) {
Toast.show({
type: "info",
text1: "Info",
text2: "Lengkapi semua data",
});
return;
}
if (!selectedDate || !selectedEndDate) {
Toast.show({
type: "info",
text1: "Info",
text2: "Pilih tanggal mulai dan berakhir",
});
return;
}
// if (selectedDate) {
// console.log("Tanggal yang dipilih:", selectedDate);
// console.log(`ISO Format ${Platform.OS}:`, selectedDate.toString());
// // Kirim ke API atau proses lanjutan
// } else {
// console.log("Tanggal belum dipilih");
// }
// if (selectedEndDate) {
// console.log("Tanggal yang dipilih:", selectedEndDate);
// console.log(`ISO Format ${Platform.OS}:`, selectedEndDate.toString());
// // Kirim ke API atau proses lanjutan
// } else {
// console.log("Tanggal berakhir belum dipilih");
// }
try {
if (selectedDate) {
console.log("Tanggal yang dipilih:", selectedDate);
console.log(`ISO Format ${Platform.OS}:`, selectedDate.toString());
// Kirim ke API atau proses lanjutan
} else {
console.log("Tanggal belum dipilih");
}
setIsLoading(true);
if (selectedEndDate) {
console.log("Tanggal yang dipilih:", selectedEndDate);
console.log(`ISO Format ${Platform.OS}:`, selectedEndDate.toString());
// Kirim ke API atau proses lanjutan
} else {
console.log("Tanggal berakhir belum dipilih");
}
const newData = {
...data,
tanggal: new Date(selectedDate as any).toISOString(),
tanggalSelesai: new Date(selectedEndDate as any).toISOString(),
authorId: user?.id,
};
console.log("Data berhasil disimpan", JSON.stringify(newData, null, 2));
const response = await apiEventCreate(newData);
console.log("Response", JSON.stringify(response, null, 2));
console.log("Data berhasil disimpan");
router.navigate("/event/status");
} catch (error) {
console.log(error);
} finally {
setIsLoading(false);
}
};
const buttonSubmit = (
<ButtonCustom title="Simpan" onPress={handlerSubmit} />
// <BoxButtonOnFooter>
// </BoxButtonOnFooter>
<ButtonCustom
isLoading={isLoading}
title="Simpan"
onPress={handlerSubmit}
/>
);
return (
@@ -61,17 +134,27 @@ export default function EventCreate() {
placeholder="Masukkan nama event"
label="Nama Event"
required
onChangeText={(value: any) => setData({ ...data, title: value })}
/>
<SelectCustom
label="Tipe Event"
placeholder="Pilih tipe event"
data={masterTypeEvent}
onChange={(value) => console.log(value)}
data={listTypeEvent.map((item: any) => ({
label: item.name,
value: item.id,
}))}
value={data?.eventMaster_TipeAcaraId || ""}
onChange={(value: any) =>
setData({ ...data, eventMaster_TipeAcaraId: value })
}
/>
<TextInputCustom
label="Lokasi"
placeholder="Masukkan lokasi event"
required
onChangeText={(value: any) => setData({ ...data, lokasi: value })}
/>
<DateTimePickerCustom
@@ -84,14 +167,24 @@ export default function EventCreate() {
minimumDate={new Date(Date.now())}
/>
<DateTimePickerCustom
label="Tanggal & Waktu Berakhir"
required
onChange={(date: Date) => {
setSelectedEndDate(date as any);
}}
value={selectedEndDate as any}
/>
<StackCustom gap={0}>
<DateTimePickerCustom
disabled={!selectedDate}
label="Tanggal & Waktu Berakhir"
required
onChange={(date: Date) => {
setSelectedEndDate(date as any);
}}
value={selectedEndDate as any}
minimumDate={new Date(selectedDate as any)}
/>
{!selectedDate && (
<TextCustom color="gray" size={"small"}>
Note: Pilih tanggal mulai terlebih dahulu
</TextCustom>
)}
<Spacing />
</StackCustom>
<TextAreaCustom
label="Deskripsi"
@@ -99,6 +192,9 @@ export default function EventCreate() {
required
showCount
maxLength={100}
onChangeText={(value: any) =>
setData({ ...data, deskripsi: value })
}
/>
{buttonSubmit}

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable react-hooks/exhaustive-deps */
import { StackCustom, ViewWrapper } from "@/components";
import { MainColor } from "@/constants/color-palet";
@@ -8,33 +9,48 @@ import TabSection from "@/screens/Home/tabSection";
import { tabsHome } from "@/screens/Home/tabsList";
import Home_FeatureSection from "@/screens/Home/topFeatureSection";
import { apiUser } from "@/service/api-client/api-user";
import { apiVersion } from "@/service/api-config";
import { Ionicons } from "@expo/vector-icons";
import { Redirect, router, Stack } from "expo-router";
import { useEffect, useState } from "react";
export default function Application() {
const { user } = useAuth();
const [data, setData] = useState<any>({});
const { token, user } = useAuth();
const [data, setData] = useState<any>();
useEffect(() => {
onLoadData();
checkVersion();
}, []);
async function onLoadData() {
const response = await apiUser(user?.id as string);
console.log("data user >>", JSON.stringify(response.active, null, 2));
console.log("Response profile >>", JSON.stringify(response?.data?.Profile, null, 2));
setData(response.data);
}
if (data?.active === false) {
const checkVersion = async () => {
const response = await apiVersion();
console.log("Version >>", JSON.stringify(response.data, null, 2));
};
if (data && data?.active === false) {
console.log("User is not active");
return <Redirect href={`/waiting-room`} />;
}
if (data && data?.Profile === null) {
console.log("Profile is null");
return <Redirect href={`/profile/create`} />;
}
return (
<>
<Stack.Screen
options={{
title: "HIPMI",
title: `HIPMI`,
headerLeft: () => (
<Ionicons
name="search"
@@ -57,7 +73,11 @@ export default function Application() {
),
}}
/>
<ViewWrapper footerComponent={<TabSection tabs={tabsHome} />}>
<ViewWrapper
footerComponent={
<TabSection tabs={tabsHome(data?.Profile?.id as string)} />
}
>
<StackCustom>
<Home_ImageSection />

View File

@@ -1,9 +1,19 @@
import { MapCustom, ViewWrapper } from "@/components";
import { View } from "react-native";
import MapView from "react-native-maps";
export default function Maps() {
return (
<ViewWrapper style={{ paddingInline: 0, paddingBlock: 0 }}>
<MapCustom height={"100%"} />
{/* <MapCustom height={"100%"} /> */}
<View style={{ flex: 1 }}>
<MapView
style={{
width: "100%",
height: "100%",
}}
/>
</View>
</ViewWrapper>
);
}

View File

@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
BoxButtonOnFooter,
ActionIcon,
AvatarComp,
BaseBox,
ButtonCenteredOnly,
ButtonCustom,
CenterCustom,
Grid,
InformationBox,
LandscapeFrameUploaded,
SelectCustom,
Spacing,
StackCustom,
@@ -13,49 +15,122 @@ import {
TextInputCustom,
ViewWrapper,
} from "@/components";
import { IconPlus } from "@/components/_Icon";
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 { ICON_SIZE_XLARGE } from "@/constants/constans-value";
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 { Ionicons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { Image } from "expo-image";
import { useLocalSearchParams } from "expo-router";
import _ from "lodash";
import { useEffect, useState } from "react";
import { Text, TouchableOpacity, 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: "",
alamatKantor: "",
tlpn: "",
deskripsi: "",
});
const [imageUri, setImageUri] = useState<string | null>(null);
const [bidangBisnis, setBidangBisnis] = useState<IMasterBidangBisnis[]>([]);
const [subBidangBisnis, setSubBidangBisnis] = useState<
IMasterSubBidangBisnis[]
>([]);
const [selectedSubBidang, setSelectedSubBidang] = useState<string[]>([]);
const [listSubBidangSelected, setListSubBidangSelected] = useState([
{
id: "",
},
]);
const [dataMedsos, setDataMedsos] = useState({
facebook: "",
twitter: "",
instagram: "",
youtube: "",
tiktok: "",
});
const [isLoadingCreate, setIsLoadingCreate] = useState(false);
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();
onLoadMasterSubBidangBisnis();
}, []);
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 () => {
try {
const response = await apiMasterSubBidangBisnis({});
setSubBidangBisnis(response.data);
} catch (error) {
setSubBidangBisnis([]);
console.log("Error onLoadMasterBidangBisnis", error);
}
};
const handlerSelectedSubBidang = ({ id }: { id: string }) => {
const selectedList = subBidangBisnis?.filter(
(item) => (item?.masterBidangBisnisId as any) === id
);
setSelectedSubBidang(selectedList as any[]);
};
return (
<ViewWrapper footerComponent={buttonSave}>
<ViewWrapper
footerComponent={
<Portofolio_ButtonCreate
id={id as string}
data={data}
dataMedsos={dataMedsos}
imageUri={imageUri}
subBidangSelected={listSubBidangSelected}
isLoadingCreate={isLoadingCreate}
setIsLoadingCreate={setIsLoadingCreate}
/>
}
>
{/* <TextCustom>Portofolio Create {id}</TextCustom> */}
<StackCustom gap={"xs"}>
<InformationBox text="Lengkapi data bisnis anda." />
@@ -63,51 +138,121 @@ 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 });
const isSameBidang = data.masterBidangBisnisId === value;
if (!isSameBidang) {
setListSubBidangSelected([{ id: "" }]);
}
setData({ ...(data as any), masterBidangBisnisId: value });
handlerSelectedSubBidang({ 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,
{listSubBidangSelected.map((item, index) => (
<SelectCustom
key={index}
disabled={data.masterBidangBisnisId === ""}
label="Sub Bidang Usaha"
required
data={_.map(selectedSubBidang as any)
.filter((option: any) => {
const selectedValues = listSubBidangSelected.map((s) => s.id);
return (
option.id === item.id || // biarkan tetap muncul kalau ini valuenya sendiri
!selectedValues.includes(option.id)
);
})
.map((e: any) => ({
value: e.id,
label: e.name,
}))}
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>
value={item.id || null}
onChange={(value) => {
const list = _.clone(listSubBidangSelected);
list[index].id = value as any;
setListSubBidangSelected(list);
}}
/>
))}
<ButtonCenteredOnly onPress={() => console.log("add")}>
<CenterCustom>
<View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
<ActionIcon
disabled={
selectedSubBidang.length === listSubBidangSelected.length
}
onPress={() => {
setListSubBidangSelected([
...listSubBidangSelected,
{ id: "" },
]);
}}
icon={
<Ionicons
name="add-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
<ActionIcon
disabled={listSubBidangSelected.length <= 1}
onPress={() => {
const list = _.clone(listSubBidangSelected);
list.pop();
setListSubBidangSelected(list);
}}
icon={
<Ionicons
name="remove-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
</View>
</CenterCustom>
<Spacing />
{/* <SelectCustom
label="Bidang Usaha"
required
data={bidangBisnis.map((item) => ({
label: item.name,
value: item.id,
}))}
value={null}
onChange={(value) => {
setData({ ...(data as any), masterBidangBisnisId: value });
handlerSelectedSubBidang({ id: value as string });
}}
/> */}
{/* <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 +277,9 @@ export default function PortofolioCreate() {
required
label="Alamat Bisnis"
placeholder="Masukkan alamat bisnis"
onChangeText={(value: any) =>
setData({ ...data, alamatKantor: value })
}
/>
<TextAreaCustom
@@ -144,18 +292,26 @@ export default function PortofolioCreate() {
maxRows={5}
required
showCount
maxLength={100}
maxLength={1000}
/>
<Spacing />
{/* 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 +323,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>

View File

@@ -1,25 +1,125 @@
import {
AvatarCustom,
BaseBox,
BoxButtonOnFooter,
ButtonCenteredOnly,
ButtonCustom,
ViewWrapper,
ViewWrapper
} from "@/components";
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 { useAuth } from "@/hooks/use-auth";
import { apiFileDelete } from "@/service/api-client/api-file";
import {
apiGetOnePortofolio,
apiUpdatePortofolio,
} from "@/service/api-client/api-portofolio";
import { uploadImageService } from "@/service/upload-service";
import pickImage from "@/utils/pickImage";
import { Image } from "expo-image";
import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function PortofolioEditLogo() {
const { id } = useLocalSearchParams();
const [logoId, setLogoId] = useState<any>();
const [imageUri, setImageUri] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const { token } = useAuth();
useEffect(() => {
onLoadData(id as string);
}, [id]);
const onLoadData = async (id: string) => {
const response = await apiGetOnePortofolio({ id: id });
console.log(
"Response portofolio >>",
JSON.stringify(response.data.logoId, null, 2)
);
setLogoId(response.data.logoId);
};
async function onUpload() {
try {
setIsLoading(true);
const response = await uploadImageService({
imageUri,
dirId: DIRECTORY_ID.portofolio_logo,
});
if (response.success) {
const fileId = response.data.id;
const responseUpdate = await apiUpdatePortofolio({
id: id as string,
data: { fileId },
category: "logo",
});
if (!responseUpdate.success) {
Toast.show({
type: "error",
text1: "Info",
text2: responseUpdate.message,
});
return;
}
if (logoId) {
const deletePrevFile = await apiFileDelete({
token: token as string,
id: logoId as string,
});
if (!deletePrevFile.success) {
console.log("error delete prev file >>", deletePrevFile.message);
}
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Logo berhasil diupdate",
});
router.back();
}
} catch (error) {
Toast.show({
type: "error",
text1: "Gagal",
text2: error as string,
});
} finally {
setIsLoading(false);
}
}
const image = imageUri ? (
<Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
) : (
<Image
source={
logoId
? { uri: API_STRORAGE.GET({ fileId: logoId }) }
: DUMMY_IMAGE.avatar
}
style={{ width: 200, height: 200 }}
/>
);
const buttonFooter = (
<BoxButtonOnFooter>
<ButtonCustom
isLoading={isLoading}
disabled={isLoading}
onPress={() => {
console.log("Simpan logo ");
router.back();
onUpload();
}}
>
Simpan
Update
</ButtonCustom>
</BoxButtonOnFooter>
);
@@ -34,13 +134,17 @@ export default function PortofolioEditLogo() {
height: 250,
}}
>
<AvatarCustom size="xl" />
{image}
</BaseBox>
<ButtonCenteredOnly
icon="upload"
onPress={() => router.navigate(`/take-picture/${id}`)}
onPress={() => {
pickImage({
setImageUri,
});
}}
>
Update
Upload
</ButtonCenteredOnly>
</ViewWrapper>
</>

View File

@@ -4,20 +4,87 @@ import {
TextInputCustom,
ViewWrapper,
} from "@/components";
import {
apiGetOnePortofolio,
apiUpdatePortofolio,
} from "@/service/api-client/api-portofolio";
import { useLocalSearchParams, router } from "expo-router";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function PortofolioEditSocialMedia() {
const { id } = useLocalSearchParams();
console.log("ID >>", id);
const [isLoading, setIsLoading] = useState(false);
const [data, setData] = useState<any>({
facebook: "",
twitter: "",
instagram: "",
tiktok: "",
youtube: "",
});
useEffect(() => {
onLoadData(id as string);
}, [id]);
const onLoadData = async (id: string) => {
const response = await apiGetOnePortofolio({ id: id });
console.log(
"Response portofolio >>",
JSON.stringify(response.data.Portofolio_MediaSosial, null, 2)
);
const data = response.data.Portofolio_MediaSosial;
setData({
facebook: data.facebook,
twitter: data.twitter,
instagram: data.instagram,
tiktok: data.tiktok,
youtube: data.youtube,
});
};
const onSubmitUpdate = async () => {
try {
setIsLoading(true);
const response = await apiUpdatePortofolio({
id: id as string,
data: data,
category: "medsos",
});
if (!response.success) {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
return;
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Data media terupdate",
});
router.back();
} catch (error) {
console.log("Error onSubmitUpdate", error);
} finally {
setIsLoading(false);
}
};
const buttonFooter = (
<BoxButtonOnFooter>
<ButtonCustom
onPress={() => {
console.log(`Simpan sosmed ${id}`);
router.back();
}}
isLoading={isLoading}
disabled={isLoading}
onPress={onSubmitUpdate}
>
Simpan
Update
</ButtonCustom>
</BoxButtonOnFooter>
);
@@ -25,11 +92,36 @@ export default function PortofolioEditSocialMedia() {
return (
<>
<ViewWrapper footerComponent={buttonFooter}>
<TextInputCustom label="Tiktok" placeholder="Masukkan tiktok" />
<TextInputCustom label="Instagram" placeholder="Masukkan instagram" />
<TextInputCustom label="Facebook" placeholder="Masukkan facebook" />
<TextInputCustom label="Twitter" placeholder="Masukkan twitter" />
<TextInputCustom label="Youtube" placeholder="Masukkan youtube" />
<TextInputCustom
value={data.tiktok}
onChangeText={(value) => setData({ ...data, tiktok: value })}
label="Tiktok"
placeholder="Masukkan tiktok"
/>
<TextInputCustom
value={data.instagram}
onChangeText={(value) => setData({ ...data, instagram: value })}
label="Instagram"
placeholder="Masukkan instagram"
/>
<TextInputCustom
value={data.facebook}
onChangeText={(value) => setData({ ...data, facebook: value })}
label="Facebook"
placeholder="Masukkan facebook"
/>
<TextInputCustom
value={data.twitter}
onChangeText={(value) => setData({ ...data, twitter: value })}
label="Twitter"
placeholder="Masukkan twitter"
/>
<TextInputCustom
value={data.youtube}
onChangeText={(value) => setData({ ...data, youtube: value })}
label="Youtube"
placeholder="Masukkan youtube"
/>
</ViewWrapper>
</>
);

View File

@@ -0,0 +1,357 @@
import {
ActionIcon,
BoxButtonOnFooter,
ButtonCustom,
CenterCustom,
SelectCustom,
Spacing,
StackCustom,
TextAreaCustom,
TextCustom,
TextInputCustom,
ViewWrapper,
} from "@/components";
import { MainColor } from "@/constants/color-palet";
import { ICON_SIZE_XLARGE } from "@/constants/constans-value";
import {
apiMasterBidangBisnis,
apiMasterSubBidangBisnis,
} from "@/service/api-client/api-master";
import {
apiGetOnePortofolio,
apiUpdatePortofolio,
} from "@/service/api-client/api-portofolio";
import {
IMasterBidangBisnis,
IMasterSubBidangBisnis,
} from "@/types/Type-Master";
import { Ionicons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import { useEffect, useState } from "react";
import { Text, View } from "react-native";
import PhoneInput, { ICountry } from "react-native-international-phone-number";
import Toast from "react-native-toast-message";
interface IFormData {
id_Portofolio: string;
namaBisnis: string;
alamatKantor: string;
tlpn: string;
deskripsi: string;
masterBidangBisnisId: string;
subBidang: any[];
}
interface IListSubBidangSelected {
id: string;
MasterSubBidangBisnis: {
id: string;
name: string;
masterBidangBisnisId: string;
};
}
export default function PortofolioEdit() {
const { id } = useLocalSearchParams();
const [isLoading, setIsLoading] = useState(false);
const [data, setData] = useState<any>({});
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
const [bidangBisnis, setBidangBisnis] = useState<IMasterBidangBisnis[]>([]);
const [subBidangBisnis, setSubBidangBisnis] = useState<
IMasterSubBidangBisnis[]
>([]);
const [selectedSubBidang, setSelectedSubBidang] = useState<string[]>([]);
const [listSubBidangSelected, setListSubBidangSelected] = useState<
IListSubBidangSelected[]
>([
{
id: "",
MasterSubBidangBisnis: {
id: "",
name: "",
masterBidangBisnisId: "",
},
},
]);
function handleInputValue(phoneNumber: string) {
setData({ ...data, tlpn: phoneNumber });
}
function handleSelectedCountry(country: ICountry) {
setSelectedCountry(country);
}
useEffect(() => {
onLoadData(id as string);
onLoadMasterBidang();
onLoadMasterSubBidangBisnis();
}, [id]);
const onLoadData = async (id: string) => {
const response = await apiGetOnePortofolio({ id: id });
if (response.data.tlpn && response.data.tlpn.includes("62")) {
const fixNumber = response.data.tlpn.replace("62", "");
setData({ ...response.data, tlpn: fixNumber });
}
};
const onLoadMasterBidang = async () => {
try {
const response = await apiMasterBidangBisnis();
setBidangBisnis(response.data);
} catch (error) {
setBidangBisnis([]);
console.log("Error onLoadMasterBidangBisnis", error);
}
};
async function onLoadMasterSubBidangBisnis() {
try {
const response = await apiMasterSubBidangBisnis({});
if (response.success) {
setSubBidangBisnis(response.data);
}
} catch (error) {
console.error("Error on load master sub bidang bisnis", error);
}
}
const handleSubmitUpdate = async () => {
try {
setIsLoading(true);
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
const fixNumber = data.tlpn.replace(/\s+/g, "");
const realNumber = callingCode + fixNumber;
const newData: IFormData = {
id_Portofolio: data.id_Portofolio,
namaBisnis: data.namaBisnis,
alamatKantor: data.alamatKantor,
tlpn: realNumber,
deskripsi: data.deskripsi,
masterBidangBisnisId: data.masterBidangBisnisId,
subBidang: listSubBidangSelected,
};
const response = await apiUpdatePortofolio({
id: id as string,
data: newData,
category: "detail",
});
if (!response.success) {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
return;
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Data terupdate",
});
router.back();
} catch (error) {
console.log("Error handleSubmitUpdate", error);
} finally {
setIsLoading(false);
}
};
const buttonUpdate = (
<BoxButtonOnFooter>
<ButtonCustom
isLoading={isLoading}
disabled={isLoading}
onPress={handleSubmitUpdate}
>
Update
</ButtonCustom>
</BoxButtonOnFooter>
);
return (
<>
<ViewWrapper footerComponent={buttonUpdate}>
<StackCustom gap={"xs"}>
<TextInputCustom
required
label="Nama Bisnis"
placeholder="Masukkan nama bisnis"
value={data.namaBisnis}
onChangeText={(value: any) =>
setData({ ...data, namaBisnis: value })
}
/>
<SelectCustom
label="Bidang Usaha"
required
data={bidangBisnis?.map((item) => ({
label: item.name,
value: item.id,
}))}
value={data.masterBidangBisnisId}
onChange={(value) => {
setData({ ...(data as any), masterBidangBisnisId: value });
}}
/>
{listSubBidangSelected.map((item, index) => (
<SelectCustom
key={index}
label="Sub Bidang Usaha"
required
data={subBidangBisnis?.map((item) => ({
label: item.name,
value: item.id,
}))}
value={item.id || null}
onChange={(value) => {
console.log("Value >>", value);
}}
/>
))}
<CenterCustom>
<View
style={{ flexDirection: "row", alignItems: "center", gap: 10 }}
>
<ActionIcon
// disabled={
// selectedSubBidang.length === listSubBidangSelected.length
// }
onPress={() => {
setListSubBidangSelected([
...listSubBidangSelected,
{
id: "",
MasterSubBidangBisnis: {
id: "",
name: "",
masterBidangBisnisId: "",
},
},
]);
}}
icon={
<Ionicons
name="add-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
<ActionIcon
// disabled={listSubBidangSelected.length <= 1}
onPress={() => {
const list = _.clone(listSubBidangSelected);
list.pop();
setListSubBidangSelected(list);
}}
icon={
<Ionicons
name="remove-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
</View>
</CenterCustom>
<Spacing />
{/* <Grid>
<Grid.Col span={10}>
<SelectCustom
// disabled
label="Sub Bidang Usaha"
required
data={dummyMasterSubBidangBisnis.map((item) => ({
label: item.name,
value: item.id,
}))}
value={data.masterSubBidangBisnisId}
onChange={(value) => {
setData({ ...(data as any), masterSubBidangBisnisId: 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> */}
{/* <ButtonCenteredOnly onPress={() => console.log("add")}>
Tambah Pilihan
</ButtonCenteredOnly>
<Spacing /> */}
<View>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<TextCustom semiBold style={{ color: MainColor.white_gray }}>
Nomor Telepon
</TextCustom>
<Text style={{ color: "red" }}> *</Text>
</View>
<Spacing height={5} />
<PhoneInput
value={data.tlpn}
onChangePhoneNumber={handleInputValue}
selectedCountry={selectedCountry}
onChangeSelectedCountry={handleSelectedCountry}
defaultCountry="ID"
placeholder="xxx-xxx-xxx"
/>
</View>
<Spacing />
<TextInputCustom
required
label="Alamat Bisnis"
placeholder="Masukkan alamat bisnis"
value={data.alamatKantor}
onChangeText={(value: any) =>
setData({ ...data, alamatKantor: value })
}
/>
<TextAreaCustom
label="Deskripsi Bisnis"
placeholder="Masukkan deskripsi bisnis"
value={data.deskripsi}
onChangeText={(value: any) =>
setData({ ...data, deskripsi: value })
}
autosize
minRows={2}
maxRows={5}
required
showCount
maxLength={1000}
/>
<Spacing />
<TextCustom>{JSON.stringify(subBidangBisnis, null, 2)}</TextCustom>
</StackCustom>
</ViewWrapper>
</>
);
}

View File

@@ -1,8 +1,9 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ActionIcon,
BoxButtonOnFooter,
ButtonCenteredOnly,
ButtonCustom,
Grid,
CenterCustom,
SelectCustom,
Spacing,
StackCustom,
@@ -12,46 +13,319 @@ 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 { ICON_SIZE_XLARGE } from "@/constants/constans-value";
import {
apiMasterBidangBisnis,
apiMasterSubBidangBisnis,
} from "@/service/api-client/api-master";
import {
apiGetOnePortofolio,
apiUpdatePortofolio,
} from "@/service/api-client/api-portofolio";
import {
IMasterBidangBisnis,
IMasterSubBidangBisnis,
} from "@/types/Type-Master";
import { Ionicons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { Text, TouchableOpacity, View } from "react-native";
import _ from "lodash";
import { useEffect, useState } from "react";
import { Text, View } from "react-native";
import PhoneInput, { ICountry } from "react-native-international-phone-number";
import { ActivityIndicator } from "react-native-paper";
import Toast from "react-native-toast-message";
interface IFormData {
id_Portofolio: string;
namaBisnis: string;
alamatKantor: string;
tlpn: string;
deskripsi: string;
masterBidangBisnisId: string;
subBidang: any[];
}
interface IListSubBidangSelected {
id: string;
MasterSubBidangBisnis?: {
id?: string;
name?: string;
masterBidangBisnisId?: string;
};
}
export default function PortofolioEdit() {
const { id } = useLocalSearchParams();
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
const [inputValue, setInputValue] = useState<string>("");
const [isLoading, setIsLoading] = useState(false);
const [data, setData] = useState<any>({});
const [data, setData] = useState({
name: "",
bidang_usaha: "",
sub_bidang_usaha: "",
alamat: "",
nomor_telepon: "",
deskripsi: "",
});
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
const [bidangBisnis, setBidangBisnis] = useState<
IMasterBidangBisnis[] | null
>(null);
const [subBidangBisnis, setSubBidangBisnis] = useState<
IMasterSubBidangBisnis[] | null
>(null);
const [selectedSubBidang, setSelectedSubBidang] = useState<string[]>([]);
const [listSubBidangSelected, setListSubBidangSelected] = useState<
IListSubBidangSelected[]
>([]);
function handleInputValue(phoneNumber: string) {
setInputValue(phoneNumber);
setData({ ...data, tlpn: phoneNumber });
}
function handleSelectedCountry(country: ICountry) {
setSelectedCountry(country);
}
function handleSave() {
console.log(`Update portofolio berhasil ${id}`);
router.back();
const onLoadMasterBidang = async () => {
try {
const response = await apiMasterBidangBisnis();
setBidangBisnis(response.data);
return response.success;
} catch (error) {
setBidangBisnis([]);
console.log("Error onLoadMasterBidangBisnis", error);
}
};
async function onLoadMasterSubBidangBisnis() {
try {
const response = await apiMasterSubBidangBisnis({});
setSubBidangBisnis(response.data);
return response.success;
} catch (error) {
console.error("Error on load master sub bidang bisnis", error);
}
}
const handleLoadMaster = async (id: string) => {
const loadBidang = await onLoadMasterBidang();
const loadSubBidang = await onLoadMasterSubBidangBisnis();
if (!loadBidang || !loadSubBidang) {
return;
}
onLoadData(id);
};
useEffect(() => {
handleLoadMaster(id as any);
}, [id]);
const onLoadData = async (id: string) => {
const response = await apiGetOnePortofolio({ id: id });
if (response.success) {
const fixNumber = response.data.tlpn.replace("62", "");
setData({ ...response.data, tlpn: fixNumber });
// Cek apakah ada sub bidang bisnis yang terpilih
const prevSubBidang = response.data.Portofolio_BidangDanSubBidangBisnis;
if (prevSubBidang && prevSubBidang.length > 0) {
setListSubBidangSelected(prevSubBidang);
} else {
// Jika tidak ada sub bidang yang terpilih sebelumnya, tetap inisialisasi dengan array kosong
setListSubBidangSelected([
{
id: "",
MasterSubBidangBisnis: {
id: "",
name: "",
},
},
]);
}
const bisnisId = response.data.masterBidangBisnisId;
handleLoadSelectedSubBidang({
id: bisnisId,
});
}
};
// Handler untuk saat komponen pertama kali load
const handleLoadSelectedSubBidang = ({ id }: { id: string }) => {
if (!subBidangBisnis) return;
const filteredSubBidang: any = subBidangBisnis.filter((item) => {
return item.masterBidangBisnisId === id;
});
setSelectedSubBidang(filteredSubBidang);
};
// Handler untuk menambah sub bidang bisnis
const handleAddSubBidang = () => {
setListSubBidangSelected([
...listSubBidangSelected,
{
id: "",
MasterSubBidangBisnis: { id: "", name: "" },
},
]);
};
// Handler untuk menghapus sub bidang bisnis
const handleRemoveSubBidang = (index: number) => {
if (listSubBidangSelected.length <= 1) return;
const updatedList = [...listSubBidangSelected];
updatedList.splice(index, 1);
setListSubBidangSelected(updatedList);
};
// Handler untuk perubahan bidang bisnis
const handleBidangBisnisChange = (val: string) => {
const isSameBidang = data?.MasterBidangBisnis?.id === val;
setData({ ...(data as any), masterBidangBisnisId: val });
// Reset sub bidang jika ganti bidang
if (!isSameBidang) {
setListSubBidangSelected([
{
id: "",
MasterSubBidangBisnis: { id: "", name: "" },
},
]);
}
handleLoadSelectedSubBidang({ id: val });
};
// Handler untuk update sub bidang
const handleSubBidangChange = (value: string, index: number) => {
const select = selectedSubBidang.find((sub: any) => sub.id === value);
const list: any = _.cloneDeep(listSubBidangSelected);
list[index] = {
id: "",
MasterSubBidangBisnis: select || {
id: value,
name: "",
masterBidangBisnisId: "",
},
};
setListSubBidangSelected(list);
};
useEffect(() => {
if (subBidangBisnis?.length !== undefined && data.masterBidangBisnisId) {
handleLoadSelectedSubBidang({
id: data.masterBidangBisnisId,
});
}
}, [subBidangBisnis, data.masterBidangBisnisId]);
function validateData(data: any) {
if (
!data.namaBisnis ||
!data.alamatKantor ||
!data.tlpn ||
!data.deskripsi ||
!data.masterBidangBisnisId
) {
return false;
}
return true;
}
function validateDataSubBidang(dataArray: any[]) {
return !dataArray.some(
(item: any) =>
!item.MasterSubBidangBisnis.id ||
item.MasterSubBidangBisnis.id.trim() === ""
);
}
const handleSubmitUpdate = async () => {
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
const fixNumber = data.tlpn.replace(/\s+/g, "");
const realNumber = callingCode + fixNumber;
const newData: IFormData = {
id_Portofolio: data.id_Portofolio,
namaBisnis: data.namaBisnis,
alamatKantor: data.alamatKantor,
tlpn: realNumber,
deskripsi: data.deskripsi,
masterBidangBisnisId: data.masterBidangBisnisId,
subBidang: listSubBidangSelected,
};
if (!validateData(newData)) {
return Toast.show({
type: "error",
text1: "Harap lengkapi data",
});
}
if (!validateDataSubBidang(listSubBidangSelected as any)) {
return Toast.show({
type: "error",
text1: "Harap lengkapi sub bidang",
});
}
try {
setIsLoading(true);
const response = await apiUpdatePortofolio({
id: id as string,
data: newData,
category: "detail",
});
if (!response.success) {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
return;
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Data terupdate",
});
router.back();
} catch (error) {
console.log("Error handleSubmitUpdate", error);
} finally {
setIsLoading(false);
}
};
const buttonUpdate = (
<BoxButtonOnFooter>
<ButtonCustom onPress={handleSave}>Simpan</ButtonCustom>
<ButtonCustom
isLoading={isLoading}
disabled={isLoading}
onPress={handleSubmitUpdate}
>
Update
</ButtonCustom>
</BoxButtonOnFooter>
);
if (!bidangBisnis || !subBidangBisnis) {
return (
<>
<ViewWrapper>
<ActivityIndicator size="large" color={MainColor.yellow} />
</ViewWrapper>
</>
);
}
return (
<>
<ViewWrapper footerComponent={buttonUpdate}>
@@ -60,50 +334,98 @@ export default function PortofolioEdit() {
required
label="Nama Bisnis"
placeholder="Masukkan nama bisnis"
value={data.namaBisnis}
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}
onChange={(value) => {
setData({ ...(data as any), bidang_usaha: value });
value={data.masterBidangBisnisId}
onChange={(value: any) => {
handleBidangBisnisChange(value);
}}
/>
<Grid>
<Grid.Col span={10}>
{listSubBidangSelected.map((item, index) => {
// Filter data untuk select sub bidang, menghilangkan yang sudah dipilih kecuali untuk item ini sendiri
const selectedIds = listSubBidangSelected
.filter((_, i) => i !== index)
.map((s) => s.MasterSubBidangBisnis?.id)
.filter((id) => id); // Filter hanya yang memiliki id (tidak kosong)
const availableSubBidangOptions = (selectedSubBidang || [])
.filter((sub: any) => {
// Tampilkan jika ini adalah opsi yang dipilih saat ini atau belum dipilih di sub bidang lainnya
return (
sub.id === item.MasterSubBidangBisnis?.id ||
!selectedIds.includes(sub.id)
);
})
.map((sub: any) => ({
value: sub.id,
label: sub.name,
}));
return (
<SelectCustom
// disabled
key={index}
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 });
data={availableSubBidangOptions}
value={item.MasterSubBidangBisnis?.id || null}
onChange={(value: any) => {
handleSubBidangChange(value, index);
}}
/>
</Grid.Col>
<Grid.Col
span={2}
style={{ alignItems: "center", justifyContent: "center" }}
);
})}
<CenterCustom>
<View
style={{ flexDirection: "row", alignItems: "center", gap: 10 }}
>
<TouchableOpacity onPress={() => console.log("delete")}>
<Ionicons name="trash" size={24} color={MainColor.red} />
</TouchableOpacity>
</Grid.Col>
</Grid>
<ButtonCenteredOnly onPress={() => console.log("add")}>
Tambah Pilihan
</ButtonCenteredOnly>
<ActionIcon
disabled={
selectedSubBidang.length === listSubBidangSelected.length
}
onPress={() => {
handleAddSubBidang();
}}
icon={
<Ionicons
name="add-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
<ActionIcon
disabled={listSubBidangSelected.length <= 1}
onPress={() => {
handleRemoveSubBidang(listSubBidangSelected.length - 1);
}}
icon={
<Ionicons
name="remove-circle-outline"
size={ICON_SIZE_XLARGE}
color={MainColor.black}
/>
}
size="xl"
/>
</View>
</CenterCustom>
<Spacing />
<View>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<TextCustom semiBold style={{ color: MainColor.white_gray }}>
@@ -113,7 +435,7 @@ export default function PortofolioEdit() {
</View>
<Spacing height={5} />
<PhoneInput
value={inputValue}
value={data.tlpn}
onChangePhoneNumber={handleInputValue}
selectedCountry={selectedCountry}
onChangeSelectedCountry={handleSelectedCountry}
@@ -127,6 +449,10 @@ export default function PortofolioEdit() {
required
label="Alamat Bisnis"
placeholder="Masukkan alamat bisnis"
value={data.alamatKantor}
onChangeText={(value: any) =>
setData({ ...data, alamatKantor: value })
}
/>
<TextAreaCustom
@@ -141,7 +467,7 @@ export default function PortofolioEdit() {
maxRows={5}
required
showCount
maxLength={100}
maxLength={1000}
/>
<Spacing />
</StackCustom>

View File

@@ -1,20 +1,31 @@
import { AlertCustom, DrawerCustom } from "@/components";
/* eslint-disable react-hooks/exhaustive-deps */
import { DrawerCustom, LoaderCustom, 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 { apiUser } from "@/service/api-client/api-user";
import { GStyles } from "@/styles/global-styles";
import { Ionicons } from "@expo/vector-icons";
import { Stack, useLocalSearchParams, router } from "expo-router";
import { useState } from "react";
import { Stack, useFocusEffect, useLocalSearchParams } from "expo-router";
import { useCallback, useState } from "react";
import { TouchableOpacity } from "react-native";
export default function Portofolio() {
const { id } = useLocalSearchParams();
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const [deleteAlert, setDeleteAlert] = useState(false);
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
const [data, setData] = useState<any>();
const [profileId, setProfileId] = useState<any>();
const { user } = useAuth();
const openDrawer = () => {
setIsDrawerOpen(true);
@@ -22,15 +33,41 @@ export default function Portofolio() {
const closeDrawer = () => {
setIsDrawerOpen(false);
};
useFocusEffect(
useCallback(() => {
onLoadData(id as string);
onLoadUserByToken();
}, [id])
);
async function onLoadData(id: string) {
const response = await apiGetOnePortofolio({ id: id });
console.log(
"[PROFILE ID]>>",
JSON.stringify(response.data.Profile.id, null, 2)
);
setData(response.data);
}
const onLoadUserByToken = async () => {
const response = await apiUser(user?.id as string);
console.log(
"[PROFILE LOGIN]>>",
JSON.stringify(response.data?.Profile.id, null, 2)
);
setProfileId(response?.data?.Profile?.id);
};
return (
<>
<ViewWrapper>
{/* Header */}
<Stack.Screen
options={{
title: "Portofolio",
headerLeft: () => <LeftButtonCustom />,
headerRight: () => (
{/* Header */}
<Stack.Screen
options={{
title: "Portofolio",
headerLeft: () => <LeftButtonCustom />,
headerRight: () =>
data?.Profile?.id !== profileId ? null : (
<TouchableOpacity onPress={openDrawer}>
<Ionicons
name="ellipsis-vertical"
@@ -39,40 +76,44 @@ export default function Portofolio() {
/>
</TouchableOpacity>
),
headerStyle: GStyles.headerStyle,
headerTitleStyle: GStyles.headerTitleStyle,
}}
/>
<PorfofolioSection setShowDeleteAlert={setDeleteAlert} />
headerStyle: GStyles.headerStyle,
headerTitleStyle: GStyles.headerTitleStyle,
}}
/>
<ViewWrapper>
{!data || !profileId ? (
<LoaderCustom />
) : (
<StackCustom>
<Portofolio_Data
data={data}
listSubBidang={data?.Portofolio_BidangDanSubBidangBisnis as any[]}
/>
<Portofolio_BusinessLocation />
<Portofolio_SocialMediaSection
data={data?.Portofolio_MediaSosial}
/>
<Portofolio_ButtonDelete
id={id as string}
isLoadingDelete={isLoadingDelete}
setIsLoadingDelete={setIsLoadingDelete}
/>
<Spacing />
</StackCustom>
)}
</ViewWrapper>
{/* Drawer Komponen Eksternal */}
<DrawerCustom
isVisible={isDrawerOpen}
closeDrawer={closeDrawer}
height={350}
height={"auto"}
>
<Portofolio_MenuDrawerSection
drawerItems={drawerItemsPortofolio({ id: id as string })}
setIsDrawerOpen={setIsDrawerOpen}
/>
</DrawerCustom>
{/* Alert Delete */}
<AlertCustom
isVisible={deleteAlert}
onLeftPress={() => setDeleteAlert(false)}
onRightPress={() => {
setDeleteAlert(false);
console.log("Hapus portofolio");
router.back();
}}
title="Hapus Portofolio"
message="Apakah Anda yakin ingin menghapus portofolio ini?"
textLeft="Batal"
textRight="Hapus"
colorRight={MainColor.red}
/>
</>
);
}

View File

@@ -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>
);
}

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
ButtonCustom,
SelectCustom,
@@ -7,46 +6,75 @@ import {
ViewWrapper,
} from "@/components";
import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter";
import { apiProfile, apiUpdateProfile } from "@/service/api-client/api-profile";
import { IProfile } from "@/types/Type-Profile";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { StyleSheet } from "react-native";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function ProfileEdit() {
const { id } = useLocalSearchParams();
const [data, setData] = useState({
nama: "Bagas Banuna",
email: "bagasbanuna@gmail.com",
alamat: "Jember",
selectedValue: "",
});
const [data, setData] = useState<IProfile | any>();
const [isLoading, setIsLoading] = useState<boolean>(false);
const options = [
{ label: "Laki-laki", value: "laki-laki" },
{ label: "Perempuan", value: "perempuan" },
];
const handleSave = () => {
console.log({
nama: data.nama,
email: data.email,
alamat: data.alamat,
selectedValue: data.selectedValue,
});
router.back();
useEffect(() => {
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);
}
}
const handleUpdate = async () => {
try {
setIsLoading(true);
const response = await apiUpdateProfile({
id: id as string,
data,
category: "profile",
});
if (!response.success) {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
return;
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Profile berhasil diupdate",
});
return router.back();
} catch (error) {
console.log("error update profile >>", error);
} finally {
setIsLoading(false);
}
};
return (
<ViewWrapper
footerComponent={
<BoxButtonOnFooter>
<ButtonCustom
// disabled={
// !data.nama || !data.email || !data.alamat || !data.selectedValue
// }
onPress={handleSave}
>
Simpan
<ButtonCustom isLoading={isLoading} onPress={handleUpdate}>
Update
</ButtonCustom>
</BoxButtonOnFooter>
}
@@ -55,16 +83,17 @@ export default function ProfileEdit() {
<TextInputCustom
label="Nama"
placeholder="Nama"
value={data.nama}
value={data?.name}
onChangeText={(text) => {
setData({ ...data, nama: text });
setData({ ...data, name: text });
}}
required
/>
<TextInputCustom
keyboardType="email-address"
label="Email"
placeholder="Email"
value={data.email}
value={data?.email}
onChangeText={(text) => {
setData({ ...data, email: text });
}}
@@ -73,7 +102,7 @@ export default function ProfileEdit() {
<TextInputCustom
label="Alamat"
placeholder="Alamat"
value={data.alamat}
value={data?.alamat}
onChangeText={(text) => {
setData({ ...data, alamat: text });
}}
@@ -84,25 +113,12 @@ export default function ProfileEdit() {
label="Jenis Kelamin"
placeholder="Pilih jenis kelamin"
data={options}
value={data.selectedValue}
value={data?.jenisKelamin}
onChange={(value) => {
setData({ ...(data as any), selectedValue: value });
setData({ ...(data as any), jenisKelamin: value });
}}
/>
</StackCustom>
</ViewWrapper>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
padding: 20,
},
result: {
marginTop: 20,
fontSize: 16,
fontWeight: "bold",
},
});

View File

@@ -1,24 +1,32 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { LoaderCustom } from "@/components";
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
import AlertCustom from "@/components/Alert/AlertCustom";
import LeftButtonCustom from "@/components/Button/BackButton";
import DrawerCustom from "@/components/Drawer/DrawerCustom";
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 { apiUser } from "@/service/api-client/api-user";
import { GStyles } from "@/styles/global-styles";
import { IProfile } from "@/types/Type-Profile";
import { Ionicons } from "@expo/vector-icons";
import { router, Stack, useLocalSearchParams } from "expo-router";
import React, { useState } from "react";
import { Stack, useFocusEffect, useLocalSearchParams } from "expo-router";
import React, { useCallback, useState } from "react";
import { TouchableOpacity } from "react-native";
export default function Profile() {
const { id } = useLocalSearchParams();
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const [showLogoutAlert, setShowLogoutAlert] = useState(false);
const [data, setData] = useState<IProfile>();
const [dataToken, setDataToken] = useState<IProfile>();
const [listPortofolio, setListPortofolio] = useState<any[]>();
const { logout } = useAuth();
const { logout, isAdmin, user } = useAuth();
const openDrawer = () => {
setIsDrawerOpen(true);
@@ -28,21 +36,51 @@ export default function Profile() {
setIsDrawerOpen(false);
};
const handleLogout = () => {
console.log("User logout");
router.replace("/");
setShowLogoutAlert(false);
useFocusEffect(
useCallback(() => {
onLoadData(id as string);
onLoadPortofolio(id as string);
onLoadUserByToken();
isUserCheck();
}, [id])
);
const isUserCheck = () => {
const userId = id;
const userLoginId = dataToken?.id;
return userId === userLoginId;
};
const onLoadData = async (id: string) => {
const response = await apiProfile({ id: id });
setData(response.data);
};
const onLoadUserByToken = async () => {
const response = await apiUser(user?.id as string);
setDataToken(response?.data?.Profile);
};
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);
setListPortofolio(lastTwoByDate);
};
return (
<>
<ViewWrapper>
{/* Header */}
<Stack.Screen
options={{
title: "Profile",
headerLeft: () => <LeftButtonCustom />,
headerRight: () => (
<Stack.Screen
options={{
title: "Profile",
headerLeft: () => <LeftButtonCustom />,
headerRight: () =>
isUserCheck() && (
<TouchableOpacity onPress={openDrawer}>
<Ionicons
name="ellipsis-vertical"
@@ -51,37 +89,38 @@ export default function Profile() {
/>
</TouchableOpacity>
),
headerStyle: GStyles.headerStyle,
headerTitleStyle: GStyles.headerTitleStyle,
}}
/>
<ProfileSection />
headerStyle: GStyles.headerStyle,
headerTitleStyle: GStyles.headerTitleStyle,
}}
/>
{/* Main View */}
<ViewWrapper>
{!data || !dataToken ? (
<LoaderCustom />
) : (
<>
<ProfileSection data={data as any} />
<Profile_PortofolioSection
data={listPortofolio as any}
profileId={id as string}
/>
</>
)}
</ViewWrapper>
{/* Drawer Komponen Eksternal */}
<DrawerCustom
height={350}
height={"auto"}
isVisible={isDrawerOpen}
closeDrawer={closeDrawer}
>
<Profile_MenuDrawerSection
drawerItems={drawerItemsProfile({ id: id as string })}
setShowLogoutAlert={setShowLogoutAlert}
drawerItems={drawerItemsProfile({ id: id as string, isAdmin })}
setIsDrawerOpen={setIsDrawerOpen}
logout={logout}
/>
</DrawerCustom>
{/* Alert Komponen Eksternal */}
<AlertCustom
isVisible={showLogoutAlert}
onLeftPress={() => setShowLogoutAlert(false)}
onRightPress={handleLogout}
title="Apakah anda yakin ingin keluar?"
textLeft="Batal"
textRight="Keluar"
colorRight={MainColor.red}
/>
</>
);
}

View File

@@ -5,40 +5,142 @@ 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 { useAuth } from "@/hooks/use-auth";
import { apiFileDelete } from "@/service/api-client/api-file";
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);
const { token } = useAuth();
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_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;
}
if (data?.imageBackgroundId) {
const deletePrevFile = await apiFileDelete({
token: token as string,
id: data?.imageBackgroundId as string,
});
if (!deletePrevFile.success) {
console.log("error delete prev file >>", deletePrevFile.message);
}
}
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>

View File

@@ -1,47 +1,148 @@
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";
import { useAuth } from "@/hooks/use-auth";
import { apiFileDelete } from "@/service/api-client/api-file";
export default function UpdatePhotoProfile() {
const { id } = useLocalSearchParams();
const [data, setData] = useState<IProfile>();
const [imageUri, setImageUri] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const { token } = useAuth();
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,
});
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;
}
if (data?.imageId) {
const deletePrevFile = await apiFileDelete({
token: token as string,
id: data?.imageId as string,
});
if (!deletePrevFile.success) {
console.log("error delete prev file >>", deletePrevFile.message);
}
}
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>
);
}

View File

@@ -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 { 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 { View } from "react-native";
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({
@@ -31,6 +38,10 @@ export default function CreateProfile() {
});
const handlerSave = async () => {
let IMG = {
imageId: "",
imageBackgroundId: "",
};
if (!data.name || !data.email || !data.alamat || !data.jenisKelamin) {
Toast.show({
type: "info",
@@ -42,9 +53,67 @@ export default function CreateProfile() {
try {
setIsLoading(true);
const response = await apiCreateProfile(data);
console.log("data create profile >>", JSON.stringify(response, null, 2));
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",
@@ -56,12 +125,18 @@ export default function CreateProfile() {
Toast.show({
type: "success",
text1: "Success",
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);
}
@@ -84,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>
@@ -98,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>

View File

@@ -1,5 +1,5 @@
import {
AvatarCustom,
AvatarComp,
ClickableCustom,
Grid,
Spacing,
@@ -10,39 +10,42 @@ import {
} from "@/components";
import { MainColor } from "@/constants/color-palet";
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
import { apiAllUser } from "@/service/api-client/api-user";
import { Ionicons } from "@expo/vector-icons";
import { router } from "expo-router";
import _ from "lodash";
import { useEffect, useState } from "react";
export default function UserSearch() {
function generateRandomPhoneNumber(index: number) {
let prefix;
const [data, setData] = useState<any[]>([]);
const [search, setSearch] = useState<string>("");
// Menentukan prefix berdasarkan index genap atau ganjil
if (index % 2 === 0) {
const evenPrefixes = ["6288", "6289", "6281"];
prefix = evenPrefixes[Math.floor(Math.random() * evenPrefixes.length)];
} else {
const oddPrefixes = ["6285", "6283"];
prefix = oddPrefixes[Math.floor(Math.random() * oddPrefixes.length)];
useEffect(() => {
onLoadData(search);
}, [search]);
const onLoadData = async (search: string) => {
try {
const response = await apiAllUser({ search: search });
console.log("[DATA USER] >", JSON.stringify(response.data, null, 2));
setData(response.data);
} catch (error) {
console.log("Error fetching data", error);
}
};
// Menghitung panjang sisa nomor acak (antara 10 - 12 digit)
const remainingLength = Math.floor(Math.random() * 3) + 10; // 10, 11, atau 12
const handleSearch = (search: string) => {
setSearch(search);
onLoadData(search);
};
// Membuat sisa nomor acak
let randomNumber = "";
for (let i = 0; i < remainingLength; i++) {
randomNumber += Math.floor(Math.random() * 10); // Digit acak antara 0-9
}
// Menggabungkan prefix dan sisa nomor
return prefix + randomNumber;
}
return (
<>
<ViewWrapper
headerComponent={
<TextInputCustom
value={search}
onChangeText={handleSearch}
iconLeft={
<Ionicons
name="search"
@@ -57,41 +60,46 @@ export default function UserSearch() {
}
>
<StackCustom>
{Array.from({ length: 20 }).map((e, index) => {
return (
<Grid key={index}>
<Grid.Col span={2}>
<AvatarCustom href={`/profile/${index}`}/>
</Grid.Col>
<Grid.Col span={9}>
<TextCustom size="large">Nama user {index}</TextCustom>
<TextCustom size="small">
+{generateRandomPhoneNumber(index)}
</TextCustom>
</Grid.Col>
<Grid.Col
span={1}
style={{
justifyContent: "center",
alignItems: "flex-end",
{!_.isEmpty(data) ? (
data?.map((e, index) => {
return (
<ClickableCustom
key={index}
onPress={() => {
console.log("Ke Profile");
router.push(`/profile/${e?.Profile?.id}`);
}}
>
<ClickableCustom
onPress={() => {
console.log("Ke Profile");
router.push(`/profile/${index}`);
}}
>
<Ionicons
name="chevron-forward"
size={ICON_SIZE_SMALL}
color={MainColor.white}
/>
</ClickableCustom>
</Grid.Col>
</Grid>
);
})}
<Grid>
<Grid.Col span={2}>
<AvatarComp fileId={e?.Profile?.imageId} size="base" />
</Grid.Col>
<Grid.Col span={9}>
<StackCustom gap={"sm"}>
<TextCustom size="large">{e?.username}</TextCustom>
<TextCustom size="small">+{e?.nomor}</TextCustom>
</StackCustom>
</Grid.Col>
<Grid.Col
span={1}
style={{
justifyContent: "center",
alignItems: "flex-end",
}}
>
<Ionicons
name="chevron-forward"
size={ICON_SIZE_SMALL}
color={MainColor.white}
/>
</Grid.Col>
</Grid>
</ClickableCustom>
);
})
) : (
<TextCustom align="center">Tidak ditemukan</TextCustom>
)}
</StackCustom>
<Spacing height={50} />
</ViewWrapper>

View File

@@ -221,7 +221,7 @@ export default function AdminLayout() {
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
router.replace(`/(application)/(user)/profile/${123}`);
router.replace(`/(application)/(user)/home`);
},
});
} else if (item.value === "logout") {

View 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>
);
}

View File

@@ -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>
);
};

View 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>
</>
);
}

View 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/",
};

View 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>
);
}

View 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 default 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",
});
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -9,11 +9,13 @@ export default function ActionIcon({
onPress,
icon,
size = "md",
disabled = false,
}: {
href?: Href;
onPress?: () => void;
icon: React.ReactNode;
size?: SizeType;
disabled?: boolean;
}) {
const sizeMap = {
xs: 22,
@@ -25,7 +27,7 @@ export default function ActionIcon({
const getSize = (size: SizeType): DimensionValue => {
if (!size) return sizeMap.md; // Default to 'md' if size is undefined
if (typeof size === 'string' && size in sizeMap) {
if (typeof size === "string" && size in sizeMap) {
return sizeMap[size as keyof typeof sizeMap];
}
return size as DimensionValue;
@@ -35,9 +37,10 @@ export default function ActionIcon({
return (
<TouchableOpacity
disabled={disabled}
activeOpacity={0.7}
style={{
backgroundColor: MainColor.yellow,
backgroundColor: disabled ? MainColor.disabled : MainColor.yellow,
padding: 5,
borderRadius: 50,
alignItems: "center",
@@ -46,6 +49,7 @@ export default function ActionIcon({
height: iconSize,
}}
onPress={() => {
if (disabled) return;
if (href) {
router.push(href);
} else {

View File

@@ -61,7 +61,7 @@ const ButtonCustom: React.FC<ButtonProps> = ({
activeOpacity={0.8}
>
{/* Render icon jika tersedia */}
{iconLeft && iconLeft}
{isLoading ? "" : iconLeft && iconLeft}
{isLoading ? (
<ActivityIndicator size={18} color={MainColor.darkblue} />
) : (

View File

@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// DateTimeInput.tsx
import { MainColor } from "@/constants/color-palet";
import { GStyles } from "@/styles/global-styles";
@@ -119,7 +119,7 @@ const DateTimeInput_Android: React.FC<DateTimeInputProps> = ({
<Ionicons
name="calendar-outline"
size={20}
color={MainColor.placeholder}
color={disabled ? MainColor.white_gray : MainColor.placeholder}
/>
</View>
@@ -131,8 +131,8 @@ const DateTimeInput_Android: React.FC<DateTimeInputProps> = ({
}}
>
<Grid.Col span={6} style={{}}>
<Pressable onPress={toggleDatePicker}>
<TextCustom color="gray">
<Pressable onPress={() => !disabled && toggleDatePicker()}>
<TextCustom color={disabled ? "default" : "gray"}>
{selectedDate ? (
<TextCustom color="black">
{selectedDate.toLocaleDateString()}
@@ -148,8 +148,8 @@ const DateTimeInput_Android: React.FC<DateTimeInputProps> = ({
</Grid.Col>
<Grid.Col span={5} style={{}}>
<Pressable onPress={toggleTimePicker}>
<TextCustom color="gray">
<Pressable onPress={() => !disabled && toggleTimePicker()}>
<TextCustom color={disabled ? "default" : "gray"}>
{selectedTime ? (
<TextCustom color="black">
{selectedTime.toLocaleTimeString("id-ID", {

View File

@@ -3,24 +3,19 @@ import { MainColor } from "@/constants/color-palet";
import { GStyles } from "@/styles/global-styles";
import { Ionicons } from "@expo/vector-icons";
import DateTimePicker, {
DateTimePickerEvent,
DateTimePickerEvent,
} from "@react-native-community/datetimepicker";
import dayjs from "dayjs";
import React, { useState } from "react";
import {
StyleProp,
Text,
View,
ViewStyle
} from "react-native";
import { StyleProp, Text, View, ViewStyle } from "react-native";
import ClickableCustom from "../Clickable/ClickableCustom";
import TextCustom from "../Text/TextCustom";
interface DateTimeInputProps {
// Main
value?: DateTimePickerEvent;
value?: DateTimePickerEvent | Date | null;
mode?: "date" | "time";
onChange: (selectedDate: DateTimePickerEvent) => void;
onChange: (selectedDate: DateTimePickerEvent | Date | null) => void;
maximumDate?: Date;
minimumDate?: Date;
// Main
@@ -74,7 +69,7 @@ const DateTimeInput_IOS: React.FC<DateTimeInputProps> = ({
<ClickableCustom
activeOpacity={0.8}
style={[GStyles.inputContainerArea, containerStyle]}
onPress={handlePress}
onPress={() => !disabled && handlePress()}
>
{label && (
<Text style={GStyles.inputLabel}>
@@ -95,11 +90,11 @@ const DateTimeInput_IOS: React.FC<DateTimeInputProps> = ({
<Ionicons
name="calendar-outline"
size={20}
color={MainColor.placeholder}
color={disabled ? MainColor.white : MainColor.placeholder}
/>
</View>
<TextCustom color="gray">
<TextCustom color={disabled ? "default" : "gray"}>
{selectedDate ? (
<TextCustom color="black">
{dayjs(selectedDate).format("DD-MM-YYYY HH:mm")}

View File

@@ -1,19 +1,17 @@
import {
DateTimePickerEvent,
} from "@react-native-community/datetimepicker";
import { DateTimePickerEvent } from "@react-native-community/datetimepicker";
import React from "react";
import { Platform } from "react-native";
import DateTimeInput_Android from "./DataTimeAndroid";
import DateTimeInput_IOS from "./DateTimeIOS";
type Props = {
value?: Date;
value?: Date | DateTimePickerEvent | null;
onChange?: (date: Date) => void;
label?: string;
required?: boolean;
maximumDate?: Date;
minimumDate?: Date;
disabled?: boolean;
};
const DateTimePickerCustom: React.FC<Props> = ({
@@ -23,18 +21,21 @@ const DateTimePickerCustom: React.FC<Props> = ({
required,
maximumDate,
minimumDate,
disabled = false,
}) => {
return (
<>
{Platform.OS === "ios" ? (
<DateTimeInput_IOS
label={label}
onChange={(date: DateTimePickerEvent) => {
onChange={(date: DateTimePickerEvent | Date | null) => {
onChange?.(date as any);
}}
required={required}
maximumDate={maximumDate}
minimumDate={minimumDate}
disabled={disabled}
value={value as DateTimePickerEvent | Date | null}
/>
) : (
<DateTimeInput_Android
@@ -45,6 +46,7 @@ const DateTimePickerCustom: React.FC<Props> = ({
required={required}
maximumDate={maximumDate}
minimumDate={minimumDate}
disabled={disabled}
/>
)}
</>

View 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()
)}
</>
);
}

View File

@@ -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 = {

View File

@@ -0,0 +1,8 @@
import { MainColor } from "@/constants/color-palet";
import { ActivityIndicator } from "react-native";
export default function LoaderCustom({ size }: { size?: "small" | "large" }) {
return (
<ActivityIndicator size={size ? size : "small"} color={MainColor.yellow} />
);
}

View File

@@ -6,8 +6,8 @@ export default function IconEdit({
size,
color,
}: {
size: number;
color: string;
size?: number;
color?: string;
}) {
return (
<>

View File

@@ -24,4 +24,5 @@ interface IMenuDrawerItem {
label: string;
path?: string;
color?: string;
value?: string;
}

View File

@@ -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";
@@ -60,6 +61,8 @@ import DummyLandscapeImage from "./_ShareComponent/DummyLandscapeImage";
import GridComponentView from "./_ShareComponent/GridSectionView";
// Progress
import ProgressCustom from "./Progress/ProgressCustom";
// Loader
import LoaderCustom from "./Loader/LoaderCustom";
export {
// ActionIcon
@@ -69,6 +72,7 @@ export {
AlertDefaultSystem,
// Image
AvatarCustom,
AvatarComp,
// ShareComponent
AvatarUsernameAndOtherComponent,
// Button
@@ -126,4 +130,6 @@ export {
TextInputCustom,
// ViewWrapper
ViewWrapper,
// Loader
LoaderCustom,
};

View 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
View 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;

View File

@@ -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;

View File

@@ -92,7 +92,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
await AsyncStorage.setItem("authToken", token);
const responseUser = await apiConfig.get(
`/mobile/user?token=${token}`,
`/mobile?token=${token}`,
{
headers: {
Authorization: `Bearer ${token}`,

View File

@@ -98,7 +98,7 @@ export default function LoginView() {
}
if (token && !isAdmin) {
return <Redirect href={"/(application)/(user)/home"} />;
return <Redirect href={"/(application)/(user)/event/(tabs)"} />;
}
if (token && isAdmin) {
@@ -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>

View File

@@ -14,7 +14,6 @@ import Toast from "react-native-toast-message";
export default function RegisterView() {
const { nomor } = useLocalSearchParams();
const [username, setUsername] = useState("");
// const [loading, setLoading] = useState(false);
const { registerUser, isLoading } = useAuth();
@@ -22,16 +21,22 @@ export default function RegisterView() {
if (!nomor) {
Toast.show({
type: "error",
text1: "Gagal",
text2: "Nomor tidak ditemukan",
text1: "Lengkapi nomor",
});
return false;
}
if (!username) {
Toast.show({
type: "error",
text1: "Gagal",
text2: "Username tidak boleh kosong",
text1: "Username tidak boleh kosong",
});
return false;
}
if (username.includes(" ")) {
Toast.show({
type: "info",
text1: "Username tidak boleh mengandung spasi",
});
return false;
}
@@ -42,9 +47,20 @@ export default function RegisterView() {
const isValid = validasiData();
if (!isValid) return;
if (username.length < 5) {
Toast.show({
type: "info",
text1: "Info",
text2: "Username minimal 5 karakter",
});
return;
}
const usernameLower = username.toLowerCase();
await registerUser({
nomor: nomor as string,
username: username,
username: usernameLower,
});
}
@@ -73,6 +89,11 @@ export default function RegisterView() {
placeholder="Masukkan username"
value={username}
onChangeText={(text) => setUsername(text)}
error={
username.includes(" ")
? "Username tidak boleh mengandung spasi"
: ""
}
/>
<ButtonCustom isLoading={isLoading} onPress={handleRegister}>

View File

@@ -29,6 +29,7 @@ export default function VerificationView() {
async function onLoadCheckCodeOtp() {
const kodeId = await AsyncStorage.getItem("kode_otp");
const response = await apiCheckCodeOtp({ kodeId: kodeId as string });
console.log("Response check code otp >>", JSON.stringify(response.otp, null, 2));
setCodeOtp(response.otp);
setUserNumber(response.nomor);
}

View File

@@ -1,28 +1,138 @@
import { ButtonCustom, Grid } from "@/components";
import { View } from "react-native";
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
import { apiEventUpdateStatus } from "@/service/api-client/api-event";
import { router } from "expo-router";
import Toast from "react-native-toast-message";
export default function Event_ButtonStatusSection({
id,
status,
onOpenAlert,
onOpenDeleteAlert,
}: {
id: string;
status: string;
onOpenAlert: (value: boolean) => void;
onOpenDeleteAlert: (value: boolean) => void;
}) {
const handleBatalkanReview = () => {
AlertDefaultSystem({
title: "Batalkan Review",
message: "Apakah Anda yakin ingin batalkan review ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: async () => {
try {
const response = await apiEventUpdateStatus({
id: id,
status: "draft",
});
const handleOpenAlert = () => {
onOpenAlert(true);
if (response.success) {
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} else {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
router.back();
}
} catch (error) {
console.log("[ERROR]", error);
}
},
});
};
const handleAjukanReview = () => {
AlertDefaultSystem({
title: "Ajukan Review",
message: "Apakah Anda yakin ingin ajukan review ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: async () => {
try {
const response = await apiEventUpdateStatus({
id: id,
status: "review",
});
if (response.success) {
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} else {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
router.back();
}
} catch (error) {
console.log("[ERROR]", error);
}
},
});
};
const handleEditKembali = () => {
AlertDefaultSystem({
title: "Edit Kembali",
message: "Apakah Anda yakin ingin edit kembali ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: async () => {
try {
const response = await apiEventUpdateStatus({
id: id,
status: "draft",
});
if (response.success) {
Toast.show({
type: "success",
text1: response.message,
});
router.back();
} else {
Toast.show({
type: "info",
text1: "Info",
text2: response.message,
});
router.back();
}
} catch (error) {
console.log("[ERROR]", error);
}
},
});
};
const handleOpenDeleteAlert = () => {
onOpenDeleteAlert(true);
AlertDefaultSystem({
title: "Hapus",
message: "Apakah Anda yakin ingin menghapus data ini?",
textLeft: "Batal",
textRight: "Hapus",
onPressRight: () => {
console.log("Hapus");
router.back();
},
});
};
const DeleteButton = () => {
return (
<>
<ButtonCustom backgroundColor="red" textColor="white" onPress={handleOpenDeleteAlert}>
<ButtonCustom
backgroundColor="red"
textColor="white"
onPress={handleOpenDeleteAlert}
>
Hapus
</ButtonCustom>
</>
@@ -35,7 +145,7 @@ export default function Event_ButtonStatusSection({
case "review":
return (
<ButtonCustom onPress={handleOpenAlert}>
<ButtonCustom onPress={handleBatalkanReview}>
Batalkan Review
</ButtonCustom>
);
@@ -44,13 +154,14 @@ export default function Event_ButtonStatusSection({
return (
<>
<Grid>
<Grid.Col span={5}>
<ButtonCustom onPress={handleOpenAlert}>Ajukan Review</ButtonCustom>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleAjukanReview}>
Ajukan Review
</ButtonCustom>
</Grid.Col>
<Grid.Col span={2}>
<View />
<Grid.Col span={6} style={{ paddingLeft: 10 }}>
{DeleteButton()}
</Grid.Col>
<Grid.Col span={5}>{DeleteButton()}</Grid.Col>
</Grid>
</>
);
@@ -59,13 +170,14 @@ export default function Event_ButtonStatusSection({
return (
<>
<Grid>
<Grid.Col span={5}>
<ButtonCustom onPress={handleOpenAlert}>Edit Kembali</ButtonCustom>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleEditKembali}>
Edit Kembali
</ButtonCustom>
</Grid.Col>
<Grid.Col span={2}>
<View />
<Grid.Col span={6} style={{ paddingLeft: 10 }}>
{DeleteButton()}
</Grid.Col>
<Grid.Col span={5}>{DeleteButton()}</Grid.Col>
</Grid>
</>
);

View File

@@ -1,6 +1,6 @@
import { ITabs } from "@/components/_Interface/types";
export const tabsHome: ITabs[] = [
export const tabsHome: any = (profileId: string) => [
{
id: "forum",
icon: "chatbubble-ellipses-outline",
@@ -33,8 +33,8 @@ export const tabsHome: ITabs[] = [
icon: "person-outline",
activeIcon: "person",
label: "Profile",
path: "/profile/id-percoban-123456",
path: `/profile/${profileId}`,
isActive: true,
disabled: false,
},
];
];

View 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>
</>
);
}

View File

@@ -0,0 +1,132 @@
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[];
isLoadingCreate: boolean;
setIsLoadingCreate: (value: boolean) => void;
}
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,
isLoadingCreate,
setIsLoadingCreate,
}: Props) {
const validaasiData = () => {
if (
!data.namaBisnis ||
!data.masterBidangBisnisId ||
!data.alamatKantor ||
!data.tlpn ||
!data.deskripsi ||
subBidangSelected.map((item) => item.id).includes("") ||
subBidangSelected.map((item) => item.id).includes(null)
) {
return false;
}
return true;
};
const handleCreatePortofolio = async () => {
console.log(
"Data sub bidang >>",
JSON.stringify(subBidangSelected, null, 2)
);
if (!validaasiData()) {
Toast.show({
type: "info",
text1: "Info",
text2: "Harap lengkapi data",
});
return;
}
try {
setIsLoadingCreate(true);
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,
};
const response = await apiPortofolioCreate({
data: newData,
});
console.log("Response >>", JSON.stringify(response, null, 2));
// return router.replace(`/maps/create`);
// return router.push(`/maps/create`);
Toast.show({
type: "success",
text1: "Sukses",
text2: "Data berhasil disimpan",
});
return router.back();
} catch (error) {
Toast.show({
type: "error",
text1: "Error",
text2: error as string,
});
} finally {
setIsLoadingCreate(false);
}
};
return (
<BoxButtonOnFooter>
<ButtonCustom
isLoading={isLoadingCreate}
onPress={handleCreatePortofolio}
>
Selanjutnya
</ButtonCustom>
</BoxButtonOnFooter>
);
}

View File

@@ -1,17 +1,53 @@
import { ButtonCustom } from "@/components";
import { AlertDefaultSystem, ButtonCustom } from "@/components";
import { MainColor } from "@/constants/color-palet";
import { Ionicons } from "@expo/vector-icons";
import { apiDeletePortofolio } from "@/service/api-client/api-portofolio";
import { router } from "expo-router";
export default function Portofolio_ButtonDelete({
setShowDeleteAlert,
id,
isLoadingDelete,
setIsLoadingDelete,
}: {
setShowDeleteAlert: (value: boolean) => void;
id: string;
isLoadingDelete: boolean;
setIsLoadingDelete: (value: boolean) => void;
}) {
const handleDelete = () => {
setShowDeleteAlert(true);
const handleDelete = async () => {
AlertDefaultSystem({
title: "Hapus Portofolio",
message: "Yakin ingin menghapus portofolio ini?",
textLeft: "Batal",
textRight: "Hapus",
onPressRight: async () => {
try {
setIsLoadingDelete(true);
const response = await apiDeletePortofolio({ id: id });
console.log("Response portofolio >>", response);
if (response.success) {
console.log("Portofolio berhasil dihapus");
router.back();
}
console.log("Gagal dihapus >>", response);
} catch (error) {
console.log("Error delete portofolio >>", error);
} finally {
setIsLoadingDelete(false);
}
},
})
};
return (
<ButtonCustom textColor={MainColor.white} iconLeft={<Ionicons name="trash-outline" size={20} color="white" />} onPress={handleDelete} backgroundColor={MainColor.red}>
<ButtonCustom
isLoading={isLoadingDelete}
textColor={MainColor.white}
iconLeft={<Ionicons name="trash-outline" size={20} color="white" />}
onPress={handleDelete}
backgroundColor={MainColor.red}
>
Hapus
</ButtonCustom>
);

View File

@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
AvatarComp,
AvatarCustom,
BaseBox,
CenterCustom,
@@ -10,11 +12,18 @@ 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,
listSubBidang,
}: {
data: any;
listSubBidang: any[];
}) {
const { id } = useLocalSearchParams();
const listData = [
@@ -22,60 +31,65 @@ 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",
// },
// ];
// console.log("List Sub Bidang >>", JSON.stringify(listSubBidang, null, 2));
return (
<>
@@ -86,7 +100,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 +122,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>
@@ -126,14 +146,18 @@ export default function Portofolio_Data() {
</Grid>
))}
<View style={{ paddingLeft: 10 }}>
{listSubBidang.map((item, index) => (
{listSubBidang?.map((item, index) => (
<Grid key={index}>
<Grid.Col span={2} style={{ alignItems: "center" }}>
{item.icon}
<Ionicons
name="chevron-forward-outline"
size={ICON_SIZE_SMALL}
color="white"
/>
</Grid.Col>
<Grid.Col span={10}>
<TextCustom style={{ paddingLeft: 5 }}>
{item.label}
{item?.MasterSubBidangBisnis?.name || "-"}
</TextCustom>
</Grid.Col>
</Grid>
@@ -160,10 +184,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>

View File

@@ -21,7 +21,7 @@ export default function Portofolio_MenuDrawerSection({
<MenuDrawerDynamicGrid
data={drawerItems}
columns={4} // Ubah ke 2 jika ingin 2 kolom per baris
onPressItem={handlePress}
onPressItem={handlePress as any}
/>
</>
);

View File

@@ -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>
);
}

View File

@@ -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"

View File

@@ -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";
@@ -22,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>
);

View File

@@ -5,85 +5,139 @@ import { Ionicons } from "@expo/vector-icons";
export const drawerItemsProfile = ({
id,
isAdmin,
}: {
id: string;
}): IMenuDrawerItem[] => [
{
icon: (
<Ionicons
name="create"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Edit profile",
path: `/(application)/profile/${id}/edit`,
},
{
icon: (
<Ionicons
name="camera"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah foto profile",
path: `/(application)/profile/${id}/update-photo`,
},
{
icon: (
<Ionicons
name="image"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah latar belakang",
path: `/(application)/profile/${id}/update-background`,
},
{
icon: (
<Ionicons
name="add-circle"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Tambah portofolio",
path: `/(application)/portofolio/${id}/create`,
},
{
icon: (
<Ionicons
name="settings"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Dashboard Admin",
path: `/(application)/admin/dashboard`,
},
{
icon: (
<Ionicons
name="log-out"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Keluar",
color: MainColor.red,
path: "",
},
{
icon: (
<Ionicons
name="create-outline"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Create profile",
path: `/(application)/profile/${id}/create`,
},
];
isAdmin: boolean;
}) => {
const adminItems: IMenuDrawerItem[] = [
{
icon: (
<Ionicons
name="create"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Edit profile",
path: `/(application)/profile/${id}/edit`,
},
{
icon: (
<Ionicons
name="camera"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah foto profile",
path: `/(application)/profile/${id}/update-photo`,
},
{
icon: (
<Ionicons
name="image"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah latar belakang",
path: `/(application)/profile/${id}/update-background`,
},
{
icon: (
<Ionicons
name="add-circle"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Tambah portofolio",
path: `/(application)/portofolio/${id}/create`,
},
{
icon: (
<Ionicons
name="settings"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Dashboard Admin",
path: `/(application)/admin/dashboard`,
},
{
icon: (
<Ionicons
name="log-out"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Keluar",
color: MainColor.red,
path: "",
},
];
const userItems: IMenuDrawerItem[] = [
{
icon: (
<Ionicons
name="create"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Edit profile",
path: `/(application)/profile/${id}/edit`,
},
{
icon: (
<Ionicons
name="camera"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah foto profile",
path: `/(application)/profile/${id}/update-photo`,
},
{
icon: (
<Ionicons
name="image"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Ubah latar belakang",
path: `/(application)/profile/${id}/update-background`,
},
{
icon: (
<Ionicons
name="add-circle"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Tambah portofolio",
path: `/(application)/portofolio/${id}/create`,
},
{
icon: (
<Ionicons
name="log-out"
size={ICON_SIZE_MEDIUM}
color={AccentColor.white}
/>
),
label: "Keluar",
color: MainColor.red,
path: "",
},
];
return isAdmin ? adminItems : userItems;
};

View 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>
</>
);
}

View File

@@ -1,26 +1,24 @@
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";
export default function ProfileSection() {
const { id } = useLocalSearchParams();
export default function ProfileSection({ data }: { data: IProfile }) {
const listData = [
{
icon: (
<Ionicons name="call-outline" size={ICON_SIZE_SMALL} color="white" />
),
label: "+6282340374412",
label: `+${data && data.User.nomor ? data.User.nomor : "-"}`,
},
{
icon: (
<Ionicons name="mail-outline" size={ICON_SIZE_SMALL} color="white" />
),
label: "bagasbanuna@gmail.com",
label: `${data && data.email ? data.email : "-"}`,
},
{
icon: (
@@ -30,28 +28,35 @@ export default function ProfileSection() {
color="white"
/>
),
label: "Jalan Raya Sesetan No. 123, Bandung, Indonesia",
label: `${data && data.alamat ? data.alamat : "-"}`,
},
{
icon: (
<FontAwesome5 name="transgender" size={ICON_SIZE_SMALL} color="white" />
),
label: "Laki-laki",
label: `${
data && data.jenisKelamin ? _.startCase(data.jenisKelamin) : "-"
}`,
},
];
return (
<>
<BaseBox>
<AvatarAndBackground backgroundId="test-background-id" imageId="test-image-id" />
<AvatarAndBackground
backgroundId={data?.imageBackgroundId as any}
imageId={data?.imageId as any}
/>
<Spacing height={50} />
<View style={{ alignItems: "center" }}>
<TextCustom bold size="large" align="center">
Nama User
{data && data.name ? data.name : "-"}
</TextCustom>
<Spacing height={5} />
<TextCustom size="small">@Username</TextCustom>
<TextCustom size="small">
@{data && data.User.username ? data.User.username : "-"}
</TextCustom>
</View>
<Spacing height={30} />
@@ -73,57 +78,7 @@ export default function ProfileSection() {
))}
</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>
</>
);
}

View File

@@ -5,12 +5,10 @@ import { router } from "expo-router";
export default function Profile_MenuDrawerSection({
drawerItems,
setShowLogoutAlert,
setIsDrawerOpen,
logout,
}: {
drawerItems: IMenuDrawerItem[];
setShowLogoutAlert: (value: boolean) => void;
setIsDrawerOpen: (value: boolean) => void;
logout: () => Promise<void>;
}) {

View File

@@ -0,0 +1,64 @@
import { apiConfig } from "../api-config";
export async function apiEventCreate(data: any) {
try {
const response = await apiConfig.post(`/mobile/event`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetByStatus({
id,
status,
}: {
id: string;
status: string;
}) {
try {
const response = await apiConfig.get(`/mobile/event/${id}/${status}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetOne({ id }: { id: string }) {
try {
const response = await apiConfig.get(`/mobile/event/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventUpdateStatus({
id,
status,
}: {
id: string;
status: "draft" | "review" | "publish" | "reject";
}) {
try {
const response = await apiConfig.put(`/mobile/event/${id}/${status}`);
console.log("[SUCCESS]", response.data);
return response.data;
} catch (error) {
// console.log("[ERROR FECTH]", error);
throw error;
}
}
export async function apiEventUpdateData({ id, data }: { id: string; data: any }) {
try {
const response = await apiConfig.put(`/mobile/event/${id}`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}

View File

@@ -0,0 +1,45 @@
import axios from "axios";
import { API_BASE_URL } from "../api-config";
const url = `${API_BASE_URL}/mobile/file`;
export async function apiFileUpload({
token,
formData,
}: {
token: string;
formData: FormData;
}) {
try {
const response = await axios.post(url, formData, {
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,
},
// timeout: 30000,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiFileDelete({
token,
id,
}: {
token: string;
id: string;
}) {
try {
const response = await axios.delete(`${url}/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
// timeout: 30000,
});
return response.data;
} catch (error) {
throw error;
}
}

View File

@@ -0,0 +1,31 @@
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 selectBidangId = id ? `/${id}` : "";
const response = await apiConfig.get(
`/master/sub-bidang-bisnis${selectBidangId}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiMasterEventType() {
try {
const response = await apiConfig.get(`/mobile/master/event-type`);
return response.data;
} catch (error) {
throw error;
}
}

View File

@@ -0,0 +1,66 @@
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;
}
}
export async function apiDeletePortofolio({ id }: { id: string }) {
try {
const response = await apiConfig.delete(`/mobile/portofolio/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiUpdatePortofolio({
id,
data,
category,
}: {
id: string;
data: any;
category: "detail" | "medsos" | "logo";
}) {
try {
const response = await apiConfig.put(
`/mobile/portofolio/${id}?category=${category}`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}

View File

@@ -4,5 +4,25 @@ export async function apiCreateProfile(data: any) {
const response = await apiConfig.post(`/mobile/profile`, {
data: data,
});
return response;
return response.data;
}
export async function apiProfile({ id }: { id: string }) {
const response = await apiConfig.get(`/mobile/profile/${id}`);
return response.data;
}
export async function apiUpdateProfile({
id,
data,
category,
}: {
id: string;
data: any;
category: "profile" | "photo" | "background";
}) {
const response = await apiConfig.put(`/mobile/profile/${id}?category=${category}`, {
data: data,
});
return response.data;
}

View File

@@ -1,7 +1,12 @@
import { apiConfig } from "../api-config";
export async function apiUser(id: string) {
const response = await apiConfig.get(`/user/${id}`);
const response = await apiConfig.get(`/mobile/user/${id}`);
return response.data;
}
}
export async function apiAllUser({ search }: { search: string }) {
const response = await apiConfig.get(`/mobile/user?search=${search}`);
return response.data;
}

View 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;
}

View File

@@ -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,
@@ -10,6 +10,7 @@ export const apiConfig: AxiosInstance = axios.create({
apiConfig.interceptors.request.use(
async (config) => {
console.log("API_BASE_URL >>", API_BASE_URL);
const token = await AsyncStorage.getItem("authToken");
if (token) {
// config.timeout = 10000;
@@ -28,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;
}

51
service/upload-service.ts Normal file
View File

@@ -0,0 +1,51 @@
import { API_BASE_URL } from "@/service/api-config";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { apiFileUpload } from "./api-client/api-file";
export async function uploadImageService({
dirId,
imageUri,
}: {
dirId: string;
imageUri: string | null;
}) {
const token = await AsyncStorage.getItem("authToken");
const url = `${API_BASE_URL}/mobile/file`;
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 apiFileUpload({
token: token as string,
formData,
});
console.log("Response upload file >>", JSON.stringify(response, null, 2));
if (!response.success) {
throw new Error(response.message);
}
return response;
} catch (error) {
throw error;
}
}

18
types/Type-Master.ts Normal file
View File

@@ -0,0 +1,18 @@
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;
masterBidangBisnisId: string;
}

16
types/Type-Profile.ts Normal file
View File

@@ -0,0 +1,16 @@
import { IUser } from "./User";
export interface IProfile {
id?: string;
name?: string;
email?: string;
alamat?: string;
jenisKelamin?: string;
active?: boolean;
createdAt?: string;
updatedAt?: string;
userId?: string;
imageId?: string | null;
imageBackgroundId?: string | null;
User: IUser
}

View File

@@ -6,12 +6,12 @@ export interface IMasterUserRole {
}
export interface IUser {
id: string;
username: string;
nomor: string;
active: boolean;
createdAt: string | null;
updatedAt: string | null;
masterUserRoleId: string;
MasterUserRole: IMasterUserRole;
id?: string;
username?: string;
nomor?: string;
active?: boolean;
createdAt?: string | null;
updatedAt?: string | null;
masterUserRoleId?: string;
MasterUserRole?: IMasterUserRole;
}

12
utils/dateTimeView.ts Normal file
View File

@@ -0,0 +1,12 @@
import dayjs from "dayjs";
export const dateTimeView = ({
date,
withoutTime = false,
}: {
date: any;
withoutTime?: boolean;
}) => {
const newDate = dayjs(date).format(`DD-MM-YYYY, ${withoutTime ? "" : "HH:mm"}`);
return newDate;
};

53
utils/pickImage.ts Normal file
View 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);
}