Forum Screens (User Phase 5 - 17 files):
- Migrate all forum list, detail, create, and report screens to OS_Wrapper.
- ViewBeranda, ViewBeranda2, ViewBeranda3: List screens with pull-to-refresh.
- DetailForum, DetailForum2: Comment sections with headers (apply disableFlexGrow fix).
- create, edit, report-*, other-report-*, preview-report-*: Forms with keyboard handling.
Admin Phase 9 (User Access - 2 files):
- index.tsx: List with search and pagination.
- [id]/index.tsx: Detail with status toggle footer.
Scroll Fixes (Critical Bugs):
- Fix "Ghost Scroll" in Android FlatList: Removed TouchableWithoutFeedback and KeyboardAvoidingView wrappers in List Mode.
- Fix Large Header Cut-off: Added optional disableFlexGrow={true} to OS_Wrapper for screens with complex ListHeaderComponents (e.g., Forum Detail).
- Fix Keyboard Dismiss: Changed keyboardShouldPersistTaps to "handled" so taps on empty areas dismiss the keyboard while allowing scroll.
Documentation:
- Update TASK-005 with complete Phase 5 details and new progress totals.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import {
|
|
ButtonCustom,
|
|
LoaderCustom,
|
|
OS_Wrapper,
|
|
Spacing,
|
|
StackCustom,
|
|
} from "@/components";
|
|
import { AccentColor, MainColor } from "@/constants/color-palet";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import Forum_ReportListSection from "@/screens/Forum/ReportListSection";
|
|
import { apiForumCreateReportCommentar } from "@/service/api-client/api-forum";
|
|
import { apiMasterForumReportList } from "@/service/api-client/api-master";
|
|
import { router, useLocalSearchParams } from "expo-router";
|
|
import { useState, useEffect } from "react";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function ForumReportCommentar() {
|
|
const { id } = useLocalSearchParams();
|
|
const { user } = useAuth();
|
|
const [selectReport, setSelectReport] = useState<string>("");
|
|
const [listMaster, setListMaster] = useState<any[] | null>(null);
|
|
const [isLoadingList, setIsLoadingList] = useState(false);
|
|
|
|
useEffect(() => {
|
|
onLoadListMaster();
|
|
}, []);
|
|
|
|
const onLoadListMaster = async () => {
|
|
try {
|
|
setIsLoadingList(true);
|
|
const response = await apiMasterForumReportList();
|
|
|
|
setListMaster(response.data);
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
} finally {
|
|
setIsLoadingList(false);
|
|
}
|
|
};
|
|
|
|
const handlerReport = async () => {
|
|
const newData = {
|
|
authorId: user?.id,
|
|
categoryId: selectReport,
|
|
};
|
|
|
|
try {
|
|
const response = await apiForumCreateReportCommentar({
|
|
id: id as string,
|
|
data: newData,
|
|
});
|
|
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Laporan berhasil dikirim",
|
|
});
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
Toast.show({
|
|
type: "error",
|
|
text1: "Gagal",
|
|
text2: "Laporan gagal dikirim",
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<OS_Wrapper>
|
|
{isLoadingList ? (
|
|
<LoaderCustom />
|
|
) : (
|
|
<StackCustom>
|
|
<Forum_ReportListSection
|
|
listMaster={listMaster}
|
|
selectReport={selectReport}
|
|
setSelectReport={setSelectReport}
|
|
/>
|
|
<ButtonCustom
|
|
disabled={!selectReport}
|
|
backgroundColor={MainColor.red}
|
|
textColor={MainColor.white}
|
|
onPress={() => {
|
|
handlerReport();
|
|
}}
|
|
>
|
|
Report
|
|
</ButtonCustom>
|
|
<ButtonCustom
|
|
backgroundColor={AccentColor.blue}
|
|
textColor={MainColor.white}
|
|
onPress={() => {
|
|
router.replace(`/forum/${id}/other-report-commentar`);
|
|
}}
|
|
>
|
|
Lainnya
|
|
</ButtonCustom>
|
|
<Spacing />
|
|
</StackCustom>
|
|
)}
|
|
</OS_Wrapper>
|
|
</>
|
|
);
|
|
}
|