diff --git a/app/(application)/(user)/job/(tabs)/index.tsx b/app/(application)/(user)/job/(tabs)/index.tsx index 1846b91..7d40873 100644 --- a/app/(application)/(user)/job/(tabs)/index.tsx +++ b/app/(application)/(user)/job/(tabs)/index.tsx @@ -1,34 +1,83 @@ import { - AvatarUsernameAndOtherComponent, - BoxWithHeaderSection, - FloatingButton, - SearchInput, - Spacing, - TextCustom, - ViewWrapper + AvatarUsernameAndOtherComponent, + BoxWithHeaderSection, + FloatingButton, + LoaderCustom, + SearchInput, + Spacing, + StackCustom, + TextCustom, + ViewWrapper, } from "@/components"; -import { jobDataDummy } from "@/screens/Job/listDataDummy"; -import { router } from "expo-router"; +import { apiJobGetAll } from "@/service/api-client/api-job"; +import { router, useFocusEffect } from "expo-router"; +import _ from "lodash"; +import { useCallback, useState } from "react"; export default function JobBeranda() { + const [listData, setListData] = useState([]); + const [isLoadData, setIsLoadData] = useState(false); + const [search, setSearch] = useState(""); + + useFocusEffect( + useCallback(() => { + onLoadData(search); + }, [search]) + ); + + const onLoadData = async (search: string) => { + try { + setIsLoadData(true); + const response = await apiJobGetAll({ search }); + setListData(response.data); + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoadData(false); + } + }; + + const handleSearch = (search: string) => { + setSearch(search); + onLoadData(search); + }; + return ( router.push("/job/create")} /> } - headerComponent={} + headerComponent={ + + } > - {jobDataDummy.map((item, index) => ( - router.push(`/job/${item.id}`)}> - - - - {item.posisi} - - - - ))} + {isLoadData ? ( + + ) : _.isEmpty(listData) ? ( + Belum ada lowongan + ) : ( + listData.map((item, index) => ( + router.push(`/job/${item.id}`)} + > + + + + + {item?.title || "-"} + + + + + )) + )} + ); } diff --git a/app/(application)/(user)/job/(tabs)/status.tsx b/app/(application)/(user)/job/(tabs)/status.tsx index e54f6cc..4c1f004 100644 --- a/app/(application)/(user)/job/(tabs)/status.tsx +++ b/app/(application)/(user)/job/(tabs)/status.tsx @@ -1,17 +1,46 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { - BaseBox, - ScrollableCustom, - TextCustom, - ViewWrapper, + BaseBox, + LoaderCustom, + ScrollableCustom, + TextCustom, + ViewWrapper, } from "@/components"; +import { useAuth } from "@/hooks/use-auth"; import { dummyMasterStatus } from "@/lib/dummy-data/_master/status"; -import { jobDataDummy } from "@/screens/Job/listDataDummy"; -import { useState } from "react"; +import { apiJobGetByStatus } from "@/service/api-client/api-job"; +import { useFocusEffect } from "expo-router"; +import _ from "lodash"; +import { useCallback, useState } from "react"; export default function JobStatus() { + const { user } = useAuth(); const [activeCategory, setActiveCategory] = useState( "publish" ); + const [listData, setListData] = useState([]); + const [isLoadList, setIsLoadList] = useState(false); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [user?.id, activeCategory]) + ); + + const onLoadData = async () => { + try { + setIsLoadList(true); + const response = await apiJobGetByStatus({ + authorId: user?.id as string, + status: activeCategory as string, + }); + setListData(response.data); + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoadList(false); + } + }; const handlePress = (item: any) => { setActiveCategory(item.value); @@ -32,19 +61,24 @@ export default function JobStatus() { return ( - {jobDataDummy.map((e, i) => ( - console.log("pressed")} - > - - {e.posisi} {activeCategory?.toUpperCase()} - - - ))} + {isLoadList ? ( + + ) : _.isEmpty(listData) ? ( + Tidak ada data {activeCategory} + ) : ( + listData.map((e, i) => ( + + + {e?.title} + + + )) + )} ); } diff --git a/app/(application)/(user)/job/[id]/[status]/detail.tsx b/app/(application)/(user)/job/[id]/[status]/detail.tsx index 8af9a97..dcad520 100644 --- a/app/(application)/(user)/job/[id]/[status]/detail.tsx +++ b/app/(application)/(user)/job/[id]/[status]/detail.tsx @@ -1,23 +1,51 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { BackButton, DotButton, DrawerCustom, + LoaderCustom, MenuDrawerDynamicGrid, Spacing, + StackCustom, ViewWrapper, } from "@/components"; import { IconEdit } from "@/components/_Icon"; import { IMenuDrawerItem } from "@/components/_Interface/types"; import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection"; import Job_ButtonStatusSection from "@/screens/Job/ButtonStatusSection"; -import { jobDataDummy } from "@/screens/Job/listDataDummy"; -import { router, Stack, useLocalSearchParams } from "expo-router"; -import { useState } from "react"; +import { apiJobGetOne } from "@/service/api-client/api-job"; +import { + router, + Stack, + useFocusEffect, + useLocalSearchParams, +} from "expo-router"; +import { useCallback, useState } from "react"; export default function JobDetailStatus() { const { id, status } = useLocalSearchParams(); const [openDrawer, setOpenDrawer] = useState(false); - const jobDetail = jobDataDummy.find((e) => e.id === Number(id)); + const [data, setData] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [isLoadData, setIsLoadData] = useState(false); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + setIsLoadData(true); + const response = await apiJobGetOne({ id: id as string }); + setData(response.data); + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoadData(false); + } + }; const handlePress = (item: IMenuDrawerItem) => { console.log("PATH >> ", item.path); @@ -38,9 +66,22 @@ export default function JobDetailStatus() { }} /> - - - + {isLoadData ? ( + + ) : ( + <> + + + + + + + )} ({ + title: "", + content: "", + deskripsi: "", + }); + const [isLoadData, setIsLoadData] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const [imageUri, setImageUri] = useState(null); + + useEffect(() => { + onLoadData(); + }, [id]); + + const onLoadData = async () => { + try { + setIsLoadData(true); + const response = await apiJobGetOne({ id: id as string }); + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoadData(false); + } + }; + + const handlerOnUpdate = async () => { + if (!data.title || !data.content || !data.deskripsi) { + Toast.show({ + type: "info", + text1: "Info", + text2: "Harap isi semua data", + }); + return; + } + + try { + setIsLoading(true); + let newImageId = ""; + + if (imageUri) { + const responseUploadImage = await uploadImageService({ + imageUri: imageUri, + dirId: DIRECTORY_ID.job_image, + }); + + if (responseUploadImage.success) { + newImageId = responseUploadImage.data.id; + } + } + + if (data?.imageId) { + const responseDeleteImage = await deleteImageService({ + id: data.imageId, + }); + + if (!responseDeleteImage.success) { + console.log("[ERROR DELETE IMAGE]", responseDeleteImage.message); + } + } + + const newData = { + title: data.title, + content: data.content, + deskripsi: data.deskripsi, + imageId: newImageId, + }; + + const response = await apiJobUpdateData({ + id: id as string, + data: newData, + }); + + if (response.success) { + Toast.show({ + type: "success", + text1: response.message, + }); + router.back(); + } else { + Toast.show({ + type: "info", + text1: "Info", + text2: response.message, + }); + } + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoading(false); + } + }; + const buttonSubmit = () => { return ( <> - router.back()}>Update + handlerOnUpdate()}> + Update + ); @@ -23,45 +134,64 @@ export default function JobEdit() { return ( - - + {isLoadData ? ( + + ) : ( + + - - { - router.push("/(application)/(image)/take-picture/123"); - }} - icon="upload" - > - Upload - + {imageUri ? ( + + ) : ( + + + + )} - + { + pickImage({ + setImageUri, + }); + }} + icon="upload" + > + Upload + - + - + setData({ ...data, title: value })} + /> - + setData({ ...data, content: value })} + /> - {buttonSubmit()} - + setData({ ...data, deskripsi: value })} + /> + + {buttonSubmit()} + + )} ); } diff --git a/app/(application)/(user)/job/[id]/index.tsx b/app/(application)/(user)/job/[id]/index.tsx index f889ac1..d3dd6ff 100644 --- a/app/(application)/(user)/job/[id]/index.tsx +++ b/app/(application)/(user)/job/[id]/index.tsx @@ -1,25 +1,41 @@ -import { - ButtonCustom, - Spacing, - ViewWrapper -} from "@/components"; +/* eslint-disable react-hooks/exhaustive-deps */ +import { ButtonCustom, LoaderCustom, Spacing, ViewWrapper } from "@/components"; import { MainColor } from "@/constants/color-palet"; import { ICON_SIZE_SMALL } from "@/constants/constans-value"; import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection"; -import { jobDataDummy } from "@/screens/Job/listDataDummy"; +import { apiJobGetOne } from "@/service/api-client/api-job"; import { Ionicons } from "@expo/vector-icons"; import * as Clipboard from "expo-clipboard"; import { useLocalSearchParams } from "expo-router"; +import { useEffect, useState } from "react"; import { Alert, Linking } from "react-native"; export default function JobDetail() { const { id } = useLocalSearchParams(); + const [data, setData] = useState(null); + const [isLoading, setIsLoading] = useState(false); - const jobDetail = jobDataDummy.find((e) => e.id === Number(id)); + useEffect(() => { + onLoadData(); + }, [id]); - const OpenLinkButton = () => { - const jobUrl = - "https://stg-hipmi.wibudev.com/job-vacancy/cm6ijt9w8005zucv4twsct657"; + const onLoadData = async () => { + try { + setIsLoading(true); + const response = await apiJobGetOne({ id: id as string }); + + setData(response.data); + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoading(false); + } + }; + + const linkUrl = `http://192.168.1.83:3000/job-vacancy/`; + + const OpenLinkButton = ({ id }: { id: string }) => { + const jobUrl = `${linkUrl}${id}`; const openInBrowser = async () => { const supported = await Linking.canOpenURL(jobUrl); @@ -44,9 +60,8 @@ export default function JobDetail() { ); }; - const CopyLinkButton = () => { - const jobUrl = - "https://stg-hipmi.wibudev.com/job-vacancy/cm6ijt9w8005zucv4twsct657"; + const CopyLinkButton = ({ id }: { id: string }) => { + const jobUrl = `${linkUrl}${id}`; const copyToClipboard = async () => { await Clipboard.setStringAsync(jobUrl); @@ -70,10 +85,16 @@ export default function JobDetail() { return ( - - - - + {isLoading ? ( + + ) : ( + <> + + + + + + )} ); } diff --git a/app/(application)/(user)/job/create.tsx b/app/(application)/(user)/job/create.tsx index 9408a6c..31ef530 100644 --- a/app/(application)/(user)/job/create.tsx +++ b/app/(application)/(user)/job/create.tsx @@ -7,19 +7,99 @@ import { StackCustom, TextAreaCustom, TextInputCustom, - ViewWrapper, + ViewWrapper } from "@/components"; +import DIRECTORY_ID from "@/constants/directory-id"; +import { useAuth } from "@/hooks/use-auth"; +import { apiJobCreate } from "@/service/api-client/api-job"; +import { uploadImageService } from "@/service/upload-service"; +import pickImage from "@/utils/pickImage"; import { router } from "expo-router"; +import { useState } from "react"; +import Toast from "react-native-toast-message"; export default function JobCreate() { + const nextUrl = "/(application)/(user)/job/(tabs)/status"; + const { user } = useAuth(); + const [isLoading, setIsLoading] = useState(false); + const [image, setImage] = useState(null); + const [data, setData] = useState({ + title: "", + content: "", + deskripsi: "", + authorId: "", + }); + + const handlerOnSubmit = async () => { + let imageId = ""; + const newData = { + title: data.title, + content: data.content, + deskripsi: data.deskripsi, + authorId: user?.id, + imageId: "", + }; + + if (!data.title || !data.content || !data.deskripsi || !user?.id) { + Toast.show({ + type: "info", + text1: "Info", + text2: "Harap isi semua data", + }); + return; + } + + try { + setIsLoading(true); + + if (image === null || !image) { + const response = await apiJobCreate(newData); + if (response.success) { + Toast.show({ + type: "success", + text1: "Berhasil", + text2: "Lowongan berhasil dibuat", + }); + router.replace(nextUrl); + } + + return; + } + + const responseUploadImage = await uploadImageService({ + imageUri: image, + dirId: DIRECTORY_ID.job_image, + }); + + if (responseUploadImage.success) { + imageId = responseUploadImage.data.id; + } + + const fixData = { + ...newData, + imageId: imageId, + }; + + const response = await apiJobCreate(fixData); + if (response.success) { + Toast.show({ + type: "success", + text1: "Berhasil", + text2: "Lowongan berhasil dibuat", + }); + router.replace(nextUrl); + } + } catch (error) { + console.log("[ERROR]", error); + } finally { + setIsLoading(false); + } + }; + const buttonSubmit = () => { return ( <> - - router.replace("/(application)/(user)/job/(tabs)/status") - } - > + handlerOnSubmit()}> Simpan @@ -32,10 +112,19 @@ export default function JobCreate() { - + {/* + + */} + { - router.push("/(application)/(image)/take-picture/123"); + // router.push("/(application)/(image)/take-picture/123"); + pickImage({ + setImageUri: setImage, + }); }} icon="upload" > @@ -48,6 +137,8 @@ export default function JobCreate() { label="Judul Lowongan" placeholder="Masukan Judul Lowongan Kerja" required + value={data.title} + onChangeText={(value) => setData({ ...data, title: value })} /> setData({ ...data, content: value })} /> setData({ ...data, deskripsi: value })} /> {buttonSubmit()} diff --git a/app/(application)/(user)/profile/[id]/index.tsx b/app/(application)/(user)/profile/[id]/index.tsx index bf3acfe..3d50901 100644 --- a/app/(application)/(user)/profile/[id]/index.tsx +++ b/app/(application)/(user)/profile/[id]/index.tsx @@ -77,18 +77,16 @@ export default function Profile() { <> , - headerRight: () => - isUserCheck() && ( - - - - ), + headerRight: () => ( + + ), headerStyle: GStyles.headerStyle, headerTitleStyle: GStyles.headerTitleStyle, }} @@ -124,3 +122,44 @@ export default function Profile() { ); } + +const ButtonnDot = ({ + id, + openDrawer, + isUserCheck, + logout, +}: { + id: string; + openDrawer: () => void; + isUserCheck: boolean; + logout: () => Promise; +}) => { + const isId = id === undefined || id === null; + + console.log("ID CHECK", id); + + if (isId) { + console.log("ID UNDEFINED", id); + return ( + <> + + + + + ); + } + + return ( + <> + {isUserCheck && ( + + + + )} + + ); +}; diff --git a/components/Box/BaseBox.tsx b/components/Box/BaseBox.tsx index 128fa0b..9bf6fd9 100644 --- a/components/Box/BaseBox.tsx +++ b/components/Box/BaseBox.tsx @@ -40,7 +40,7 @@ export default function BaseBox({ return ( <> - {onPress || href ? ( + {onPress as any || href ? ( router.navigate(href) : onPress} diff --git a/components/Image/LandscapeFrameUploaded.tsx b/components/Image/LandscapeFrameUploaded.tsx index 02439de..1f9b78f 100644 --- a/components/Image/LandscapeFrameUploaded.tsx +++ b/components/Image/LandscapeFrameUploaded.tsx @@ -2,7 +2,11 @@ import DUMMY_IMAGE from "@/constants/dummy-image-value"; import { Image } from "react-native"; import BaseBox from "../Box/BaseBox"; -export default function LandscapeFrameUploaded() { +export default function LandscapeFrameUploaded({ + image, +}: { + image?: string; +}) { return ( diff --git a/components/_ShareComponent/DummyLandscapeImage.tsx b/components/_ShareComponent/DummyLandscapeImage.tsx index d4ee613..8ff9b4b 100644 --- a/components/_ShareComponent/DummyLandscapeImage.tsx +++ b/components/_ShareComponent/DummyLandscapeImage.tsx @@ -4,17 +4,33 @@ import { Image } from "expo-image"; import { StyleSheet } from "react-native"; import ClickableCustom from "../Clickable/ClickableCustom"; import { router } from "expo-router"; +import API_STRORAGE from "@/constants/base-url-api-strorage"; -export default function DummyLandscapeImage({height, unClickPath}: {height?: number, unClickPath?: boolean}) { +export default function DummyLandscapeImage({ + height, + unClickPath, + imageId, +}: { + height?: number; + unClickPath?: boolean; + imageId?: string; +}) { return ( { if (!unClickPath) { - router.push("/(application)/(image)/preview-image/1"); + router.push(`/(application)/(image)/preview-image/${imageId}`); } }} > - + ); } diff --git a/components/_ShareComponent/SearchInput.tsx b/components/_ShareComponent/SearchInput.tsx index b73df2f..01d297a 100644 --- a/components/_ShareComponent/SearchInput.tsx +++ b/components/_ShareComponent/SearchInput.tsx @@ -11,6 +11,7 @@ interface SearchInputProps { iconRight?: React.ReactNode; containerStyle?: StyleProp; style?: StyleProp; + onChangeText?: (value: string) => void; } export default function SearchInput({ placeholder, @@ -19,6 +20,7 @@ export default function SearchInput({ iconRight, containerStyle, style, + onChangeText, ...props }: SearchInputProps) { return ( @@ -30,6 +32,7 @@ export default function SearchInput({ color={MainColor.placeholder} /> } + onChangeText={onChangeText} placeholder={placeholder} borderRadius={50} containerStyle={[containerStyle, { marginBottom: 0 }]} diff --git a/screens/Job/BoxDetailSection.tsx b/screens/Job/BoxDetailSection.tsx index 5995554..0137783 100644 --- a/screens/Job/BoxDetailSection.tsx +++ b/screens/Job/BoxDetailSection.tsx @@ -1,28 +1,34 @@ -import { BaseBox, StackCustom, DummyLandscapeImage, TextCustom } from "@/components"; +import { + BaseBox, + StackCustom, + DummyLandscapeImage, + TextCustom, +} from "@/components"; -export default function Job_BoxDetailSection({data}: {data: any}) { - return ( - <> - - - +export default function Job_BoxDetailSection({ data }: { data: any }) { + return ( + <> + + + {data && data.imageId && ( + + )} - - {data?.posisi} - + + {data?.title || "-"} + - - Syarat & Ketentuan : - {data?.syaratKetentuan} - - - - Deskripsi : - {data?.deskripsi} - + + Syarat & Ketentuan : + {data?.content || "-"} - - - ); + + + Deskripsi : + {data?.deskripsi || "-"} + + + + + ); } - \ No newline at end of file diff --git a/screens/Job/ButtonStatusSection.tsx b/screens/Job/ButtonStatusSection.tsx index edaf004..6799bce 100644 --- a/screens/Job/ButtonStatusSection.tsx +++ b/screens/Job/ButtonStatusSection.tsx @@ -1,11 +1,18 @@ import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components"; +import { apiJobDelete, apiJobUpdateStatus } from "@/service/api-client/api-job"; import { router } from "expo-router"; -import { View } from "react-native"; +import Toast from "react-native-toast-message"; export default function Job_ButtonStatusSection({ + id, status, + isLoading, + onSetLoading, }: { + id: string; status: string; + isLoading: boolean; + onSetLoading: (value: boolean) => void; }) { const handleBatalkanReview = () => { AlertDefaultSystem({ @@ -13,9 +20,33 @@ export default function Job_ButtonStatusSection({ message: "Apakah Anda yakin ingin batalkan review ini?", textLeft: "Batal", textRight: "Ya", - onPressRight: () => { - console.log("Hapus"); - router.back(); + onPressRight: async () => { + try { + onSetLoading(true); + const response = await apiJobUpdateStatus({ + id: id, + status: "draft", + }); + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + 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); + } finally { + onSetLoading(false); + } }, }); }; @@ -26,9 +57,33 @@ export default function Job_ButtonStatusSection({ message: "Apakah Anda yakin ingin ajukan review ini?", textLeft: "Batal", textRight: "Ya", - onPressRight: () => { - console.log("Hapus"); - router.back(); + onPressRight: async () => { + try { + onSetLoading(true); + const response = await apiJobUpdateStatus({ + id: id, + status: "review", + }); + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + 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); + } finally { + onSetLoading(false); + } }, }); }; @@ -39,9 +94,33 @@ export default function Job_ButtonStatusSection({ message: "Apakah Anda yakin ingin edit kembali ini?", textLeft: "Batal", textRight: "Ya", - onPressRight: () => { - console.log("Hapus"); - router.back(); + onPressRight: async () => { + try { + onSetLoading(true); + const response = await apiJobUpdateStatus({ + id: id, + status: "draft", + }); + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + 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); + } finally { + onSetLoading(false); + } }, }); }; @@ -52,9 +131,32 @@ export default function Job_ButtonStatusSection({ message: "Apakah Anda yakin ingin menghapus data ini?", textLeft: "Batal", textRight: "Hapus", - onPressRight: () => { - console.log("Hapus"); - router.back(); + onPressRight: async () => { + try { + onSetLoading(true); + const response = await apiJobDelete({ + id: id, + }); + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + 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); + } finally { + onSetLoading(false); + } }, }); }; @@ -63,6 +165,7 @@ export default function Job_ButtonStatusSection({ return ( <> + Batalkan Review ); @@ -99,15 +202,14 @@ export default function Job_ButtonStatusSection({ return ( <> - - + + Ajukan Review - - + + {DeleteButton()} - {DeleteButton()} ); @@ -116,15 +218,15 @@ export default function Job_ButtonStatusSection({ return ( <> - - + + Edit Kembali - - + + + {DeleteButton()} - {DeleteButton()} ); diff --git a/service/api-client/api-job.ts b/service/api-client/api-job.ts new file mode 100644 index 0000000..fbd3c98 --- /dev/null +++ b/service/api-client/api-job.ts @@ -0,0 +1,87 @@ +import { apiConfig } from "../api-config"; + +export async function apiJobCreate(data: any) { + try { + const response = await apiConfig.post(`/mobile/job`, { + data: data, + }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobGetByStatus({ + authorId, + status, +}: { + authorId: string; + status: string; +}) { + try { + const response = await apiConfig.get(`/mobile/job/${authorId}/${status}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobGetOne({ id }: { id: string }) { + try { + const response = await apiConfig.get(`/mobile/job/${id}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobUpdateStatus({ + id, + status, +}: { + id: string; + status: "draft" | "review" | "publish" | "reject"; +}) { + try { + const response = await apiConfig.put(`/mobile/job/${id}/${status}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobDelete({ id }: { id: string }) { + try { + const response = await apiConfig.delete(`/mobile/job/${id}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobGetAll({ search }: { search?: string }) { + try { + const searchText = search ? `?search=${search}` : ""; + const response = await apiConfig.get(`/mobile/job${searchText}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiJobUpdateData({ + id, + data, +}: { + id: string; + data: any; +}) { + try { + const response = await apiConfig.put(`/mobile/job/${id}`, { + data: data, + }); + return response.data; + } catch (error) { + throw error; + } +} diff --git a/service/upload-service.ts b/service/upload-service.ts index 3fe7347..dcc7e02 100644 --- a/service/upload-service.ts +++ b/service/upload-service.ts @@ -1,6 +1,6 @@ import { API_BASE_URL } from "@/service/api-config"; import AsyncStorage from "@react-native-async-storage/async-storage"; -import { apiFileUpload } from "./api-client/api-file"; +import { apiFileDelete, apiFileUpload } from "./api-client/api-file"; export async function uploadImageService({ dirId, @@ -49,3 +49,18 @@ export async function uploadImageService({ throw error; } } + +export async function deleteImageService({ id }: { id: string }) { + const token = await AsyncStorage.getItem("authToken"); + + try { + const response = await apiFileDelete({ + id: id, + token: token as string, + }); + + return response; + } catch (error) { + throw error; + } +}