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:
@@ -1,11 +1,11 @@
|
|||||||
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 /> */}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,8 @@ Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan
|
|||||||
<!-- Start Penerapan NewWrapper -->
|
<!-- Start Penerapan NewWrapper -->
|
||||||
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
|
||||||
|
|||||||
@@ -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);
|
|
||||||
markAsRead(data.id);
|
selectedCategory(activeCategory as string);
|
||||||
setListData((prev: any) =>
|
router.navigate(newPath as any);
|
||||||
prev.map((item: any) =>
|
|
||||||
item.id === data.id ? { ...item, isRead: true } : item,
|
if (!data.isRead) {
|
||||||
),
|
markAsRead(data.id);
|
||||||
);
|
setListData((prev: any) =>
|
||||||
|
prev.map((item: any) =>
|
||||||
|
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,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user