Job
Add: - add file: (user)/job/[id]/archive Fix: - Semua tampilan telah terintergrasi ke API Job ### No Issue
This commit is contained in:
@@ -509,6 +509,13 @@ export default function UserLayout() {
|
|||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="job/[id]/archive"
|
||||||
|
options={{
|
||||||
|
title: "Arsip Job",
|
||||||
|
headerLeft: () => <BackButton />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* ========== End Job Section ========= */}
|
{/* ========== End Job Section ========= */}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,57 @@
|
|||||||
import { BaseBox, TextCustom, ViewWrapper } from "@/components";
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import { jobDataDummy } from "@/screens/Job/listDataDummy";
|
import { BaseBox, LoaderCustom, TextCustom, ViewWrapper } from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiJobGetAll } from "@/service/api-client/api-job";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function JobArchive() {
|
export default function JobArchive() {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [listData, setListData] = useState<any[]>([]);
|
||||||
|
const [isLoadData, setIsLoadData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [user?.id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoadData(true);
|
||||||
|
const response = await apiJobGetAll({
|
||||||
|
category: "archive",
|
||||||
|
authorId: user?.id,
|
||||||
|
});
|
||||||
|
setListData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper hideFooter>
|
<ViewWrapper hideFooter>
|
||||||
{jobDataDummy.map((e, i) => (
|
{isLoadData ? (
|
||||||
<BaseBox key={i} paddingTop={20} paddingBottom={20}>
|
<LoaderCustom />
|
||||||
<TextCustom align="center" bold truncate size="large">
|
) : _.isEmpty(listData) ? (
|
||||||
{e.posisi}
|
<TextCustom align="center">Anda tidak memiliki arsip</TextCustom>
|
||||||
</TextCustom>
|
) : (
|
||||||
</BaseBox>
|
listData.map((item, index) => (
|
||||||
))}
|
<BaseBox
|
||||||
|
key={index}
|
||||||
|
paddingTop={20}
|
||||||
|
paddingBottom={20}
|
||||||
|
href={`/job/${item.id}/archive`}
|
||||||
|
>
|
||||||
|
<TextCustom align="center" bold truncate size="large">
|
||||||
|
{item?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default function JobBeranda() {
|
|||||||
const onLoadData = async (search: string) => {
|
const onLoadData = async (search: string) => {
|
||||||
try {
|
try {
|
||||||
setIsLoadData(true);
|
setIsLoadData(true);
|
||||||
const response = await apiJobGetAll({ search });
|
const response = await apiJobGetAll({ search, category: "beranda" });
|
||||||
setListData(response.data);
|
setListData(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default function JobDetailStatus() {
|
|||||||
status={status as string}
|
status={status as string}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onSetLoading={setIsLoading}
|
onSetLoading={setIsLoading}
|
||||||
|
isArchive={true}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|||||||
100
app/(application)/(user)/job/[id]/archive.tsx
Normal file
100
app/(application)/(user)/job/[id]/archive.tsx
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
ButtonCustom,
|
||||||
|
LoaderCustom,
|
||||||
|
Spacing,
|
||||||
|
StackCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection";
|
||||||
|
import { apiJobGetOne, apiJobUpdateData } from "@/service/api-client/api-job";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function JobDetailArchive() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any>(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 handleArchive = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await apiJobUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: false,
|
||||||
|
category: "archive",
|
||||||
|
});
|
||||||
|
|
||||||
|
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 {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{isLoadData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : (
|
||||||
|
<ViewWrapper>
|
||||||
|
<>
|
||||||
|
<StackCustom>
|
||||||
|
<Job_BoxDetailSection data={data} />
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
handleArchive();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Publish kembali
|
||||||
|
</ButtonCustom>
|
||||||
|
{/* <Job_ButtonStatusSection
|
||||||
|
id={id as string}
|
||||||
|
status={status as string}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onSetLoading={setIsLoading}
|
||||||
|
isArchive={true}
|
||||||
|
/> */}
|
||||||
|
</StackCustom>
|
||||||
|
<Spacing />
|
||||||
|
</>
|
||||||
|
</ViewWrapper>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -99,6 +99,7 @@ export default function JobEdit() {
|
|||||||
const response = await apiJobUpdateData({
|
const response = await apiJobUpdateData({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
data: newData,
|
data: newData,
|
||||||
|
category: "edit",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import { ButtonCustom, LoaderCustom, Spacing, ViewWrapper } from "@/components";
|
import { ButtonCustom, LoaderCustom, Spacing, StackCustom, ViewWrapper } from "@/components";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||||
import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection";
|
import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection";
|
||||||
@@ -90,9 +90,11 @@ export default function JobDetail() {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Job_BoxDetailSection data={data} />
|
<Job_BoxDetailSection data={data} />
|
||||||
<OpenLinkButton id={id as string} />
|
<StackCustom>
|
||||||
|
<OpenLinkButton id={id as string} />
|
||||||
|
<CopyLinkButton id={id as string} />
|
||||||
|
</StackCustom>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<CopyLinkButton id={id as string} />
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
|
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
|
||||||
import { apiJobDelete, apiJobUpdateStatus } from "@/service/api-client/api-job";
|
import {
|
||||||
|
apiJobDelete,
|
||||||
|
apiJobUpdateData,
|
||||||
|
apiJobUpdateStatus,
|
||||||
|
} from "@/service/api-client/api-job";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
@@ -8,11 +12,13 @@ export default function Job_ButtonStatusSection({
|
|||||||
status,
|
status,
|
||||||
isLoading,
|
isLoading,
|
||||||
onSetLoading,
|
onSetLoading,
|
||||||
|
isArchive,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
status: string;
|
status: string;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
onSetLoading: (value: boolean) => void;
|
onSetLoading: (value: boolean) => void;
|
||||||
|
isArchive?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const handleBatalkanReview = () => {
|
const handleBatalkanReview = () => {
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
@@ -27,7 +33,7 @@ export default function Job_ButtonStatusSection({
|
|||||||
id: id,
|
id: id,
|
||||||
status: "draft",
|
status: "draft",
|
||||||
});
|
});
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -64,7 +70,7 @@ export default function Job_ButtonStatusSection({
|
|||||||
id: id,
|
id: id,
|
||||||
status: "review",
|
status: "review",
|
||||||
});
|
});
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -101,7 +107,7 @@ export default function Job_ButtonStatusSection({
|
|||||||
id: id,
|
id: id,
|
||||||
status: "draft",
|
status: "draft",
|
||||||
});
|
});
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -137,7 +143,7 @@ export default function Job_ButtonStatusSection({
|
|||||||
const response = await apiJobDelete({
|
const response = await apiJobDelete({
|
||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -161,6 +167,45 @@ export default function Job_ButtonStatusSection({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleArchive = () => {
|
||||||
|
AlertDefaultSystem({
|
||||||
|
title: "Arsipkan",
|
||||||
|
message: "Apakah Anda yakin ingin mengarsipkan data ini?",
|
||||||
|
textLeft: "Batal",
|
||||||
|
textRight: "Arsipkan",
|
||||||
|
onPressRight: async () => {
|
||||||
|
try {
|
||||||
|
onSetLoading(true);
|
||||||
|
const response = await apiJobUpdateData({
|
||||||
|
id: id,
|
||||||
|
data: isArchive,
|
||||||
|
category: "archive",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
// router.back();
|
||||||
|
router.replace("/(application)/(user)/job/(tabs)/archive");
|
||||||
|
} else {
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: "Info",
|
||||||
|
text2: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
onSetLoading(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const DeleteButton = () => {
|
const DeleteButton = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -181,9 +226,9 @@ export default function Job_ButtonStatusSection({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log("Arsipkan");
|
handleArchive();
|
||||||
router.replace("/(application)/(user)/job/(tabs)/archive");
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Arsipkan
|
Arsipkan
|
||||||
|
|||||||
@@ -59,10 +59,24 @@ export async function apiJobDelete({ id }: { id: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiJobGetAll({ search }: { search?: string }) {
|
export async function apiJobGetAll({
|
||||||
|
search,
|
||||||
|
category,
|
||||||
|
authorId,
|
||||||
|
}: {
|
||||||
|
search?: string;
|
||||||
|
category: "archive" | "beranda";
|
||||||
|
authorId?: string;
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
const searchText = search ? `?search=${search}` : "";
|
let categoryText = category ? `?category=${category}` : "";
|
||||||
const response = await apiConfig.get(`/mobile/job${searchText}`);
|
if (category === "archive") {
|
||||||
|
categoryText = `?category=${category}&authorId=${authorId}`;
|
||||||
|
}
|
||||||
|
const searchText = search ? `&search=${search}` : "";
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/job${categoryText}${searchText}`
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
@@ -72,12 +86,15 @@ export async function apiJobGetAll({ search }: { search?: string }) {
|
|||||||
export async function apiJobUpdateData({
|
export async function apiJobUpdateData({
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
|
category,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
data: any;
|
data: any;
|
||||||
|
category: "edit" | "archive";
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.put(`/mobile/job/${id}`, {
|
const categoryJob = category ? `?category=${category}` : "";
|
||||||
|
const response = await apiConfig.put(`/mobile/job/${id}${categoryJob}`, {
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user