Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nsylwa committed Oct 9, 2023
1 parent 24e9939 commit 463593d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 112 deletions.
2 changes: 1 addition & 1 deletion components/logistic/Logistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Table } from "antd"
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
import DateRangePickerComponent from "../DateRangePicker"
import { logisticColumns, LogisticDataType, logisticStatusFilters, ShippingByStatus } from "./columns"
import { logisticColumns, LogisticDataType, logisticStatusFilters, ShippingByStatus } from "./logistic-columns"

const initialValue = () => ({
created: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Shipping } from "@/interfaces/Shipping"
import { formatDate, formatLocation } from "@/utils"
import { Divider, Tag } from "antd"
import { ColumnsType } from "antd/es/table"
import Link from "next/link"
import { statusMap } from "../Status"
import { ShippingByStatus } from "./logistic-columns"
import styled from "styled-components"
import Link from "next/link"
import { formatDate, formatLocation } from "@/utils"

interface CellContentProps {
data: ShippingByStatus
expand: boolean
}


export const SmallTag = styled.div<{ $status: string }>`
Expand All @@ -21,67 +25,32 @@ export const SmallTag = styled.div<{ $status: string }>`
font-size: 11px;
`

export interface LogisticDataType {
key: string
contentType: string
push2hot: ShippingByStatus
hot2frez: ShippingByStatus
frez2hot: ShippingByStatus
hot2lahta: ShippingByStatus
expand: boolean
const generateToolTip = (shipping: Shipping) => {
const from = formatLocation(shipping.from)
const to = formatLocation(shipping.to)
const tooltip = [
`${from}${to}`,
`${shipping.contentType} ${shipping.count} шт.`,
`${statusMap.get(shipping.status)!.label} ${statusTime(shipping)}`
].join('\n')
return tooltip
}

export interface ShippingByStatus {
recieved: Shipping[],
created: Shipping[],
sended: Shipping[],
const statusTime = (shipping: Shipping) => {
switch (shipping.status) {
case 'created':
return formatDate(shipping.createdAt)
case 'sended':
return formatDate(shipping.sendedAt)
case 'recieved':
return formatDate(shipping.recievedAt)
default:
return '-'
}
}

export const logisticColumns: ColumnsType<LogisticDataType> = [
{
title: 'Контент',
dataIndex: 'contentType',
key: 'contentType',
align: 'center',
},
{
title: 'Пушкино → Хотьково',
dataIndex: 'push2hot',
key: 'push2hot',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.push2hot} expand={record.expand} />,
},
{
title: 'Хотьково → Фрезеровка',
dataIndex: 'hot2frez',
key: 'hot2frez',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.hot2frez} expand={record.expand} />,
},
{
title: 'Фрезеровка → Хотьково',
dataIndex: 'frez2hot',
key: 'frez2hot',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.frez2hot} expand={record.expand} />,
},
{
title: 'Хотьково → Лахта',
dataIndex: 'hot2lahta_created',
key: 'hot2lahta_created',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.hot2lahta} expand={record.expand} />,
},
]



interface CellContentProps {
data: ShippingByStatus
expand: boolean
}

const ShippingTotal = (props: CellContentProps): JSX.Element => {
export default function ShippingTotal(props: CellContentProps): JSX.Element {

const { data, expand } = props

Expand Down Expand Up @@ -132,54 +101,3 @@ const ShippingTotal = (props: CellContentProps): JSX.Element => {

}

const generateToolTip = (shipping: Shipping) => {
const from = formatLocation(shipping.from)
const to = formatLocation(shipping.to)
const tooltip = [
`${from}${to}`,
`${shipping.contentType} ${shipping.count} шт.`,
`${statusMap.get(shipping.status)!.label} ${statusTime(shipping)}`
].join('\n')
return tooltip
}

const statusTime = (shipping: Shipping) => {
switch (shipping.status) {
case 'created':
return formatDate(shipping.createdAt)
case 'sended':
return formatDate(shipping.sendedAt)
case 'recieved':
return formatDate(shipping.recievedAt)
default:
return '-'
}
}

export const logisticStatusFilters = [
{
key: `push2hot`,
filter: (shipping: Shipping) =>
shipping.from === '1 — Пушкино' &&
shipping.to === '2 — Хотьково',
},
{
key: `hot2lahta`,
filter: (shipping: Shipping) =>
shipping.from === '2 — Хотьково' &&
shipping.to === '4 — Лахта',
},
{
key: `hot2frez`,
filter: (shipping: Shipping) =>
shipping.from === '2 — Хотьково' &&
shipping.to === '3 — Фрезеровка',
},
{
key: `frez2hot`,
filter: (shipping: Shipping) =>
shipping.from === '3 — Фрезеровка' &&
shipping.to === '2 — Хотьково',
},
]

84 changes: 84 additions & 0 deletions components/logistic/logistic-columns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Shipping } from "@/interfaces/Shipping"
import { ColumnsType } from "antd/es/table"
import ShippingTotal from "./logistic-cell"

export interface LogisticDataType {
key: string
contentType: string
push2hot: ShippingByStatus
hot2frez: ShippingByStatus
frez2hot: ShippingByStatus
hot2lahta: ShippingByStatus
expand: boolean
}

export interface ShippingByStatus {
recieved: Shipping[],
created: Shipping[],
sended: Shipping[],
}

export const logisticColumns: ColumnsType<LogisticDataType> = [
{
title: 'Контент',
dataIndex: 'contentType',
key: 'contentType',
align: 'center',
},
{
title: 'Пушкино → Хотьково',
dataIndex: 'push2hot',
key: 'push2hot',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.push2hot} expand={record.expand} />,
},
{
title: 'Хотьково → Фрезеровка',
dataIndex: 'hot2frez',
key: 'hot2frez',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.hot2frez} expand={record.expand} />,
},
{
title: 'Фрезеровка → Хотьково',
dataIndex: 'frez2hot',
key: 'frez2hot',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.frez2hot} expand={record.expand} />,
},
{
title: 'Хотьково → Лахта',
dataIndex: 'hot2lahta_created',
key: 'hot2lahta_created',
align: 'center',
render: (value, record, index) => <ShippingTotal data={record.hot2lahta} expand={record.expand} />,
},
]

export const logisticStatusFilters = [
{
key: `push2hot`,
filter: (shipping: Shipping) =>
shipping.from === '1 — Пушкино' &&
shipping.to === '2 — Хотьково',
},
{
key: `hot2lahta`,
filter: (shipping: Shipping) =>
shipping.from === '2 — Хотьково' &&
shipping.to === '4 — Лахта',
},
{
key: `hot2frez`,
filter: (shipping: Shipping) =>
shipping.from === '2 — Хотьково' &&
shipping.to === '3 — Фрезеровка',
},
{
key: `frez2hot`,
filter: (shipping: Shipping) =>
shipping.from === '3 — Фрезеровка' &&
shipping.to === '2 — Хотьково',
},
]

File renamed without changes.
2 changes: 1 addition & 1 deletion components/summary/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Shipping } from "@/interfaces/Shipping";
import { User } from "@/interfaces/UserInterface";
import { useRouter } from "next/router";
import { Table } from "antd";
import { Summary, SummaryByLocation, SummaryByType, summaryColumns, SummaryData, SummaryDataType } from "./columns";
import { Summary, SummaryByLocation, SummaryByType, summaryColumns, SummaryData, SummaryDataType } from "./summary-columns";


export const LocationSummary = (): JSX.Element => {
Expand Down

0 comments on commit 463593d

Please sign in to comment.