FixL
modified: app/(application)/(user)/_layout.tsx
modified: app/(application)/(user)/forum/[id]/index.tsx
modified: app/(application)/(user)/forum/create.tsx
modified: app/(application)/admin/forum/[id]/list-report-posting.tsx
modified: screens/Home/tabsList.ts
modified: service/api-admin/api-admin-forum.ts
modified: service/api-client/api-forum.ts
Add:
app/(application)/(user)/forum/[id]/preview-report-posting.tsx
types/type-forum.ts
### No Issue
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import {
|
|
BoxButtonOnFooter,
|
|
ButtonCustom,
|
|
TextAreaCustom,
|
|
ViewWrapper,
|
|
} from "@/components";
|
|
import AlertWarning from "@/components/Alert/AlertWarning";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { apiForumCreate } from "@/service/api-client/api-forum";
|
|
import { censorText, isBadContent } from "@/utils/badWordsIndonesia";
|
|
import { router } from "expo-router";
|
|
import { useState } from "react";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function ForumCreate() {
|
|
const { user } = useAuth();
|
|
const [text, setText] = useState("");
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const handlerSubmit = async () => {
|
|
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: cencorContent,
|
|
authorId: user?.id,
|
|
};
|
|
|
|
try {
|
|
setIsLoading(true);
|
|
const response = await apiForumCreate({ data: newData });
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Posting berhasil",
|
|
});
|
|
setText("");
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
const buttonFooter = (
|
|
<BoxButtonOnFooter>
|
|
<ButtonCustom
|
|
disabled={!text.trim() || isLoading}
|
|
isLoading={isLoading}
|
|
onPress={() => {
|
|
handlerSubmit();
|
|
}}
|
|
>
|
|
Posting
|
|
</ButtonCustom>
|
|
</BoxButtonOnFooter>
|
|
);
|
|
|
|
return (
|
|
<ViewWrapper footerComponent={buttonFooter}>
|
|
<TextAreaCustom
|
|
placeholder="Ketik diskusi anda..."
|
|
maxLength={1000}
|
|
showCount
|
|
value={text}
|
|
onChangeText={setText}
|
|
/>
|
|
</ViewWrapper>
|
|
);
|
|
}
|