Skip to content

Commit 9288f44

Browse files
th-213: Business Journey - FE: Order List (#295)
* th-213: + orders * th-213: + orders * th-213: + orders state * th-213: * order list * th-213: - null in order response dto * th-213: + add route building * th-213: + add route building * th-213: + order-list-card for business * th-213: * chenge map center to optional, card hover * th-213: * selector * th-213: + info window on the map * th-213: * correct helper * th-213: * correct styles * th-213: * create icon helper, small changes * th-213: * type Map options * th-123: * image path enum * th-213: * mapper, small changes * th-213: * rename, move helper * th-213: * onSelect
1 parent b575e50 commit 9288f44

39 files changed

+626
-48
lines changed

backend/src/packages/orders/order.entity.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ class OrderEntity implements IEntity {
116116
shiftId,
117117
customerName,
118118
customerPhone,
119-
}: Omit<OrderEntityT, 'id' | 'driver' | 'truck'> & {
119+
driver,
120+
truck,
121+
}: Omit<OrderEntityT, 'id'> & {
120122
shiftId: number;
121123
}): OrderEntity {
122124
return new OrderEntity({
@@ -132,8 +134,8 @@ class OrderEntity implements IEntity {
132134
customerName,
133135
customerPhone,
134136
shiftId,
135-
driver: null,
136-
truck: null,
137+
driver,
138+
truck,
137139
});
138140
}
139141

4.58 KB
Loading

frontend/src/assets/img/tow-truck-small.svg

Lines changed: 9 additions & 0 deletions
Loading

frontend/src/libs/components/components.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ export { Image } from './image/image.js';
1616
export { Input } from './input/input.js';
1717
export { Link } from './link/link.js';
1818
export { LocationInput } from './location-input/location-input.js';
19+
export { Map } from './map/map.js';
1920
export { Modal } from './modal/modal.js';
2021
export { Notification } from './notification/notification.js';
2122
export { OrderCard } from './order-card/order-card.js';
23+
export { OrderList } from './order-list/order-list.js';
24+
export { OrderListCardBusiness } from './order-list-card-business/order-list-card-business.js';
2225
export { PageLayout } from './page-layout/page-layout.js';
2326
export { Pagination } from './pagination/pagination.js';
2427
export { PlainSvgIcon } from './plain-svg-icon/plain-svg-icon.js';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const DEFAULT_ZOOM = 10;
2+
3+
export { DEFAULT_ZOOM };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { OrderStatus } from '~/libs/enums/enums.js';
2+
import { type OrderStatusValues } from '~/libs/types/types.js';
3+
4+
import { type ReadableStatusWithColor } from '../types/readable-status-with-color.type.js';
5+
6+
const mapOrderStatusToReadable: Record<
7+
OrderStatusValues,
8+
ReadableStatusWithColor
9+
> = {
10+
[OrderStatus.PENDING]: { name: 'Pending', color: 'grey-light' },
11+
[OrderStatus.CONFIRMED]: { name: 'On the way', color: 'blue-light' },
12+
[OrderStatus.CANCELED]: { name: 'Canceled', color: 'red' },
13+
[OrderStatus.DONE]: { name: 'Done', color: 'grey-dark' },
14+
[OrderStatus.PICKING_UP]: { name: 'Arrived', color: 'green' },
15+
[OrderStatus.REJECTED]: { name: 'Rejected', color: 'red-light' },
16+
};
17+
18+
export { mapOrderStatusToReadable };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { mapOrderStatusToReadable } from './map-order-status-to-readable.map.js';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { type Color } from '~/libs/types/color.type.js';
2+
3+
type ReadableStatusWithColor = {
4+
name: string;
5+
color: Color;
6+
};
7+
export { type ReadableStatusWithColor };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { type ReadableStatusWithColor } from './readable-status-with-color.type.js';
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { IconName, ImgPath } from '~/libs/enums/enums.js';
2+
import {
3+
getValidClassNames,
4+
jsonToLatLngLiteral,
5+
} from '~/libs/helpers/helpers.js';
6+
import { useCallback } from '~/libs/hooks/hooks.js';
7+
import { type PlaceLatLng } from '~/libs/packages/map/libs/types/types.js';
8+
import { type OrderResponseDto } from '~/libs/types/types.js';
9+
10+
import { Badge, Icon } from '../components.js';
11+
import { getFullName } from '../header/libs/helpers/helpers.js';
12+
import { mapOrderStatusToReadable } from './libs/map/maps.js';
13+
import styles from './styles.module.scss';
14+
15+
type Properties = {
16+
order: OrderResponseDto;
17+
onSelect: ({ startPoint, endPoint }: PlaceLatLng) => void;
18+
};
19+
20+
const OrderListCardBusiness: React.FC<Properties> = ({
21+
order,
22+
onSelect,
23+
}: Properties) => {
24+
const {
25+
id,
26+
status,
27+
startPoint,
28+
endPoint,
29+
shift: { driver, truck },
30+
} = order;
31+
32+
const handleSelectCard = useCallback(
33+
(startPoint: string, endPoint: string) => () => {
34+
onSelect({
35+
startPoint: jsonToLatLngLiteral(startPoint),
36+
endPoint: jsonToLatLngLiteral(endPoint),
37+
});
38+
},
39+
[onSelect],
40+
);
41+
42+
const statusBadge = mapOrderStatusToReadable[status];
43+
44+
return (
45+
<div
46+
className={styles.container}
47+
onMouseEnter={handleSelectCard(startPoint, endPoint)}
48+
>
49+
<div className={styles.header}>
50+
<p className={getValidClassNames('textMdBold', styles.cardName)}>
51+
Order {id}
52+
</p>
53+
<Badge color={statusBadge.color}>{statusBadge.name}</Badge>
54+
</div>
55+
<div className={styles.content}>
56+
<img
57+
src={ImgPath.AVATAR_DEFAULT}
58+
alt={driver?.firstName}
59+
className={styles.avatar}
60+
/>
61+
<div className={styles.driver}>
62+
<p className={getValidClassNames('textMdBold')}>
63+
{driver && getFullName(driver.firstName, driver.lastName)}
64+
</p>
65+
<p className={getValidClassNames('textMd', styles.driverPhone)}>
66+
{driver?.phone}
67+
</p>
68+
</div>
69+
<div className={styles.truck}>
70+
<Icon iconName={IconName.TRUCK} className={styles.icon} />
71+
<p className={styles.truckNumber}>{truck?.licensePlateNumber}</p>
72+
</div>
73+
</div>
74+
</div>
75+
);
76+
};
77+
78+
export { OrderListCardBusiness };

0 commit comments

Comments
 (0)