diff --git a/app/(application)/(user)/event/(tabs)/status.tsx b/app/(application)/(user)/event/(tabs)/status.tsx index 1605185..e1c823d 100644 --- a/app/(application)/(user)/event/(tabs)/status.tsx +++ b/app/(application)/(user)/event/(tabs)/status.tsx @@ -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( "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 = ( ({ id: i, @@ -34,30 +64,36 @@ export default function EventStatus() { ); return ( - - - - - - - Lorem ipsum,{" "} - {activeCategory} dolor - sit amet consectetur adipisicing elit. - - - - {new Date().toLocaleDateString()} - - + + {loadingGetData ? ( + + ) : _.isEmpty(listData) ? ( + Tidak ada data {activeCategory} + ) : ( + listData.map((item: any, i) => ( + + + + + + {item?.title} + + + + + {new Date(item?.tanggal).toLocaleDateString()} + + + - - 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! - - - + {item?.deskripsi} + + + )) + )} ); } diff --git a/app/(application)/(user)/event/[id]/[status]/detail-event.tsx b/app/(application)/(user)/event/[id]/[status]/detail-event.tsx index 3a6f7e7..f84cb03 100644 --- a/app/(application)/(user)/event/[id]/[status]/detail-event.tsx +++ b/app/(application)/(user)/event/[id]/[status]/detail-event.tsx @@ -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(); + + 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() { - Judul event {status} + {data?.title || "-"} {listData.map((item, index) => ( @@ -60,9 +108,8 @@ export default function EventDetailStatus() { @@ -70,7 +117,7 @@ export default function EventDetailStatus() { setOpenDrawer(false)} - height={250} + height={"auto"} > - - ); } - -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!", - }, -]; diff --git a/app/(application)/(user)/event/[id]/edit.tsx b/app/(application)/(user)/event/[id]/edit.tsx index 1b3f771..11e8395 100644 --- a/app/(application)/(user)/event/[id]/edit.tsx +++ b/app/(application)/(user)/event/[id]/edit.tsx @@ -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(); + // { + // 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 = ( - - ); + 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 ( <> - - - console.log(value)} - /> - + {isLoadData ? ( + + ) : ( + + setData({ ...data, title: value })} + /> + ({ + label: item.name, + value: item.id, + }))} + value={data?.eventMaster_TipeAcaraId || ""} + onChange={(value) => { + console.log(value); + setData({ ...data, eventMaster_TipeAcaraId: value }); + }} + /> + setData({ ...data, lokasi: value })} + /> + { + setSelectedDate(date as any); + }} + /> + + { + setSelectedEndDate(date as any); + }} + /> - { - setSelectedDate(date as any); - }} - value={selectedDate as any} - minimumDate={new Date(Date.now())} - /> + {/* Muncul */} + {validateDateRange(selectedDate as any, selectedEndDate as any) + .isValid ? ( + + { + validateDateRange( + selectedDate as any, + selectedEndDate as any + ).error + } + + ) : ( + + { + validateDateRange( + selectedDate as any, + selectedEndDate as any + ).error + } + + )} + + - { - setSelectedEndDate(date as any); - }} - value={selectedEndDate as any} - /> + setData({ ...data, deskripsi: value })} + /> - - - {buttonSubmit} - + + + )} ); diff --git a/app/(application)/(user)/event/create.tsx b/app/(application)/(user)/event/create.tsx index 47653e5..69d0322 100644 --- a/app/(application)/(user)/event/create.tsx +++ b/app/(application)/(user)/event/create.tsx @@ -1,6 +1,7 @@ import { ButtonCustom, SelectCustom, + Spacing, StackCustom, TextAreaCustom, TextCustom, @@ -9,11 +10,12 @@ import { } from "@/components"; import DateTimePickerCustom from "@/components/DateInput/DateTimePickerCustom"; import { useAuth } from "@/hooks/use-auth"; -import { masterTypeEvent } from "@/lib/dummy-data/event/master-type-event"; +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; @@ -27,8 +29,23 @@ interface EventCreateProps { export default function EventCreate() { const [data, setData] = useState(); + 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); @@ -37,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(data, null, 2)); - // router.navigate("/event/status"); + console.log("Data berhasil disimpan", JSON.stringify(newData, null, 2)); + + const response = await apiEventCreate(newData); + console.log("Response", JSON.stringify(response, null, 2)); + + router.navigate("/event/status"); } catch (error) { console.log(error); + } finally { + setIsLoading(false); } }; const buttonSubmit = ( - - // - // + ); return ( @@ -78,14 +136,20 @@ export default function EventCreate() { required onChangeText={(value: any) => setData({ ...data, title: value })} /> + ({ + label: item.name, + value: item.id, + }))} + value={data?.eventMaster_TipeAcaraId || ""} onChange={(value: any) => setData({ ...data, eventMaster_TipeAcaraId: value }) } /> + - { - setSelectedEndDate(date as any); - }} - value={selectedEndDate as any} - /> + + { + setSelectedEndDate(date as any); + }} + value={selectedEndDate as any} + minimumDate={new Date(selectedDate as any)} + /> + {!selectedDate && ( + + Note: Pilih tanggal mulai terlebih dahulu + + )} + + + setData({ ...data, deskripsi: value }) + } /> {buttonSubmit} diff --git a/components/DateInput/DataTimeAndroid.tsx b/components/DateInput/DataTimeAndroid.tsx index aafd1a2..1931cd6 100644 --- a/components/DateInput/DataTimeAndroid.tsx +++ b/components/DateInput/DataTimeAndroid.tsx @@ -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 = ({ @@ -131,8 +131,8 @@ const DateTimeInput_Android: React.FC = ({ }} > - - + !disabled && toggleDatePicker()}> + {selectedDate ? ( {selectedDate.toLocaleDateString()} @@ -148,8 +148,8 @@ const DateTimeInput_Android: React.FC = ({ - - + !disabled && toggleTimePicker()}> + {selectedTime ? ( {selectedTime.toLocaleTimeString("id-ID", { diff --git a/components/DateInput/DateTimeIOS.tsx b/components/DateInput/DateTimeIOS.tsx index b27a765..0119102 100644 --- a/components/DateInput/DateTimeIOS.tsx +++ b/components/DateInput/DateTimeIOS.tsx @@ -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 = ({ !disabled && handlePress()} > {label && ( @@ -95,11 +90,11 @@ const DateTimeInput_IOS: React.FC = ({ - + {selectedDate ? ( {dayjs(selectedDate).format("DD-MM-YYYY HH:mm")} diff --git a/components/DateInput/DateTimePickerCustom.tsx b/components/DateInput/DateTimePickerCustom.tsx index 9a4814a..f1c5cc0 100644 --- a/components/DateInput/DateTimePickerCustom.tsx +++ b/components/DateInput/DateTimePickerCustom.tsx @@ -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 = ({ @@ -23,18 +21,21 @@ const DateTimePickerCustom: React.FC = ({ required, maximumDate, minimumDate, + disabled = false, }) => { return ( <> {Platform.OS === "ios" ? ( { + onChange={(date: DateTimePickerEvent | Date | null) => { onChange?.(date as any); }} required={required} maximumDate={maximumDate} minimumDate={minimumDate} + disabled={disabled} + value={value as DateTimePickerEvent | Date | null} /> ) : ( = ({ required={required} maximumDate={maximumDate} minimumDate={minimumDate} + disabled={disabled} /> )} diff --git a/screens/Authentication/LoginView.tsx b/screens/Authentication/LoginView.tsx index 7534c6c..8f2d0b4 100644 --- a/screens/Authentication/LoginView.tsx +++ b/screens/Authentication/LoginView.tsx @@ -98,7 +98,7 @@ export default function LoginView() { } if (token && !isAdmin) { - return ; + return ; } if (token && isAdmin) { diff --git a/screens/Event/ButtonStatusSection.tsx b/screens/Event/ButtonStatusSection.tsx index cf2077a..077b168 100644 --- a/screens/Event/ButtonStatusSection.tsx +++ b/screens/Event/ButtonStatusSection.tsx @@ -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 ( <> - + Hapus @@ -35,7 +145,7 @@ export default function Event_ButtonStatusSection({ case "review": return ( - + Batalkan Review ); @@ -44,13 +154,14 @@ export default function Event_ButtonStatusSection({ return ( <> - - Ajukan Review + + + Ajukan Review + - - + + {DeleteButton()} - {DeleteButton()} ); @@ -59,13 +170,14 @@ export default function Event_ButtonStatusSection({ return ( <> - - Edit Kembali + + + Edit Kembali + - - + + {DeleteButton()} - {DeleteButton()} ); diff --git a/service/api-client/api-event.ts b/service/api-client/api-event.ts new file mode 100644 index 0000000..6e7098b --- /dev/null +++ b/service/api-client/api-event.ts @@ -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; + } +} diff --git a/service/api-client/api-master.ts b/service/api-client/api-master.ts index dca1b46..7e80cb8 100644 --- a/service/api-client/api-master.ts +++ b/service/api-client/api-master.ts @@ -21,6 +21,11 @@ export async function apiMasterSubBidangBisnis({ id }: { id?: string }) { } } -// export async function apiMasterEventType(params:type) { - -// } \ No newline at end of file +export async function apiMasterEventType() { + try { + const response = await apiConfig.get(`/mobile/master/event-type`); + return response.data; + } catch (error) { + throw error; + } +} \ No newline at end of file diff --git a/utils/dateTimeView.ts b/utils/dateTimeView.ts new file mode 100644 index 0000000..c5c675c --- /dev/null +++ b/utils/dateTimeView.ts @@ -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; +};