Fix path Notification admin

UI – Notifications (User)
- app/(application)/(user)/notifications/index.tsx
- screens/Notification/ScreenNotification_V2.tsx

UI – Notifications (Admin)
- screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx

API
- service/api-notifications.ts

Docs
- docs/prompt-for-qwen-code.md

### No Issue
This commit is contained in:
2026-02-05 16:37:50 +08:00
parent 72a3d42013
commit 7415c8c8ce
5 changed files with 66 additions and 27 deletions

View File

@@ -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 (
<>
<ScreenNotification />
{/* <ScreenNotification_V1 /> */}
<ScreenNotification_V2 />
{/* <ScreenNotification_V1 /> */}
</>
);
}

View File

@@ -24,4 +24,8 @@ Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan
<!-- Start Penerapan NewWrapper -->
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
<!-- -->
<!-- -->
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

View File

@@ -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 = ({
<BaseBox
backgroundColor={data.isRead ? AccentColor.darkblue : AccentColor.blue}
onPress={() => {
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,
),
);
}
}}
>
<StackCustom>
@@ -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,
});

View File

@@ -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<string | null>(
@@ -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",

View File

@@ -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(