Skip to content

Commit

Permalink
Merge pull request #17 from pieceowater-dev/dev
Browse files Browse the repository at this point in the history
fix: pie and payments
  • Loading branch information
baynt1 authored Sep 11, 2024
2 parents fe9599d + cf8aa07 commit a2cc0d1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/entities/dashboard/payment-data/payment-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ export const usePaymentData = () => {
}, [])

const columns: TableProps<IColumnPayments>['columns'] = [
{
title: 'Платеж №',
dataIndex: 'id',
key: 'id',
},
{
title: 'Статус',
dataIndex: 'status',
key: 'status',
},
{
title: 'Тип',
dataIndex: 'type',
key: 'type',
},
{
title: 'Дата',
dataIndex: 'date',
Expand Down
6 changes: 4 additions & 2 deletions src/entities/dashboard/pie-chart/pie-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const usePieChart = () => {
params: { dateType: dateType, start: start, end: end, posts: posts },
})
if (res.data.length > 0) {
setPieData([res.data[0].sum, res.data[1].sum])
setPieData([res.data?.[0]?.sum || 0, res.data?.[1]?.sum || 0])
} else {
setPieData([0, 0])
}
Expand All @@ -27,7 +27,9 @@ export const usePieChart = () => {
}

useEffect(() => {
fetchData()
if (dateType !== 6 || (start && end)) {
fetchData()
}
}, [dateType, start, end, posts])

const pie = {
Expand Down
2 changes: 2 additions & 0 deletions src/entities/dashboard/table-data/model/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface IRowsPaymentResponse {
id: number
datetime: number | string
sum: string
type: number
result: number
device: {
id: number
name: string
Expand Down
3 changes: 3 additions & 0 deletions src/entities/dashboard/table-data/table-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const useTableData = () => {
const paymentsRows = payments.items.map((row: IRowsPaymentResponse) => {
setPaymentTableSum((prevState) => prevState + transformPrice(row.sum))
return {
id: row.id,
status: row.result === 0 ? 'Не успешный' : 'Успешный',
type: row.type === 0 ? 'Наличные' : 'Безналичные',
key: row.id,
date: row.datetime ? unixDate(+row.datetime * 1000, 'DMYHM') : '',
post: row.device.name,
Expand Down

0 comments on commit a2cc0d1

Please sign in to comment.