display score user
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
|
'use client';
|
||||||
import { ef } from '@/lib/helpers/utfNumbers'
|
import { ef } from '@/lib/helpers/utfNumbers'
|
||||||
import { Cup, Star1 } from 'iconsax-react'
|
import { Cup, Star1 } from 'iconsax-react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { useGetUserWallet } from '../../hooks/useTransactionData';
|
||||||
|
|
||||||
function TransactionsIndex() {
|
function TransactionsIndex() {
|
||||||
|
|
||||||
|
const { data: userWallet } = useGetUserWallet();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className='pt-6'>
|
<section className='pt-6'>
|
||||||
<h1 className='font-medium'>کدهای تخفیف</h1>
|
<h1 className='font-medium'>کدهای تخفیف</h1>
|
||||||
@@ -28,7 +33,7 @@ function TransactionsIndex() {
|
|||||||
<p className='text-xs mt-[7px]'>با امتیازی که داری سفارش بده!</p>
|
<p className='text-xs mt-[7px]'>با امتیازی که داری سفارش بده!</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className='text-xs font-medium'>مجموع امتیازات شما: {ef('1500')}</p>
|
<p className='text-xs font-medium'>مجموع امتیازات شما: {ef(userWallet?.data?.points?.toString() ?? '0')}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,3 +7,10 @@ export const useGetMyCoupons = () => {
|
|||||||
queryFn: api.getMyCoupons,
|
queryFn: api.getMyCoupons,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useGetUserWallet = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["user-wallet"],
|
||||||
|
queryFn: api.getUserWallet,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import { api } from "@/config/axios";
|
import { api } from "@/config/axios";
|
||||||
import { CouponsResponse } from "../types/Types";
|
import { CouponsResponse, WalletResponse } from "../types/Types";
|
||||||
|
|
||||||
export const getMyCoupons = async (): Promise<CouponsResponse> => {
|
export const getMyCoupons = async (): Promise<CouponsResponse> => {
|
||||||
const { data } = await api.get<CouponsResponse>("/public/coupons/me");
|
const { data } = await api.get<CouponsResponse>("/public/coupons/me");
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUserWallet = async (): Promise<WalletResponse> => {
|
||||||
|
const { data } = await api.get<WalletResponse>("/public/user/wallet");
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|||||||
@@ -25,3 +25,16 @@ export interface Coupon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type CouponsResponse = BaseResponse<Coupon[]>;
|
export type CouponsResponse = BaseResponse<Coupon[]>;
|
||||||
|
|
||||||
|
export interface Wallet {
|
||||||
|
id: string;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
deletedAt: string | null;
|
||||||
|
restaurant: string;
|
||||||
|
user: string;
|
||||||
|
wallet: number;
|
||||||
|
points: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WalletResponse = BaseResponse<Wallet>;
|
||||||
|
|||||||
Reference in New Issue
Block a user