-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: payment order table conflic resolved
- Loading branch information
Showing
14 changed files
with
279 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import type { ColorScheme } from '@mantine/core' | ||
import { ColorSchemeProvider, MantineProvider } from '@mantine/core' | ||
import { useHotkeys, useLocalStorage } from '@mantine/hooks' | ||
import { useEffect } from 'react' | ||
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom' | ||
|
||
import Layout from '@/components/Layout/Layout' | ||
|
@@ -13,6 +14,7 @@ import { | |
ProductAnalytics, | ||
Users | ||
} from '@/screens' | ||
import { server } from '@/utils/server' | ||
|
||
function App() { | ||
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({ | ||
|
@@ -25,6 +27,25 @@ function App() { | |
setColorScheme(value || (colorScheme === 'dark' ? 'light' : 'dark')) | ||
|
||
useHotkeys([['mod+J', () => toggleColorScheme()]]) | ||
|
||
useEffect(() => { | ||
const login = async () => { | ||
await server.post( | ||
'/users/login', | ||
{ | ||
email: '[email protected]', | ||
password: '12345678' | ||
}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
withCredentials: true | ||
} | ||
) | ||
} | ||
login() | ||
}, []) | ||
return ( | ||
<MantineProvider | ||
theme={{ colorScheme, primaryColor: 'yellow' }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Badge, Flex, Table, Text, Tooltip } from '@mantine/core' | ||
import { IconCurrencyRupee } from '@tabler/icons' | ||
import dayjs from 'dayjs' | ||
import { useQuery } from 'react-query' | ||
|
||
import { getTransactionHistory } from '@/graphql/main' | ||
import { server } from '@/utils/server' | ||
|
||
type TransactionElementType = { | ||
name: string | ||
status: string | ||
amount: number | ||
orderId: string | ||
date: string | ||
} | ||
|
||
const fetchTransactions = async () => { | ||
const res = await server.post('/graphql', { | ||
query: getTransactionHistory | ||
}) | ||
const { docs } = res.data.data.Orders | ||
const rows = docs.map((item: any) => { | ||
const { firstName } = item.user | ||
const orderId = item.payment.orderCreationId | ||
const date = dayjs(item.createdAt).format('MMMM DD, YYYY') | ||
return { | ||
name: firstName, | ||
amount: item.orderAmount, | ||
orderId, | ||
status: item.orderStatus, | ||
date | ||
} | ||
}) | ||
return rows | ||
} | ||
|
||
export default function TransactionHistory() { | ||
const { data, isLoading, error } = useQuery( | ||
'transaction-history', | ||
fetchTransactions, | ||
{ | ||
retry: 1, | ||
refetchOnWindowFocus: false, | ||
refetchOnReconnect: false | ||
} | ||
) | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div> | ||
} | ||
if (error instanceof Error) { | ||
return <div>{error!.message}</div> | ||
} | ||
const rows = data.map((element: TransactionElementType) => ( | ||
<tr key={element.orderId}> | ||
<td> | ||
<Text weight={700} variant="gradient"> | ||
{element.name} | ||
</Text> | ||
</td> | ||
<td> | ||
<Tooltip label={element.orderId}> | ||
<Text underline>{`${element.orderId}`.slice(0, 10)}</Text> | ||
</Tooltip> | ||
</td> | ||
<td> | ||
<Flex align="center"> | ||
<IconCurrencyRupee size={16} /> | ||
<Text mb={1}>{element.amount}</Text> | ||
</Flex> | ||
</td> | ||
<td> | ||
<Badge color={'grape'}>{element.status}</Badge> | ||
</td> | ||
<td>{element.date}</td> | ||
</tr> | ||
)) | ||
|
||
return ( | ||
<Table verticalSpacing="md" striped highlightOnHover withBorder> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>OrderId</th> | ||
<th>Amount</th> | ||
<th>Status</th> | ||
<th>Date</th> | ||
</tr> | ||
</thead> | ||
<tbody>{rows}</tbody> | ||
</Table> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as OrderTable } from './OrderTable' | ||
export { default as TransactionTable } from './Transaction' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const getTransactionHistory = ` | ||
query { | ||
Orders { | ||
docs { | ||
id | ||
user { | ||
firstName | ||
} | ||
orderStatus | ||
orderAmount | ||
payment { | ||
orderCreationId | ||
} | ||
} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/* eslint-disable prettier/prettier */ | ||
export const COLORS = { | ||
primary: '#DAB444', | ||
secondary: '#099268' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import axios from 'axios' | ||
|
||
export const server = axios.create({ | ||
baseURL: 'http://localhost:5000/api' | ||
baseURL: 'http://localhost:5000/api', | ||
withCredentials: true | ||
}) |
Oops, something went wrong.