diff --git a/app/(application)/(user)/notifications/index.tsx b/app/(application)/(user)/notifications/index.tsx index 2e2c57b..01bec9a 100644 --- a/app/(application)/(user)/notifications/index.tsx +++ b/app/(application)/(user)/notifications/index.tsx @@ -1,11 +1,11 @@ -import ScreenNotification from "@/screens/Notification/ScreenNotification_V2"; import ScreenNotification_V1 from "@/screens/Notification/ScreenNotification_V1"; +import ScreenNotification_V2 from "@/screens/Notification/ScreenNotification_V2"; export default function Notification() { return ( <> - - {/* */} + + {/* */} ); } diff --git a/docs/prompt-for-qwen-code.md b/docs/prompt-for-qwen-code.md index a1f8989..952b35a 100644 --- a/docs/prompt-for-qwen-code.md +++ b/docs/prompt-for-qwen-code.md @@ -24,4 +24,8 @@ Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan Terapkan NewWrapper pada file: screens/Forum/DetailForum.tsx Component yang digunakan: components/_ShareComponent/NewWrapper.tsx , karena ini adalah halaman detail saya ingin anda fokus pada props pada NewWrapper. Seperti - \ No newline at end of file + + +Bantu saya untuk memperbaiki logika path yang ada di dalam file "screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx" , pada function fixPath +Saya ingin jika didalam deeplink ada "/admin/..." contoh "/admin/event/review/status" maka path yang akan di redirect adalah "/admin/event/review/status" +jika tidak maka terapkan sesuai dengan logika yang sudah ada diff --git a/screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx b/screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx index 26816b5..6ef400a 100644 --- a/screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx +++ b/screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx @@ -12,7 +12,7 @@ import { import { IconPlus } from "@/components/_Icon"; import { IconDot } from "@/components/_Icon/IconComponent"; import { AccentColor, MainColor } from "@/constants/color-palet"; -import { ICON_SIZE_SMALL } from "@/constants/constans-value"; +import { ICON_SIZE_SMALL, PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value"; import { createPaginationComponents } from "@/helpers/paginationHelpers"; import { useAuth } from "@/hooks/use-auth"; import { useNotificationStore } from "@/hooks/use-notification-store"; @@ -26,8 +26,6 @@ import _ from "lodash"; import { useState } from "react"; import { RefreshControl, View } from "react-native"; -const PAGE_SIZE = 10; - const selectedCategory = (value: string) => { const category = listOfcategoriesAppNotification.find( (c) => c.value === value, @@ -35,6 +33,37 @@ const selectedCategory = (value: string) => { return category?.label; }; +const fixPath = ({ + deepLink, + categoryApp, +}: { + deepLink: string; + categoryApp: string; +}) => { + // Jika categoryApp adalah "OTHER", kembalikan deepLink tanpa perubahan + if (categoryApp === "OTHER") { + return deepLink; + } + + // Jika dalam deepLink terdapat "/admin/", kembalikan path tersebut tanpa modifikasi tambahan + if (deepLink.includes("/admin/")) { + return deepLink; + } + + console.log("Category App", categoryApp); + console.log("Deep Link", deepLink); + + const separator = deepLink.includes("?") ? "&" : "?"; + + const fixedPath = `${deepLink}${separator}from=notifications&category=${_.lowerCase( + categoryApp, + )}`; + + console.log("Fix Path", fixedPath); + + return fixedPath; +}; + const BoxNotification = ({ data, activeCategory, @@ -50,17 +79,22 @@ const BoxNotification = ({ { - console.log( - "Notification >", - selectedCategory(activeCategory as string), - ); - router.push(data.deepLink); - markAsRead(data.id); - setListData((prev: any) => - prev.map((item: any) => - item.id === data.id ? { ...item, isRead: true } : item, - ), - ); + const newPath = fixPath({ + deepLink: data.deepLink, + categoryApp: data.kategoriApp, + }); + + selectedCategory(activeCategory as string); + router.navigate(newPath as any); + + if (!data.isRead) { + markAsRead(data.id); + setListData((prev: any) => + prev.map((item: any) => + item.id === data.id ? { ...item, isRead: true } : item, + ), + ); + } }} > @@ -97,7 +131,7 @@ export default function Admin_ScreenNotification2() { page: String(page), }); }, - pageSize: PAGE_SIZE, + pageSize: PAGINATION_DEFAULT_TAKE, dependencies: [user?.id, activeCategory], onError: (error) => console.error("[ERROR] Fetch admin notifications:", error), @@ -110,7 +144,7 @@ export default function Admin_ScreenNotification2() { refreshing: pagination.refreshing, listData: pagination.listData, emptyMessage: "Belum ada notifikasi", - skeletonCount: 5, + skeletonCount: PAGINATION_DEFAULT_TAKE, skeletonHeight: 100, }); diff --git a/screens/Notification/ScreenNotification_V2.tsx b/screens/Notification/ScreenNotification_V2.tsx index f4f12cb..a58878d 100644 --- a/screens/Notification/ScreenNotification_V2.tsx +++ b/screens/Notification/ScreenNotification_V2.tsx @@ -52,6 +52,9 @@ const fixPath = ({ return deepLink; } + console.log("Category App", categoryApp); + console.log("Deep Link", deepLink); + const separator = deepLink.includes("?") ? "&" : "?"; const fixedPath = `${deepLink}${separator}from=notifications&category=${_.lowerCase( @@ -83,8 +86,8 @@ const BoxNotification = ({ categoryApp: data.kategoriApp, }); - router.navigate(newPath as any); selectedCategory(activeCategory as string); + router.navigate(newPath as any); if (!data.isRead) { markAsRead(data.id); @@ -112,7 +115,7 @@ const BoxNotification = ({ ); }; -export default function ScreenNotification() { +export default function ScreenNotification_V2() { const { user } = useAuth(); const { category } = useLocalSearchParams<{ category?: string }>(); const [activeCategory, setActiveCategory] = useState( @@ -140,7 +143,7 @@ export default function ScreenNotification() { // useFocusEffect( // useCallback(() => { // // Reset and load first page when category changes - // pagination.reset(); + // pagination.onRefresh(); // }, [activeCategory]), // ); @@ -171,7 +174,7 @@ export default function ScreenNotification() { listData: pagination.listData, isInitialLoad: pagination.isInitialLoad, emptyMessage: "Belum ada notifikasi", - skeletonCount: 5, + skeletonCount: PAGINATION_DEFAULT_TAKE, skeletonHeight: 100, }); @@ -237,7 +240,6 @@ export default function ScreenNotification() { }, ]} onPressItem={(item: any) => { - // console.log("Item", item.value); if (item.value === "read-all") { AlertDefaultSystem({ title: "Tandai Semua Dibaca", diff --git a/service/api-notifications.ts b/service/api-notifications.ts index 212e335..68b0bd9 100644 --- a/service/api-notifications.ts +++ b/service/api-notifications.ts @@ -47,9 +47,8 @@ export async function apiGetNotificationsById({ category: TypeNotificationCategoryApp; page?: string; }) { - console.log("ID", id); + console.log("Category", category); - console.log("Page", page); try { const response = await apiConfig.get(