diff --git a/app/(application)/(user)/_layout.tsx b/app/(application)/(user)/_layout.tsx index 7d75dd1..f6779c5 100644 --- a/app/(application)/(user)/_layout.tsx +++ b/app/(application)/(user)/_layout.tsx @@ -616,6 +616,15 @@ export default function UserLayout() { headerLeft: () => , }} /> + , + }} + /> + + {/* ========== Maps Section ========= */} (null); - const [listComment, setListComment] = useState(null); + const [listComment, setListComment] = useState(null); const [isLoadingComment, setLoadingComment] = useState(false); // Status @@ -122,6 +108,7 @@ export default function ForumDetail() { comment: text, authorId: user?.id, }; + try { setLoadingComment(true); const response = await apiForumCreateComment({ diff --git a/app/(application)/(user)/forum/[id]/preview-report-posting.tsx b/app/(application)/(user)/forum/[id]/preview-report-posting.tsx new file mode 100644 index 0000000..8e1e20a --- /dev/null +++ b/app/(application)/(user)/forum/[id]/preview-report-posting.tsx @@ -0,0 +1,43 @@ +import { NewWrapper, TextCustom } from "@/components"; +import { useAuth } from "@/hooks/use-auth"; +import { + apiForumGetOne, + apiForumGetReportPosting, +} from "@/service/api-client/api-forum"; +import { useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useState } from "react"; + +export default function ForumPreviewReportPosting() { + const { id } = useLocalSearchParams(); + const { user } = useAuth(); + const [data, setData] = useState(null); + // Status + + useFocusEffect( + useCallback(() => { + onLoadData(id as string); + }, [id]) + ); + + const onLoadData = async (id: string) => { + try { + const response = await apiForumGetReportPosting({ id }); + setData(response.data); + } catch (error) { + console.log("[ERROR]", error); + } + }; + + return ( + <> + + + Halaman preview repost posting + {JSON.stringify(data, null, 2)} + + untuk report jomentar beda halaman + + + + ); +} diff --git a/app/(application)/(user)/forum/create.tsx b/app/(application)/(user)/forum/create.tsx index 8599bbf..6dd88ba 100644 --- a/app/(application)/(user)/forum/create.tsx +++ b/app/(application)/(user)/forum/create.tsx @@ -2,15 +2,14 @@ import { BoxButtonOnFooter, ButtonCustom, TextAreaCustom, - ViewWrapper + ViewWrapper, } from "@/components"; import AlertWarning from "@/components/Alert/AlertWarning"; import { useAuth } from "@/hooks/use-auth"; import { apiForumCreate } from "@/service/api-client/api-forum"; -import { isBadContent } from "@/utils/badWordsIndonesia"; +import { censorText, isBadContent } from "@/utils/badWordsIndonesia"; import { router } from "expo-router"; import { useState } from "react"; -import { Alert } from "react-native"; import Toast from "react-native-toast-message"; export default function ForumCreate() { @@ -19,16 +18,22 @@ export default function ForumCreate() { const [isLoading, setIsLoading] = useState(false); const handlerSubmit = async () => { - - if (isBadContent(text)) { - AlertWarning({}) + if (text.trim() === "") { + AlertWarning({ + title: "Lengkapi Data", + description: "Postingan tidak boleh kosong", + }); return; } - + + // Bisa di sensor atau return dan tidak bisa di post + const cencorContent = censorText(text) + const newData = { - diskusi: text, + diskusi: cencorContent, authorId: user?.id, }; + try { setIsLoading(true); const response = await apiForumCreate({ data: newData }); @@ -50,6 +55,7 @@ export default function ForumCreate() { const buttonFooter = ( { handlerSubmit(); diff --git a/app/(application)/admin/forum/[id]/list-report-posting.tsx b/app/(application)/admin/forum/[id]/list-report-posting.tsx index faedf07..e26b625 100644 --- a/app/(application)/admin/forum/[id]/list-report-posting.tsx +++ b/app/(application)/admin/forum/[id]/list-report-posting.tsx @@ -16,12 +16,11 @@ import { IconDot, IconView } from "@/components/_Icon/IconComponent"; import { IconTrash } from "@/components/_Icon/IconTrash"; import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle"; -import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue"; import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; import { MainColor } from "@/constants/color-palet"; import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; +import { useAuth } from "@/hooks/use-auth"; import { apiAdminForumDeactivatePosting, apiAdminForumListReportPostingById, @@ -35,6 +34,7 @@ import { Divider } from "react-native-paper"; import Toast from "react-native-toast-message"; export default function AdminForumReportPosting() { + const { user } = useAuth(); const { id } = useLocalSearchParams(); const [openDrawerPage, setOpenDrawerPage] = useState(false); const [openDrawerAction, setOpenDrawerAction] = useState(false); @@ -215,6 +215,9 @@ export default function AdminForumReportPosting() { onPressRight: async () => { const response = await apiAdminForumDeactivatePosting({ id: id as string, + data: { + senderId: user?.id as string, + }, }); if (!response.success) { diff --git a/screens/Home/tabsList.ts b/screens/Home/tabsList.ts index a29f31c..0a57395 100644 --- a/screens/Home/tabsList.ts +++ b/screens/Home/tabsList.ts @@ -13,7 +13,8 @@ export const tabsHome: any = ({ icon: "chatbubble-ellipses-outline", activeIcon: "chatbubble-ellipses", label: "Forum", - path: acceptedForumTermsAt ? "/forum" : "/forum/terms", + // path: acceptedForumTermsAt ? "/forum" : "/forum/terms", + path: "/forum", isActive: true, disabled: false, }, diff --git a/service/api-admin/api-admin-forum.ts b/service/api-admin/api-admin-forum.ts index 82b4a10..9306525 100644 --- a/service/api-admin/api-admin-forum.ts +++ b/service/api-admin/api-admin-forum.ts @@ -81,9 +81,17 @@ export async function apiAdminForumListReportPostingById({ } } -export async function apiAdminForumDeactivatePosting({ id }: { id: string }) { +export async function apiAdminForumDeactivatePosting({ + id, + data, +}: { + id: string; + data: { senderId: string }; +}) { try { - const response = await apiConfig.put(`/mobile/admin/forum/${id}`); + const response = await apiConfig.put(`/mobile/admin/forum/${id}`, { + data: data, + }); return response.data; } catch (error) { throw error; diff --git a/service/api-client/api-forum.ts b/service/api-client/api-forum.ts index 9e3c4e3..17c6dc9 100644 --- a/service/api-client/api-forum.ts +++ b/service/api-client/api-forum.ts @@ -119,3 +119,12 @@ export async function apiForumDeleteComment({ id }: { id: string }) { throw error; } } + +export async function apiForumGetReportPosting({id}: {id:string}) { + try { + const response = await apiConfig.get(`/mobile/forum/${id}/preview-report-posting`); + return response.data; + } catch (error) { + throw error; + } +} \ No newline at end of file diff --git a/types/type-forum.ts b/types/type-forum.ts new file mode 100644 index 0000000..c55fd78 --- /dev/null +++ b/types/type-forum.ts @@ -0,0 +1,15 @@ +export interface TypeForum_CommentProps { + id: string; + isActive: boolean; + komentar: string; + createdAt: Date; + authorId: string; + Author: { + id: string; + username: string; + Profile: { + id: string; + imageId: string; + }; + }; +} \ No newline at end of file