Penambahan fitur block user: 50%
Fix: - app/(application)/(user)/forum/[id]/index.tsx - app/(application)/(user)/home.tsx - screens/Forum/ListPage.tsx - screens/Forum/MenuDrawerSection.tsx/MenuBeranda.tsx - service/api-client/api-master.ts - service/api-client/api-user.ts ### No Issue
This commit is contained in:
@@ -9,15 +9,18 @@ import {
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiForumDelete } from "@/service/api-client/api-forum";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { apiForumBlockUser } from "@/service/api-client/api-user";
|
||||
|
||||
export default function Forum_MenuDrawerBerandaSection({
|
||||
id,
|
||||
authorUsername,
|
||||
status,
|
||||
setIsDrawerOpen,
|
||||
authorId,
|
||||
handlerUpdateStatus,
|
||||
}: {
|
||||
id: string;
|
||||
authorUsername: string;
|
||||
status: string;
|
||||
setIsDrawerOpen: (value: boolean) => void;
|
||||
authorId: string;
|
||||
@@ -25,7 +28,7 @@ export default function Forum_MenuDrawerBerandaSection({
|
||||
}) {
|
||||
const { user } = useAuth();
|
||||
const handlePress = (item: IMenuDrawerItem) => {
|
||||
if (item.label === "Hapus") {
|
||||
if (item.value === "delete") {
|
||||
AlertDefaultSystem({
|
||||
title: "Hapus diskusi",
|
||||
message: "Apakah Anda yakin ingin menghapus diskusi ini?",
|
||||
@@ -34,7 +37,7 @@ export default function Forum_MenuDrawerBerandaSection({
|
||||
onPressRight: async () => {
|
||||
try {
|
||||
const response = await apiForumDelete({ id });
|
||||
|
||||
|
||||
if (response.success) {
|
||||
Toast.show({
|
||||
type: "success",
|
||||
@@ -52,14 +55,46 @@ export default function Forum_MenuDrawerBerandaSection({
|
||||
}
|
||||
},
|
||||
});
|
||||
} else if (item.label === "Buka forum" || item.label === "Tutup forum") {
|
||||
} else if (item.value === "status") {
|
||||
AlertDefaultSystem({
|
||||
title: "Ubah Status",
|
||||
message: "Apakah Anda yakin ingin mengubah status forum ini?",
|
||||
textLeft: "Batal",
|
||||
textRight: "Ubah",
|
||||
onPressRight: () => {
|
||||
handlerUpdateStatus?.(item.label === "Buka forum" ? "Open" : "Closed");
|
||||
handlerUpdateStatus?.(
|
||||
item.label === "Buka forum" ? "Open" : "Closed"
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (item.value === "block") {
|
||||
AlertDefaultSystem({
|
||||
title: "Blockir user",
|
||||
message: `Apakah anda yakin ingin blockir user @${authorUsername}?`,
|
||||
textLeft: "Batal",
|
||||
textRight: "Blockir",
|
||||
onPressRight: async () => {
|
||||
console.log("Blockir");
|
||||
const response = await apiForumBlockUser({
|
||||
data: {
|
||||
menuFeature: "Forum",
|
||||
blockedId: authorId,
|
||||
blockerId: user?.id || "",
|
||||
},
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Berhasil blokir",
|
||||
});
|
||||
router.back();
|
||||
} else {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: response.message,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -76,9 +111,12 @@ export default function Forum_MenuDrawerBerandaSection({
|
||||
data={
|
||||
authorId === user?.id
|
||||
? drawerItemsForumBerandaForAuthor({ id, status })
|
||||
: drawerItemsForumBerandaForNonAuthor({ id })
|
||||
: drawerItemsForumBerandaForNonAuthor({
|
||||
id,
|
||||
username: authorUsername,
|
||||
})
|
||||
}
|
||||
columns={4} // Ubah ke 2 jika ingin 2 kolom per baris
|
||||
columns={authorId === user?.id ? 4 : 2} // Ubah ke 2 jika ingin 2 kolom per baris
|
||||
onPressItem={handlePress as any}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user