generated from pieceowater-dev/openAPI-frontend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from pieceowater-dev/dev
Dev
- Loading branch information
Showing
15 changed files
with
122 additions
and
5 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
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,3 @@ | ||
import { usePaymentData } from 'entities/dashboard/payment-data/payment-data' | ||
|
||
export { usePaymentData } |
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,5 @@ | ||
export interface IColumnPayments { | ||
date: string | ||
post: string | ||
sum: string | ||
} |
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,46 @@ | ||
import { TableProps } from 'antd' | ||
import { useNotify } from 'app/providers/app' | ||
import { IColumnPayments } from 'entities/dashboard/payment-data/model/interface' | ||
import { useEffect } from 'react' | ||
import { getAxiosInstance } from 'shared/api/api-query/api-query' | ||
import { setPaymentsState } from 'shared/redux/dashboard/dashboard-slice' | ||
import { useAppDispatch } from 'shared/redux/store' | ||
|
||
export const usePaymentData = () => { | ||
const { openNotification } = useNotify() | ||
const dispatch = useAppDispatch() | ||
|
||
const fetchData = async () => { | ||
try { | ||
const axiosInstance = await getAxiosInstance() | ||
const res = await axiosInstance.get('/payments') | ||
dispatch(setPaymentsState(res.data)) | ||
} catch (error) { | ||
openNotification('Произошла ошибка при загрузке данных о пользователях') | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
fetchData() | ||
}, []) | ||
|
||
const columns: TableProps<IColumnPayments>['columns'] = [ | ||
{ | ||
title: 'Дата', | ||
dataIndex: 'date', | ||
key: 'date', | ||
}, | ||
{ | ||
title: 'Пост', | ||
dataIndex: 'post', | ||
key: 'post', | ||
}, | ||
{ | ||
title: 'Сумма', | ||
dataIndex: 'sum', | ||
key: 'sum', | ||
}, | ||
] | ||
|
||
return { fetchData, columns } | ||
} |
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,26 @@ | ||
import { Table } from 'antd' | ||
import { usePaymentData } from 'entities/dashboard/payment-data' | ||
import { FC } from 'react' | ||
import { useAppSelector } from 'shared/redux/store' | ||
|
||
export const Dashboard: FC = () => { | ||
const { fetchData, columns } = usePaymentData() | ||
const payments = useAppSelector((state) => state.dashboard.payments) | ||
|
||
console.log(payments) | ||
|
||
return ( | ||
<> | ||
<Table | ||
columns={columns} | ||
dataSource={[]} | ||
bordered={true} | ||
showHeader={true} | ||
tableLayout={'fixed'} | ||
pagination={{ | ||
total: 0, | ||
}} | ||
/> | ||
</> | ||
) | ||
} |
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,3 @@ | ||
import { Dashboard } from 'pages/dashboard/dashboard' | ||
|
||
export default Dashboard |
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ export const Posts: FC = () => { | |
handlePostModal() | ||
}} | ||
> | ||
Новый пост | ||
+ | ||
</Button> | ||
</Flex> | ||
|
||
|
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ export const Users: FC = () => { | |
handleUserOpen() | ||
}} | ||
> | ||
Новый пользователь | ||
+ | ||
</Button> | ||
</Flex> | ||
|
||
|
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,19 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
const initialState = { | ||
payments: { items: [], total: { count: 0 } }, | ||
} | ||
|
||
export const DashboardSlice = createSlice({ | ||
name: 'dashboard', | ||
initialState, | ||
reducers: { | ||
setPaymentsState: (state, action) => { | ||
state.payments = action.payload | ||
}, | ||
}, | ||
}) | ||
|
||
export const { setPaymentsState } = DashboardSlice.actions | ||
|
||
export default DashboardSlice.reducer |
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