notification + change call back and ...
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
VITE_TOKEN_NAME = 'dsc_token'
|
||||
VITE_REFRESH_TOKEN_NAME = 'dsc_refresh_token'
|
||||
VITE_BASE_URL = 'https://api.danakcorp.com'
|
||||
# VITE_BASE_URL = 'http://192.168.1.124:4000'
|
||||
# VITE_BASE_URL = 'https://api.danakcorp.com'
|
||||
VITE_BASE_URL = 'http://192.168.0.216:4000'
|
||||
+1
-1
@@ -427,7 +427,7 @@
|
||||
"callback": {
|
||||
"title_success": "پرداخت موفق بود!",
|
||||
"desc_success": "پرداخت شما با موفقیت انجام شد. از خرید شما متشکریم!",
|
||||
"order_number": "شماره سفارش",
|
||||
"order_number": "کد رهگیری",
|
||||
"amount": "مبلغ پرداختی",
|
||||
"date": "تاریخ",
|
||||
"back": "بازگشت",
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Carousel } from "@material-tailwind/react";
|
||||
import { useGetAds } from '../ads/hooks/useAdsData'
|
||||
import { AdsDisplayLocation, AdsItemType } from '../ads/types/AdsTypes'
|
||||
import { Pages } from '../../config/Pages'
|
||||
import { useGetQuikAccess } from './hooks/useHomeData'
|
||||
import { useGetDashboardSummary, useGetQuikAccess } from './hooks/useHomeData'
|
||||
import { QuikAccessItemType } from './types/HomeTypes'
|
||||
import ServiceItem from '../../components/ServiceItem'
|
||||
import PageLoading from '../../components/PageLoading'
|
||||
@@ -22,6 +22,7 @@ const Home: FC = () => {
|
||||
const { t } = useTranslation('global')
|
||||
const getAds = useGetAds(AdsDisplayLocation.HOMEPAGE_TOP)
|
||||
const getQuikAccess = useGetQuikAccess()
|
||||
const getDashboard = useGetDashboardSummary()
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@@ -29,7 +30,7 @@ const Home: FC = () => {
|
||||
<title>داناک | پیشخوان</title>
|
||||
</Helmet>
|
||||
{
|
||||
getAds.isPending || getQuikAccess.isPending ?
|
||||
getAds.isPending || getQuikAccess.isPending || getDashboard.isPending ?
|
||||
<div className='mt-5'>
|
||||
<PageLoading />
|
||||
</div>
|
||||
@@ -78,7 +79,7 @@ const Home: FC = () => {
|
||||
title={t('home.myservice')}
|
||||
icon={<Element3 size={20} color='black' />}
|
||||
color='#00D16C'
|
||||
count={4}
|
||||
count={getDashboard.data?.data?.subscriptionCount}
|
||||
description={t('home.active_service')}
|
||||
link={Pages.services.mine}
|
||||
/>
|
||||
@@ -87,7 +88,7 @@ const Home: FC = () => {
|
||||
title={t('home.ticket')}
|
||||
icon={<Messages3 size={20} color='black' />}
|
||||
color='#FF7B00'
|
||||
count={4}
|
||||
count={getDashboard.data?.data?.ticketCount}
|
||||
description={t('home.unread_messages')}
|
||||
link={Pages.ticket.list}
|
||||
/>
|
||||
@@ -96,7 +97,7 @@ const Home: FC = () => {
|
||||
title={t('receip.receip')}
|
||||
icon={<Receipt21 size={20} color='black' />}
|
||||
color='#0047FF'
|
||||
count={4}
|
||||
count={getDashboard.data?.data?.invoiceCount}
|
||||
description={t('home.receip')}
|
||||
link={Pages.receipts.index}
|
||||
/>
|
||||
@@ -105,7 +106,7 @@ const Home: FC = () => {
|
||||
title={t('home.announcement')}
|
||||
icon={<NotificationStatus size={20} color='black' />}
|
||||
color='#FF0000'
|
||||
count={4}
|
||||
count={getDashboard.data?.data?.announcementCount}
|
||||
description={t('home.unread_announcement')}
|
||||
link={Pages.announcement.list}
|
||||
/>
|
||||
|
||||
@@ -14,6 +14,13 @@ export const useGetQuikAccess = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetDashboardSummary = () => {
|
||||
return useQuery({
|
||||
queryKey: ["dashboard-summary"],
|
||||
queryFn: () => api.getDashboardSummary(),
|
||||
});
|
||||
};
|
||||
|
||||
export const useRemoveQuikAccess = () => {
|
||||
return useMutation({
|
||||
mutationFn: (variables: string) => api.removeQuikAccess(variables),
|
||||
|
||||
@@ -12,6 +12,11 @@ export const getQuikAccess = async () => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getDashboardSummary = async () => {
|
||||
const { data } = await axios.get(`/dashboards/summary`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const removeQuikAccess = async (serviceId: string) => {
|
||||
const { data } = await axios.delete(
|
||||
`/subscriptions/${serviceId}/remove-quick-access`
|
||||
|
||||
@@ -12,19 +12,22 @@ import InfiniteScroll from 'react-infinite-scroll-component';
|
||||
import MoonLoader from "react-spinners/MoonLoader"
|
||||
import Button from '../../components/Button';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useGetDashboardSummary } from '../home/hooks/useHomeData';
|
||||
|
||||
const Notifications: FC = () => {
|
||||
const { t } = useTranslation('global');
|
||||
const ref = useOutsideClick(() => setShowModal(false));
|
||||
const [activeTab, setActiveTab] = useState<'all' | 'read' | 'unread'>('all');
|
||||
const [showModal, setShowModal] = useState<boolean>(false);
|
||||
const { data, fetchNextPage, hasNextPage, refetch } = useGetNotification();
|
||||
const { data, fetchNextPage, hasNextPage, refetch } = useGetNotification(activeTab);
|
||||
const readAll = useReadAll()
|
||||
const posts = data?.pages.flatMap((page) => page.data?.notifications) || [];
|
||||
const getDashboard = useGetDashboardSummary()
|
||||
|
||||
const handleAllRead = () => {
|
||||
readAll.mutate(undefined, {
|
||||
onSuccess: () => {
|
||||
getDashboard.refetch()
|
||||
refetch()
|
||||
toast.success(t('success'))
|
||||
}
|
||||
@@ -33,7 +36,12 @@ const Notifications: FC = () => {
|
||||
|
||||
return (
|
||||
<div ref={ref}>
|
||||
<Notification onClick={() => setShowModal(!showModal)} size={18} color="black" />
|
||||
<div onClick={() => setShowModal(!showModal)} className='relative cursor-pointer'>
|
||||
<Notification size={18} color="black" />
|
||||
<div className="absolute top-0 right-0 -mt-1 -mr-1 rounded-full bg-red-500 text-white text-[8px] size-3 flex justify-center items-center">
|
||||
{getDashboard.data?.data?.notificationCount}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showModal && (
|
||||
<div id='notificationsContainer' className="xl:h-[calc(100%-110px)] h-[70%] p-6 z-50 xl:w-[300px] w-full xl:left-7 left-0 xl:top-[90px] top-0 overflow-y-auto xl:rounded-3xl rounded-b-3xl rounded-t-none fixed modalGlass3 ">
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import * as api from "../service/NotificationService";
|
||||
import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
|
||||
|
||||
export const useGetNotification = () => {
|
||||
export const useGetNotification = (status: "all" | "read" | "unread") => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ["notifications"],
|
||||
queryFn: ({ pageParam = 1 }) => api.getNotifications(pageParam), // فراخوانی API برای گرفتن دادهها
|
||||
queryKey: ["notifications", status],
|
||||
queryFn: ({ pageParam = 1 }) => api.getNotifications(pageParam, status), // فراخوانی API برای گرفتن دادهها
|
||||
initialPageParam: 1, // صفحه اول به طور پیشفرض
|
||||
getNextPageParam: (lastPage) => {
|
||||
const currentPage = lastPage.data?.pager.page;
|
||||
const totalPages = lastPage.data?.pager.totalPages;
|
||||
console.log("hasNextPage check: ", currentPage, totalPages); // بررسی وضعیت صفحات
|
||||
|
||||
return currentPage < totalPages ? currentPage + 1 : undefined;
|
||||
},
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import axios from "../../../config/axios";
|
||||
|
||||
export const getNotifications = async (page: number) => {
|
||||
const { data } = await axios.get(`/notifications?page=${page}`);
|
||||
export const getNotifications = async (
|
||||
page: number,
|
||||
status: "all" | "read" | "unread"
|
||||
) => {
|
||||
let query = ``;
|
||||
if (status !== "all") {
|
||||
query = `&isRead=${status === "read" ? 1 : 0}`;
|
||||
}
|
||||
const { data } = await axios.get(`/notifications?page=${page}${query}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ import { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { NumberFormat } from '../../config/func'
|
||||
import Button from '../../components/Button'
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import moment from 'moment-jalaali'
|
||||
import { Pages } from '../../config/Pages'
|
||||
|
||||
const CallBack: FC = () => {
|
||||
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const { t } = useTranslation('global')
|
||||
|
||||
@@ -94,6 +96,7 @@ const CallBack: FC = () => {
|
||||
<Button
|
||||
label={t('callback.back')}
|
||||
className='xl:max-w-[560px] mt-8'
|
||||
onClick={() => navigate(Pages.transactions)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -177,7 +177,7 @@ const ReceiptsDetail: FC = () => {
|
||||
{t('receip.factor_number')}
|
||||
</div>
|
||||
<div>
|
||||
{getInvoce.data?.data?.invoice.id}
|
||||
{moment(getInvoce.data?.data?.invoice.createdAt).format('jYYYY') + '-' + getInvoce.data?.data?.invoice.numericId}
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex justify-between h-12 border-b items-center'>
|
||||
|
||||
@@ -86,10 +86,10 @@ const ReceiptsList: FC = () => {
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
getInvoices.data?.data?.invoices?.map((item: ReceiptItemType, index: number) => {
|
||||
getInvoices.data?.data?.invoices?.map((item: ReceiptItemType) => {
|
||||
return (
|
||||
<tr className='tr'>
|
||||
<Td text={String(index + 1)} />
|
||||
<Td text={moment(item.createdAt).format('jYYYY') + '-' + item.numericId} />
|
||||
{/* <Td text={item.user.firstName + ' ' + item.user.lastName} /> */}
|
||||
<Td text={''}>
|
||||
<div className='dltr text-right'>
|
||||
|
||||
@@ -16,6 +16,7 @@ export type ReceiptItemType = {
|
||||
dueDate: string;
|
||||
status: "PENDING" | "PAID" | "CANCELED" | "EXPIRED";
|
||||
paidAt: string;
|
||||
numericId: string;
|
||||
};
|
||||
|
||||
export type ReceiptDetailItemType = {
|
||||
|
||||
Reference in New Issue
Block a user