Files
hipmi-mobile/app/(application)/admin/job/[id]/[status]/reject-input.tsx
bagasbanuna 0823a1c26a feat: Complete Admin Phase 6 Job screens migration
- Migrate 4 admin job screens to OS_Wrapper (dashboard, list, detail, form)
- Add enableKeyboardHandling to reject-input form screen
- Update TASK-005 with Admin Phase 6 completion status
- Total: 132 files migrated (~79% complete)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-14 12:24:58 +08:00

121 lines
2.9 KiB
TypeScript

/* eslint-disable react-hooks/exhaustive-deps */
import {
AlertDefaultSystem,
BoxButtonOnFooter,
OS_Wrapper,
TextAreaCustom,
} from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
import funUpdateStatusJob from "@/screens/Admin/Job/funUpdateStatus";
import { apiAdminJobGetById } from "@/service/api-admin/api-admin-job";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import { useCallback, useState } from "react";
import Toast from "react-native-toast-message";
export default function AdminJobRejectInput() {
const { id, status } = useLocalSearchParams();
const [data, setData] = useState({
catatan: "",
senderId: ""
});
const [isLoading, setIsLoading] = useState(false);
useFocusEffect(
useCallback(() => {
onLoadData();
}, [id])
);
const onLoadData = async () => {
try {
const response = await apiAdminJobGetById({
id: id as string,
});
if (response.success) {
setData(response.data.catatan);
}
} catch (error) {
console.log("[ERROR]", error);
}
};
const handleUpdate = async ({
changeStatus,
}: {
changeStatus: "publish" | "review" | "reject";
}) => {
try {
setIsLoading(true);
const response = await funUpdateStatusJob({
id: id as string,
changeStatus,
data: data ,
});
if (!response.success) {
Toast.show({
type: "error",
text1: "Report gagal",
});
}
Toast.show({
type: "success",
text1: "Report berhasil",
});
if (status === "review") {
router.replace(`/admin/job/reject/status`);
} else if (status === "reject") {
router.back();
}
} catch (error) {
console.log("[ERROR]", error);
} finally {
setIsLoading(false);
}
};
const buttonSubmit = (
<BoxButtonOnFooter>
<AdminButtonReject
isLoading={isLoading}
title="Report"
onReject={() =>
AlertDefaultSystem({
title: "Reject",
message: "Apakah anda yakin ingin menolak data ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
handleUpdate({ changeStatus: "reject" });
},
})
}
/>
</BoxButtonOnFooter>
);
return (
<>
<OS_Wrapper
enableKeyboardHandling
contentPaddingBottom={250}
footerComponent={buttonSubmit}
headerComponent={<AdminBackButtonAntTitle title="Penolakan Job" />}
>
<TextAreaCustom
value={data?.catatan}
onChangeText={(text) => setData({ ...data, catatan: text })}
placeholder="Masukan alasan"
required
showCount
maxLength={1000}
/>
</OS_Wrapper>
</>
);
}