Create PageWrapper component that routes to: - iOS: NewWrapper (stable, tested) - Android: NewWrapper_V2 (keyboard handling fix) New Files: - components/_ShareComponent/PageWrapper.tsx - docs/PAGEWRAPPER-USAGE.md Migrated Job Screens (10): - screens/Job/ScreenJobCreate.tsx: NewWrapper_V2 → PageWrapper - screens/Job/ScreenJobEdit.tsx: NewWrapper_V2 → PageWrapper - screens/Job/ScreenArchive.tsx: ViewWrapper → PageWrapper - screens/Job/ScreenArchive2.tsx: NewWrapper_V2 → PageWrapper - screens/Job/ScreenBeranda2.tsx: NewWrapper_V2 → PageWrapper - screens/Job/MainViewStatus2.tsx: NewWrapper_V2 → PageWrapper - app/(application)/(user)/job/[id]/index.tsx: ViewWrapper → PageWrapper - app/(application)/(user)/job/[id]/archive.tsx: ViewWrapper → PageWrapper - app/(application)/(user)/job/[id]/[status]/detail.tsx: NewWrapper_V2 → PageWrapper Benefits: - iOS users (70%+) get stable NewWrapper - Android users get keyboard handling fix - Clean API - no Platform.OS checks in screens - Easy future migration path Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
94 lines
2.2 KiB
TypeScript
94 lines
2.2 KiB
TypeScript
/* eslint-disable react-hooks/exhaustive-deps */
|
|
import {
|
|
ButtonCustom,
|
|
LoaderCustom,
|
|
PageWrapper,
|
|
Spacing,
|
|
StackCustom,
|
|
} 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 />
|
|
) : (
|
|
<PageWrapper>
|
|
<>
|
|
<StackCustom>
|
|
<Job_BoxDetailSection data={data} />
|
|
<ButtonCustom
|
|
isLoading={isLoading}
|
|
onPress={() => {
|
|
handleArchive();
|
|
}}
|
|
>
|
|
Publish kembali
|
|
</ButtonCustom>
|
|
</StackCustom>
|
|
<Spacing />
|
|
</>
|
|
</PageWrapper>
|
|
)}
|
|
</>
|
|
);
|
|
}
|