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,10 +1,10 @@
import ScreenNotification from "@/screens/Notification/ScreenNotification_V2";
import ScreenNotification_V1 from "@/screens/Notification/ScreenNotification_V1"; import ScreenNotification_V1 from "@/screens/Notification/ScreenNotification_V1";
import ScreenNotification_V2 from "@/screens/Notification/ScreenNotification_V2";
export default function Notification() { export default function Notification() {
return ( return (
<> <>
<ScreenNotification /> <ScreenNotification_V2 />
{/* <ScreenNotification_V1 /> */} {/* <ScreenNotification_V1 /> */}
</> </>
); );

View File

@@ -25,3 +25,7 @@ Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan
Terapkan NewWrapper pada file: screens/Forum/DetailForum.tsx 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 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 { IconPlus } from "@/components/_Icon";
import { IconDot } from "@/components/_Icon/IconComponent"; import { IconDot } from "@/components/_Icon/IconComponent";
import { AccentColor, MainColor } from "@/constants/color-palet"; 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 { createPaginationComponents } from "@/helpers/paginationHelpers";
import { useAuth } from "@/hooks/use-auth"; import { useAuth } from "@/hooks/use-auth";
import { useNotificationStore } from "@/hooks/use-notification-store"; import { useNotificationStore } from "@/hooks/use-notification-store";
@@ -26,8 +26,6 @@ import _ from "lodash";
import { useState } from "react"; import { useState } from "react";
import { RefreshControl, View } from "react-native"; import { RefreshControl, View } from "react-native";
const PAGE_SIZE = 10;
const selectedCategory = (value: string) => { const selectedCategory = (value: string) => {
const category = listOfcategoriesAppNotification.find( const category = listOfcategoriesAppNotification.find(
(c) => c.value === value, (c) => c.value === value,
@@ -35,6 +33,37 @@ const selectedCategory = (value: string) => {
return category?.label; 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 = ({ const BoxNotification = ({
data, data,
activeCategory, activeCategory,
@@ -50,17 +79,22 @@ const BoxNotification = ({
<BaseBox <BaseBox
backgroundColor={data.isRead ? AccentColor.darkblue : AccentColor.blue} backgroundColor={data.isRead ? AccentColor.darkblue : AccentColor.blue}
onPress={() => { onPress={() => {
console.log( const newPath = fixPath({
"Notification >", deepLink: data.deepLink,
selectedCategory(activeCategory as string), categoryApp: data.kategoriApp,
); });
router.push(data.deepLink);
selectedCategory(activeCategory as string);
router.navigate(newPath as any);
if (!data.isRead) {
markAsRead(data.id); markAsRead(data.id);
setListData((prev: any) => setListData((prev: any) =>
prev.map((item: any) => prev.map((item: any) =>
item.id === data.id ? { ...item, isRead: true } : item, item.id === data.id ? { ...item, isRead: true } : item,
), ),
); );
}
}} }}
> >
<StackCustom> <StackCustom>
@@ -97,7 +131,7 @@ export default function Admin_ScreenNotification2() {
page: String(page), page: String(page),
}); });
}, },
pageSize: PAGE_SIZE, pageSize: PAGINATION_DEFAULT_TAKE,
dependencies: [user?.id, activeCategory], dependencies: [user?.id, activeCategory],
onError: (error) => onError: (error) =>
console.error("[ERROR] Fetch admin notifications:", error), console.error("[ERROR] Fetch admin notifications:", error),
@@ -110,7 +144,7 @@ export default function Admin_ScreenNotification2() {
refreshing: pagination.refreshing, refreshing: pagination.refreshing,
listData: pagination.listData, listData: pagination.listData,
emptyMessage: "Belum ada notifikasi", emptyMessage: "Belum ada notifikasi",
skeletonCount: 5, skeletonCount: PAGINATION_DEFAULT_TAKE,
skeletonHeight: 100, skeletonHeight: 100,
}); });

View File

@@ -52,6 +52,9 @@ const fixPath = ({
return deepLink; return deepLink;
} }
console.log("Category App", categoryApp);
console.log("Deep Link", deepLink);
const separator = deepLink.includes("?") ? "&" : "?"; const separator = deepLink.includes("?") ? "&" : "?";
const fixedPath = `${deepLink}${separator}from=notifications&category=${_.lowerCase( const fixedPath = `${deepLink}${separator}from=notifications&category=${_.lowerCase(
@@ -83,8 +86,8 @@ const BoxNotification = ({
categoryApp: data.kategoriApp, categoryApp: data.kategoriApp,
}); });
router.navigate(newPath as any);
selectedCategory(activeCategory as string); selectedCategory(activeCategory as string);
router.navigate(newPath as any);
if (!data.isRead) { if (!data.isRead) {
markAsRead(data.id); markAsRead(data.id);
@@ -112,7 +115,7 @@ const BoxNotification = ({
); );
}; };
export default function ScreenNotification() { export default function ScreenNotification_V2() {
const { user } = useAuth(); const { user } = useAuth();
const { category } = useLocalSearchParams<{ category?: string }>(); const { category } = useLocalSearchParams<{ category?: string }>();
const [activeCategory, setActiveCategory] = useState<string | null>( const [activeCategory, setActiveCategory] = useState<string | null>(
@@ -140,7 +143,7 @@ export default function ScreenNotification() {
// useFocusEffect( // useFocusEffect(
// useCallback(() => { // useCallback(() => {
// // Reset and load first page when category changes // // Reset and load first page when category changes
// pagination.reset();
// pagination.onRefresh(); // pagination.onRefresh();
// }, [activeCategory]), // }, [activeCategory]),
// ); // );
@@ -171,7 +174,7 @@ export default function ScreenNotification() {
listData: pagination.listData, listData: pagination.listData,
isInitialLoad: pagination.isInitialLoad, isInitialLoad: pagination.isInitialLoad,
emptyMessage: "Belum ada notifikasi", emptyMessage: "Belum ada notifikasi",
skeletonCount: 5, skeletonCount: PAGINATION_DEFAULT_TAKE,
skeletonHeight: 100, skeletonHeight: 100,
}); });
@@ -237,7 +240,6 @@ export default function ScreenNotification() {
}, },
]} ]}
onPressItem={(item: any) => { onPressItem={(item: any) => {
// console.log("Item", item.value);
if (item.value === "read-all") { if (item.value === "read-all") {
AlertDefaultSystem({ AlertDefaultSystem({
title: "Tandai Semua Dibaca", title: "Tandai Semua Dibaca",

View File

@@ -47,9 +47,8 @@ export async function apiGetNotificationsById({
category: TypeNotificationCategoryApp; category: TypeNotificationCategoryApp;
page?: string; page?: string;
}) { }) {
console.log("ID", id);
console.log("Category", category); console.log("Category", category);
console.log("Page", page);
try { try {
const response = await apiConfig.get( const response = await apiConfig.get(