refactor project

This commit is contained in:
Alihaghighattalab
2024-08-21 10:36:05 +03:30
parent 4672843399
commit 643f3cb497
9 changed files with 67 additions and 130 deletions
+3 -3
View File
@@ -42,6 +42,7 @@ export const Table: FC<Props> = ({ columns, data, setSorting, sorting, tableStat
<ComboBox placeholder="100" className="bg-auth-form" />
</div>
</div>
{tableStatus && <div className="w-full flex justify-end items-end text-sm lg:text-lg text-primary-text-color font-normal -mb-7 pl-2">امتیاز من: {tableStatus}</div>}
<div className="block max-w-full overflow-x-auto overflow-y-hidden bg-auth-form rounded-[40px] shadow-sm p-4 pb-0 xl:p-9 xl:pb-0 relative">
<table>
<thead className="border-b border-b-secondary-color">
@@ -70,14 +71,13 @@ export const Table: FC<Props> = ({ columns, data, setSorting, sorting, tableStat
))}
</tbody>}
</table>
{isLoading ? <Loading /> : <>
{isLoading ? <Loading /> :
<div className="flex flex-row justify-center items-center border-t p-4 gap-x-3 mt-3">
<ArrowRight2 color="#11212D" size={19} className="cursor-pointer" onClick={() => table.getCanNextPage() && table.nextPage()} />
<p className="text-base font-normal text-primary-text-color">1-{table.getPageCount()}</p>
<ArrowLeft2 color="#11212D" size={19} className="cursor-pointer" onClick={() => table.getCanPreviousPage() && table.previousPage()} />
</div>
{tableStatus && <div className="absolute text-sm bottom-1.5 lg:left-10 lg:top-5 lg:text-lg text-primary-text-color font-normal">امتیاز من: {tableStatus}</div>}
</>}
}
</div>
</div>
);
+1 -1
View File
@@ -12,6 +12,6 @@ export const Score = () => {
queryFn: getScoresList
})
return (
<Table sorting={sorting} setSorting={setSorting} columns={scoresCol} data={data?.data?.data} tableStatus={data?.score} isLoading={isLoading} />
<Table sorting={sorting} setSorting={setSorting} columns={scoresCol} data={data?.data?.data} tableStatus={data?.data?.score} isLoading={isLoading} />
)
}
+2 -16
View File
@@ -1,21 +1,7 @@
import { ScoreResponse } from "../../types";
import axiosInstance from "../axios";
export type ScoreData = {
_id: string,
deviceId: string,
score: number,
created_at: string,
updated_at: string,
__v: number,
userId: string,
id: string
}
export interface ScoreResponse {
data: ScoreData[] | []
score: number,
total: number
}
export const getScoresList = () => axiosInstance.get<ScoreData, any>("/gps/score")
export const getScoresList = () => axiosInstance.get<ScoreResponse, any>("/gps/score")
+1 -27
View File
@@ -1,30 +1,4 @@
import { TransactionsResponse } from "../../types";
import axiosInstance from "../axios";
export interface TransactionsResponse {
data: TransactionsData[] | []
}
export interface TransactionsData {
_id: string,
card: TransactionsCard
userId: string,
amount: number,
dollarAmount: number,
status: number,
created_at: string,
updated_at: string,
__v: number,
id: string
}
export interface TransactionsCard {
_id: string,
holderName: string,
PAN: number,
IBAN: string,
created_at: string,
updated_at: string,
id: string
}
export const getTransactionsList = () => axiosInstance.get<TransactionsResponse>("/gps/withdraw")
+1 -13
View File
@@ -1,17 +1,5 @@
import axiosInstance from "../axios";
export type OverviewUser = {
walletBalance: number,
dollarBalance: number,
score: number,
_id: string,
id: string
}
export interface OverviewResponse {
pending: boolean,
user: OverviewUser
}
import { OverviewResponse } from "./overview";
export const getWalletDetails = () => axiosInstance.get<OverviewResponse[] | OverviewResponse | [], any>("/gps/overview/wallet")
-14
View File
@@ -1,14 +0,0 @@
import { create } from "zustand";
type UserType = {
token: string | null
}
const useUserStore = create<UserType>((set) => ({
token: '',
setToken: (token: string | null) => {
set({ token: token });
},
}));
export default useUserStore;
+57
View File
@@ -218,4 +218,61 @@ export interface AwardsResponse {
updated_at: string,
__v: number,
id: string
}
interface TransactionsData {
_id: string,
card: TransactionsCard
userId: string,
amount: number,
dollarAmount: number,
status: number,
created_at: string,
updated_at: string,
__v: number,
id: string
}
interface TransactionsCard {
_id: string,
holderName: string,
PAN: number,
IBAN: string,
created_at: string,
updated_at: string,
id: string
}
export interface TransactionsResponse {
data: TransactionsData[] | []
}
type OverviewUser = {
walletBalance: number,
dollarBalance: number,
score: number,
_id: string,
id: string
}
export interface OverviewResponse {
pending: boolean,
user: OverviewUser
}
type ScoreData = {
_id: string,
deviceId: string,
score: number,
created_at: string,
updated_at: string,
__v: number,
userId: string,
id: string
}
export interface ScoreResponse {
data: ScoreData[] | []
score: number,
total: number
}