From 0f552443c45735b48cce5b876c4319d59ab12cff Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Thu, 2 Apr 2026 15:31:26 +0800 Subject: [PATCH] refactor: Cleanup test files and migrate Job Detail screen - Delete ScreenJobCreate2.tsx and ScreenJobEdit2.tsx (test files) - Delete TestWrapper.tsx and TestKeyboardInput.tsx (test components) - Delete test pages (test-keyboard.tsx, test-keyboard-bug.tsx) - Update create.tsx to use ScreenJobCreate (not test version) - Update edit.tsx to use ScreenJobEdit (not test version) - Migrate Job Detail screen to NewWrapper_V2 - Remove TestWrapper from exports - Clean up imports Phase 1 cleanup completed! Co-authored-by: Qwen-Coder --- .../(user)/job/[id]/[status]/detail.tsx | 8 +- app/(application)/(user)/job/[id]/edit.tsx | 8 +- app/(application)/(user)/job/create.tsx | 8 +- components/_ShareComponent/TestWrapper.tsx | 45 ---- components/index.ts | 2 - screens/Job/ScreenJobCreate2.tsx | 183 ---------------- screens/Job/ScreenJobEdit2.tsx | 207 ------------------ 7 files changed, 6 insertions(+), 455 deletions(-) delete mode 100644 components/_ShareComponent/TestWrapper.tsx delete mode 100644 screens/Job/ScreenJobCreate2.tsx delete mode 100644 screens/Job/ScreenJobEdit2.tsx diff --git a/app/(application)/(user)/job/[id]/[status]/detail.tsx b/app/(application)/(user)/job/[id]/[status]/detail.tsx index 8fbb353..12bd4c4 100644 --- a/app/(application)/(user)/job/[id]/[status]/detail.tsx +++ b/app/(application)/(user)/job/[id]/[status]/detail.tsx @@ -5,9 +5,9 @@ import { DrawerCustom, LoaderCustom, MenuDrawerDynamicGrid, + NewWrapper_V2, Spacing, StackCustom, - ViewWrapper, } from "@/components"; import AppHeader from "@/components/_ShareComponent/AppHeader"; import { IconEdit } from "@/components/_Icon"; @@ -72,7 +72,7 @@ export default function JobDetailStatus() { ), }} /> - + {isLoadData ? ( ) : ( @@ -83,7 +83,7 @@ export default function JobDetailStatus() { (status === "draft" || status === "reject") && ( )} - + )} - + - {/* ; */} - - - ); + return ; } diff --git a/app/(application)/(user)/job/create.tsx b/app/(application)/(user)/job/create.tsx index d9ca6d3..2e2ebf6 100644 --- a/app/(application)/(user)/job/create.tsx +++ b/app/(application)/(user)/job/create.tsx @@ -1,11 +1,5 @@ import { Job_ScreenCreate } from "@/screens/Job/ScreenJobCreate"; -import { Job_ScreenCreate2 } from "@/screens/Job/ScreenJobCreate2"; export default function JobCreate() { - return ( - <> - {/* */} - - - ); + return ; } diff --git a/components/_ShareComponent/TestWrapper.tsx b/components/_ShareComponent/TestWrapper.tsx deleted file mode 100644 index fc20c7a..0000000 --- a/components/_ShareComponent/TestWrapper.tsx +++ /dev/null @@ -1,45 +0,0 @@ -// TestWrapper.tsx - Wrapper sederhana untuk test keyboard handling -import { MainColor } from "@/constants/color-palet"; -import { - Keyboard, - KeyboardAvoidingView, - Platform, - ScrollView, - View, -} from "react-native"; -import { - NativeSafeAreaViewProps, - SafeAreaView, -} from "react-native-safe-area-context"; - -interface TestWrapperProps { - children: React.ReactNode; - footerComponent?: React.ReactNode; -} - -export function TestWrapper({ children, footerComponent }: TestWrapperProps) { - return ( - - - {children} - - - {footerComponent && ( - - {footerComponent} - - )} - - ); -} diff --git a/components/index.ts b/components/index.ts index fe97dad..6b7f156 100644 --- a/components/index.ts +++ b/components/index.ts @@ -63,7 +63,6 @@ import DummyLandscapeImage from "./_ShareComponent/DummyLandscapeImage"; import GridComponentView from "./_ShareComponent/GridSectionView"; import NewWrapper from "./_ShareComponent/NewWrapper"; import BasicWrapper from "./_ShareComponent/BasicWrapper"; -import { TestWrapper } from "./_ShareComponent/TestWrapper"; import { FormWrapper } from "./_ShareComponent/FormWrapper"; import { NewWrapper_V2 } from "./_ShareComponent/NewWrapper_V2"; @@ -131,7 +130,6 @@ export { Spacing, NewWrapper, BasicWrapper, - TestWrapper, FormWrapper, NewWrapper_V2, // Stack diff --git a/screens/Job/ScreenJobCreate2.tsx b/screens/Job/ScreenJobCreate2.tsx deleted file mode 100644 index 2ec4dce..0000000 --- a/screens/Job/ScreenJobCreate2.tsx +++ /dev/null @@ -1,183 +0,0 @@ -import { - BoxButtonOnFooter, - ButtonCenteredOnly, - ButtonCustom, - FormWrapper, - InformationBox, - LandscapeFrameUploaded, - Spacing, - StackCustom, - TextAreaCustom, - TextInputCustom, -} from "@/components"; -import { MainColor } from "@/constants/color-palet"; -import DIRECTORY_ID from "@/constants/directory-id"; -import { useKeyboardForm } from "@/hooks/useKeyboardForm"; -import { useAuth } from "@/hooks/use-auth"; -import { apiJobCreate } from "@/service/api-client/api-job"; -import { uploadFileService } from "@/service/upload-service"; -import pickImage from "@/utils/pickImage"; -import { router } from "expo-router"; -import { useState } from "react"; -import { View } from "react-native"; -import Toast from "react-native-toast-message"; - -interface JobCreateData { - title: string; - content: string; - deskripsi: string; - authorId: string; -} - -export function Job_ScreenCreate2() { - const nextUrl = "/(application)/(user)/job/(tabs)/status?status=review"; - const { user } = useAuth(); - const [isLoading, setIsLoading] = useState(false); - const [image, setImage] = useState(null); - const [data, setData] = useState({ - title: "", - content: "", - deskripsi: "", - authorId: "", - }); - - // Use keyboard form hook - const { scrollViewRef, createFocusHandler } = useKeyboardForm(100); - - 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 uploadFileService({ - 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 ( - <> - - handlerOnSubmit()}> - Simpan - - - - ); - }; - - const onFocusHandler = createFocusHandler(); - - return ( - - - - - { - pickImage({ - setImageUri: setImage, - }); - }} - icon="upload" - > - Upload - - - - - true}> - setData({ ...data, title: value })} - onFocus={onFocusHandler} - /> - - - true}> - setData({ ...data, content: value })} - onFocus={onFocusHandler} - /> - - - true}> - setData({ ...data, deskripsi: value })} - onFocus={onFocusHandler} - /> - - - ); -} \ No newline at end of file diff --git a/screens/Job/ScreenJobEdit2.tsx b/screens/Job/ScreenJobEdit2.tsx deleted file mode 100644 index 659f144..0000000 --- a/screens/Job/ScreenJobEdit2.tsx +++ /dev/null @@ -1,207 +0,0 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - BaseBox, - BoxButtonOnFooter, - ButtonCenteredOnly, - ButtonCustom, - DummyLandscapeImage, - InformationBox, - LandscapeFrameUploaded, - LoaderCustom, - NewWrapper_V2, - Spacing, - StackCustom, - TextAreaCustom, - TextInputCustom, -} from "@/components"; -import { AccentColor } from "@/constants/color-palet"; -import DIRECTORY_ID from "@/constants/directory-id"; -import { apiJobGetOne, apiJobUpdateData } from "@/service/api-client/api-job"; -import { deleteFileService, uploadFileService } from "@/service/upload-service"; -import pickImage from "@/utils/pickImage"; -import { router, useLocalSearchParams } from "expo-router"; -import { useEffect, useState } from "react"; -import { View } from "react-native"; -import Toast from "react-native-toast-message"; - -export function Job_ScreenEdit2() { - const { id } = useLocalSearchParams(); - const [data, setData] = useState({ - 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 uploadFileService({ - imageUri: imageUri, - dirId: DIRECTORY_ID.job_image, - }); - - if (responseUploadImage.success) { - newImageId = responseUploadImage.data.id; - } - } - - if (data?.imageId) { - const responseDeleteImage = await deleteFileService({ - 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, - category: "edit", - }); - - 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 ( - <> - - handlerOnUpdate()}> - Update - - - - ); - }; - - return ( - - {isLoadData ? ( - - ) : ( - - - - {imageUri ? ( - - ) : ( - - - - )} - - { - pickImage({ - setImageUri, - }); - }} - icon="upload" - > - Upload - - - - - true}> - setData({ ...data, title: value })} - /> - - - true}> - setData({ ...data, content: value })} - /> - - - true}> - setData({ ...data, deskripsi: value })} - /> - - - )} - - ); -}