bananas-commerce-admin 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api.js +13 -0
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/contexts/ApiContext.js +13 -14
- package/dist/cjs/contexts/ApiContext.js.map +1 -1
- package/dist/cjs/extensions/fulfillment/components/AddressInfo.js +7 -5
- package/dist/cjs/extensions/fulfillment/components/AddressInfo.js.map +1 -1
- package/dist/cjs/extensions/fulfillment/components/RecipientCard.js +18 -15
- package/dist/cjs/extensions/fulfillment/components/RecipientCard.js.map +1 -1
- package/dist/cjs/extensions/fulfillment/components/ShipmentCard.js +22 -37
- package/dist/cjs/extensions/fulfillment/components/ShipmentCard.js.map +1 -1
- package/dist/cjs/extensions/fulfillment/components/contrib/PurchaseOrderList.js +2 -2
- package/dist/cjs/extensions/fulfillment/components/contrib/PurchaseOrderList.js.map +1 -1
- package/dist/cjs/extensions/fulfillment/components/order/OrderDestinationCard.js +38 -0
- package/dist/cjs/extensions/fulfillment/components/order/OrderDestinationCard.js.map +1 -0
- package/dist/cjs/extensions/fulfillment/components/order/OrderDetail.js +276 -0
- package/dist/cjs/extensions/fulfillment/components/order/OrderDetail.js.map +1 -0
- package/dist/cjs/extensions/fulfillment/index.js +21 -25
- package/dist/cjs/extensions/fulfillment/index.js.map +1 -1
- package/dist/cjs/extensions/pos/pages/purchase/detail.js +6 -21
- package/dist/cjs/extensions/pos/pages/purchase/detail.js.map +1 -1
- package/dist/esm/api.js +13 -0
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/contexts/ApiContext.js +13 -14
- package/dist/esm/contexts/ApiContext.js.map +1 -1
- package/dist/esm/extensions/fulfillment/components/AddressInfo.js +7 -5
- package/dist/esm/extensions/fulfillment/components/AddressInfo.js.map +1 -1
- package/dist/esm/extensions/fulfillment/components/RecipientCard.js +18 -15
- package/dist/esm/extensions/fulfillment/components/RecipientCard.js.map +1 -1
- package/dist/esm/extensions/fulfillment/components/ShipmentCard.js +22 -37
- package/dist/esm/extensions/fulfillment/components/ShipmentCard.js.map +1 -1
- package/dist/esm/extensions/fulfillment/components/contrib/PurchaseOrderList.js +2 -2
- package/dist/esm/extensions/fulfillment/components/contrib/PurchaseOrderList.js.map +1 -1
- package/dist/esm/extensions/fulfillment/components/order/OrderDestinationCard.js +31 -0
- package/dist/esm/extensions/fulfillment/components/order/OrderDestinationCard.js.map +1 -0
- package/dist/esm/extensions/fulfillment/components/order/OrderDetail.js +248 -0
- package/dist/esm/extensions/fulfillment/components/order/OrderDetail.js.map +1 -0
- package/dist/esm/extensions/fulfillment/index.js +21 -25
- package/dist/esm/extensions/fulfillment/index.js.map +1 -1
- package/dist/esm/extensions/pos/pages/purchase/detail.js +6 -21
- package/dist/esm/extensions/pos/pages/purchase/detail.js.map +1 -1
- package/dist/types/App.d.ts +2 -2
- package/dist/types/api.d.ts +1 -0
- package/dist/types/contexts/ApiContext.d.ts +2 -2
- package/dist/types/extensions/fulfillment/components/AddressInfo.d.ts +1 -0
- package/dist/types/extensions/fulfillment/components/RecipientCard.d.ts +3 -1
- package/dist/types/extensions/fulfillment/components/ShipmentCard.d.ts +3 -2
- package/dist/types/extensions/fulfillment/components/order/OrderDestinationCard.d.ts +7 -0
- package/dist/types/extensions/fulfillment/components/order/OrderDetail.d.ts +7 -0
- package/dist/types/extensions/fulfillment/index.d.ts +2 -2
- package/dist/types/extensions/fulfillment/types/order.d.ts +6 -5
- package/dist/types/extensions/fulfillment/types/recipient.d.ts +1 -5
- package/dist/types/extensions/fulfillment/types/shipment.d.ts +2 -57
- package/dist/types/extensions/pos/types/purchase.d.ts +1 -0
- package/dist/types/types/index.d.ts +4 -4
- package/example/index.tsx +4 -1
- package/example/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/App.tsx +2 -2
- package/src/api.ts +14 -0
- package/src/contexts/ApiContext.tsx +10 -8
- package/src/extensions/fulfillment/components/AddressInfo.tsx +9 -5
- package/src/extensions/fulfillment/components/RecipientCard.tsx +47 -22
- package/src/extensions/fulfillment/components/ShipmentCard.tsx +57 -63
- package/src/extensions/fulfillment/components/contrib/PurchaseOrderList.tsx +2 -2
- package/src/extensions/fulfillment/components/order/OrderDestinationCard.tsx +68 -0
- package/src/extensions/fulfillment/components/order/OrderDetail.tsx +262 -0
- package/src/extensions/fulfillment/index.tsx +13 -35
- package/src/extensions/fulfillment/types/order.ts +7 -5
- package/src/extensions/fulfillment/types/recipient.ts +1 -6
- package/src/extensions/fulfillment/types/shipment.ts +2 -60
- package/src/extensions/pos/pages/purchase/detail.tsx +8 -12
- package/src/extensions/pos/types/purchase.ts +1 -0
- package/src/types/index.ts +8 -4
- package/dist/cjs/extensions/fulfillment/components/ContactInfo.js +0 -21
- package/dist/cjs/extensions/fulfillment/components/ContactInfo.js.map +0 -1
- package/dist/cjs/extensions/fulfillment/components/ShipmentAccordion.js +0 -215
- package/dist/cjs/extensions/fulfillment/components/ShipmentAccordion.js.map +0 -1
- package/dist/cjs/extensions/fulfillment/components/ShipmentItemsCard.js +0 -131
- package/dist/cjs/extensions/fulfillment/components/ShipmentItemsCard.js.map +0 -1
- package/dist/cjs/extensions/fulfillment/components/ShipmentItemsTable.js +0 -85
- package/dist/cjs/extensions/fulfillment/components/ShipmentItemsTable.js.map +0 -1
- package/dist/cjs/extensions/fulfillment/components/ShipmentRow.js +0 -29
- package/dist/cjs/extensions/fulfillment/components/ShipmentRow.js.map +0 -1
- package/dist/esm/extensions/fulfillment/components/ContactInfo.js +0 -14
- package/dist/esm/extensions/fulfillment/components/ContactInfo.js.map +0 -1
- package/dist/esm/extensions/fulfillment/components/ShipmentAccordion.js +0 -208
- package/dist/esm/extensions/fulfillment/components/ShipmentAccordion.js.map +0 -1
- package/dist/esm/extensions/fulfillment/components/ShipmentItemsCard.js +0 -124
- package/dist/esm/extensions/fulfillment/components/ShipmentItemsCard.js.map +0 -1
- package/dist/esm/extensions/fulfillment/components/ShipmentItemsTable.js +0 -78
- package/dist/esm/extensions/fulfillment/components/ShipmentItemsTable.js.map +0 -1
- package/dist/esm/extensions/fulfillment/components/ShipmentRow.js +0 -22
- package/dist/esm/extensions/fulfillment/components/ShipmentRow.js.map +0 -1
- package/dist/types/extensions/fulfillment/components/ContactInfo.d.ts +0 -7
- package/dist/types/extensions/fulfillment/components/ShipmentAccordion.d.ts +0 -7
- package/dist/types/extensions/fulfillment/components/ShipmentItemsCard.d.ts +0 -6
- package/dist/types/extensions/fulfillment/components/ShipmentItemsTable.d.ts +0 -8
- package/dist/types/extensions/fulfillment/components/ShipmentRow.d.ts +0 -7
- package/src/extensions/fulfillment/components/ContactInfo.tsx +0 -33
- package/src/extensions/fulfillment/components/ShipmentAccordion.tsx +0 -209
- package/src/extensions/fulfillment/components/ShipmentItemsCard.tsx +0 -170
- package/src/extensions/fulfillment/components/ShipmentItemsTable.tsx +0 -116
- package/src/extensions/fulfillment/components/ShipmentRow.tsx +0 -32
package/dist/types/App.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import React from "react";
|
|
|
2
2
|
import { Theme } from "@mui/material/styles";
|
|
3
3
|
import { AdminProps } from "./Admin";
|
|
4
4
|
import { ApiClient } from "./api";
|
|
5
|
-
import {
|
|
5
|
+
import { ContribComponentMap } from "./types";
|
|
6
6
|
type AppProps = {
|
|
7
7
|
api: ApiClient | string | URL | {
|
|
8
8
|
schema: string | URL;
|
|
9
9
|
server?: string | URL;
|
|
10
10
|
};
|
|
11
11
|
theme?: Theme | Partial<Theme> | ((outerTheme: Theme) => Theme);
|
|
12
|
-
contrib?:
|
|
12
|
+
contrib?: ContribComponentMap;
|
|
13
13
|
} & AdminProps;
|
|
14
14
|
declare const App: React.FC<AppProps>;
|
|
15
15
|
export default App;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -35,4 +35,5 @@ export declare class ApiClient {
|
|
|
35
35
|
static load(source: string | URL, server?: string | URL): Promise<ApiClient>;
|
|
36
36
|
constructor(document: OpenAPI.Document, server?: string | URL);
|
|
37
37
|
isAuthenticated(): Promise<boolean>;
|
|
38
|
+
findContrib(prefix: string): ApiOperation[];
|
|
38
39
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ApiClient } from "../api";
|
|
3
|
-
import {
|
|
3
|
+
import { ContribComponentMap } from "../types";
|
|
4
4
|
export interface ApiContextProviderProps {
|
|
5
5
|
api: ApiClient | string | URL | {
|
|
6
6
|
schema: string | URL;
|
|
7
7
|
server?: string | URL;
|
|
8
8
|
prefix?: string;
|
|
9
9
|
};
|
|
10
|
-
contrib?:
|
|
10
|
+
contrib?: ContribComponentMap;
|
|
11
11
|
}
|
|
12
12
|
declare const ApiContext: React.Context<ApiClient>;
|
|
13
13
|
export declare const useApi: () => ApiClient;
|
|
@@ -2,6 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { Recipient } from "../types/recipient";
|
|
3
3
|
interface RecipientCard {
|
|
4
4
|
recipient: Recipient;
|
|
5
|
+
email?: string;
|
|
6
|
+
phone?: string;
|
|
5
7
|
}
|
|
6
8
|
export declare const RecipientCard: React.FC<RecipientCard>;
|
|
7
|
-
export
|
|
9
|
+
export default RecipientCard;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Shipment } from "../types/shipment";
|
|
3
3
|
export interface ShipmentCardProps {
|
|
4
|
-
shipment:
|
|
4
|
+
shipment: Shipment;
|
|
5
5
|
}
|
|
6
6
|
export declare const ShipmentCard: React.FC<ShipmentCardProps>;
|
|
7
|
+
export default ShipmentCard;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RouterExtension } from "../../router/Router";
|
|
2
|
-
import {
|
|
2
|
+
import { ContribComponentMap, NavigationOverrides } from "../../types";
|
|
3
3
|
export declare const router: RouterExtension;
|
|
4
4
|
export declare const navigation: NavigationOverrides;
|
|
5
|
-
export declare const contrib:
|
|
5
|
+
export declare const contrib: Record<string, ContribComponentMap>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Recipient } from "./recipient";
|
|
2
|
+
import { Shipment } from "./shipment";
|
|
1
3
|
export type OrderDestinationType = "HOME" | "STORE" | "SERVICE_POINT" | "LOCKER";
|
|
2
4
|
export type OrderStateType = "PENDING" | "CONFIRMED" | "SENT" | "IN_TRANSIT" | "READY_FOR_PICKUP" | "DELIVERED" | "CANCELLED";
|
|
3
5
|
export interface OrderListItem {
|
|
@@ -12,6 +14,7 @@ export interface OrderListItem {
|
|
|
12
14
|
recipient: {
|
|
13
15
|
given_name: string;
|
|
14
16
|
family_name: string;
|
|
17
|
+
company_name: string;
|
|
15
18
|
} | null;
|
|
16
19
|
tracking_number: string;
|
|
17
20
|
state: OrderStateType;
|
|
@@ -23,6 +26,7 @@ export interface OrderDetail {
|
|
|
23
26
|
phone: string | null;
|
|
24
27
|
destination_type: OrderDestinationType;
|
|
25
28
|
state: OrderStateType;
|
|
29
|
+
channel: string;
|
|
26
30
|
destination_reference?: string;
|
|
27
31
|
name: string;
|
|
28
32
|
care_of: string;
|
|
@@ -33,11 +37,8 @@ export interface OrderDetail {
|
|
|
33
37
|
country_code: string;
|
|
34
38
|
region: string;
|
|
35
39
|
items: OrderItem[];
|
|
36
|
-
shipment:
|
|
37
|
-
|
|
38
|
-
option_name: string;
|
|
39
|
-
tracking_number: string;
|
|
40
|
-
} | null;
|
|
40
|
+
shipment: Shipment | null;
|
|
41
|
+
recipient: Recipient | null;
|
|
41
42
|
}
|
|
42
43
|
export interface OrderItem {
|
|
43
44
|
code: string;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Shipment } from "./shipment";
|
|
2
1
|
export interface Recipient {
|
|
3
|
-
email: string;
|
|
4
|
-
phone?: string;
|
|
5
2
|
given_name: string;
|
|
6
3
|
family_name: string;
|
|
4
|
+
company_name: string;
|
|
7
5
|
care_of: string;
|
|
8
6
|
street_address: string;
|
|
9
7
|
street_address2: string;
|
|
@@ -11,6 +9,4 @@ export interface Recipient {
|
|
|
11
9
|
city: string;
|
|
12
10
|
country_code: string;
|
|
13
11
|
region: string;
|
|
14
|
-
reference: string;
|
|
15
|
-
shipments: Shipment[];
|
|
16
12
|
}
|
|
@@ -1,64 +1,9 @@
|
|
|
1
1
|
export type ShipmentDestinationType = "HOME" | "STORE" | "SERVICE_POINT" | "LOCKER";
|
|
2
|
-
export interface ShipmentListItem {
|
|
3
|
-
shipment_reference: string;
|
|
4
|
-
purchase_number: number;
|
|
5
|
-
email: string;
|
|
6
|
-
phone?: string;
|
|
7
|
-
option_name: string;
|
|
8
|
-
carrier: string;
|
|
9
|
-
destination_type: ShipmentDestinationType;
|
|
10
|
-
name: string;
|
|
11
|
-
tracking_number: string;
|
|
12
|
-
date_confirmed?: string;
|
|
13
|
-
date_sent?: string;
|
|
14
|
-
date_cancelled?: string;
|
|
15
|
-
date_arrived_at_destination?: string;
|
|
16
|
-
date_delivered?: string;
|
|
17
|
-
}
|
|
18
2
|
export interface Shipment {
|
|
19
|
-
shipment_reference: string;
|
|
20
3
|
option_name: string;
|
|
21
4
|
carrier: string;
|
|
22
|
-
destination_type: ShipmentDestinationType;
|
|
23
|
-
destination_reference?: string;
|
|
24
|
-
name: string;
|
|
25
|
-
care_of: string;
|
|
26
|
-
street_address: string;
|
|
27
|
-
street_address2: string;
|
|
28
|
-
postal_code: string;
|
|
29
|
-
city: string;
|
|
30
|
-
country_code: string;
|
|
31
|
-
region: string;
|
|
32
5
|
tracking_number: string;
|
|
33
|
-
|
|
6
|
+
tracking_url: string;
|
|
7
|
+
date_commited?: string;
|
|
34
8
|
date_sent?: string;
|
|
35
|
-
date_cancelled?: string;
|
|
36
|
-
date_arrived_at_destination?: string;
|
|
37
|
-
date_delivered?: string;
|
|
38
|
-
items: ShipmentItem[];
|
|
39
|
-
}
|
|
40
|
-
export interface ShipmentDetail {
|
|
41
|
-
option_name: string;
|
|
42
|
-
carrier: string;
|
|
43
|
-
destination_type: ShipmentDestinationType;
|
|
44
|
-
destination_reference?: string;
|
|
45
|
-
name: string;
|
|
46
|
-
care_of: string;
|
|
47
|
-
street_address: string;
|
|
48
|
-
street_address2: string;
|
|
49
|
-
postal_code: string;
|
|
50
|
-
city: string;
|
|
51
|
-
country_code: string;
|
|
52
|
-
region: string;
|
|
53
|
-
tracking_number: string;
|
|
54
|
-
date_confirmed?: string;
|
|
55
|
-
date_sent?: string;
|
|
56
|
-
date_cancelled?: string;
|
|
57
|
-
date_arrived_at_destination?: string;
|
|
58
|
-
date_delivered?: string;
|
|
59
|
-
items: ShipmentItem[];
|
|
60
|
-
}
|
|
61
|
-
export interface ShipmentItem {
|
|
62
|
-
code: string;
|
|
63
|
-
quantity: number;
|
|
64
9
|
}
|
|
@@ -19,7 +19,7 @@ export interface PageContribComponent {
|
|
|
19
19
|
title?: string;
|
|
20
20
|
component: ContribComponent | Promise<ContribComponent>;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
component: (
|
|
25
|
-
}
|
|
22
|
+
export type ContribComponentMap = Record<string, {
|
|
23
|
+
title?: string;
|
|
24
|
+
component: () => ContribComponent<any> | Promise<ContribComponent<any>>;
|
|
25
|
+
}>;
|
package/example/index.tsx
CHANGED
|
@@ -15,7 +15,10 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
|
|
15
15
|
...Bananas.fulfillment.navigation,
|
|
16
16
|
}}
|
|
17
17
|
extensions={[Bananas.bananas.router, Bananas.pos.router, Bananas.fulfillment.router]}
|
|
18
|
-
contrib={
|
|
18
|
+
contrib={{
|
|
19
|
+
...Bananas.fulfillment.contrib.orders,
|
|
20
|
+
...Bananas.fulfillment.contrib.returns,
|
|
21
|
+
}}
|
|
19
22
|
theme={createTheme({
|
|
20
23
|
palette: {
|
|
21
24
|
primary: {
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { ApiContextProvider } from "./contexts/ApiContext";
|
|
|
11
11
|
import { I18nContextProvider } from "./contexts/I18nContext";
|
|
12
12
|
import { UserContextProvider } from "./contexts/UserContext";
|
|
13
13
|
import { parentPath } from "./router/routes";
|
|
14
|
-
import {
|
|
14
|
+
import { ContribComponentMap } from "./types";
|
|
15
15
|
|
|
16
16
|
type AppProps = {
|
|
17
17
|
api:
|
|
@@ -23,7 +23,7 @@ type AppProps = {
|
|
|
23
23
|
server?: string | URL;
|
|
24
24
|
};
|
|
25
25
|
theme?: Theme | Partial<Theme> | ((outerTheme: Theme) => Theme);
|
|
26
|
-
contrib?:
|
|
26
|
+
contrib?: ContribComponentMap;
|
|
27
27
|
} & AdminProps;
|
|
28
28
|
|
|
29
29
|
const App: React.FC<AppProps> = ({ theme, api, contrib, ...rest }) => {
|
package/src/api.ts
CHANGED
|
@@ -291,4 +291,18 @@ export class ApiClient {
|
|
|
291
291
|
return false;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
findContrib(prefix: string) {
|
|
296
|
+
const results = [];
|
|
297
|
+
|
|
298
|
+
for (const [tag, operations] of Object.entries(this.contrib)) {
|
|
299
|
+
for (const [_, operation] of Object.entries(operations)) {
|
|
300
|
+
if (tag.startsWith(prefix) && operation.component !== undefined) {
|
|
301
|
+
results.push(operation);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return results;
|
|
307
|
+
}
|
|
294
308
|
}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { useSnackbar } from "notistack";
|
|
4
4
|
|
|
5
5
|
import { ApiClient } from "../api";
|
|
6
|
-
import {
|
|
6
|
+
import { ContribComponentMap } from "../types";
|
|
7
7
|
import { getCookie } from "../util/get_cookie";
|
|
8
8
|
|
|
9
9
|
export interface ApiContextProviderProps {
|
|
@@ -16,7 +16,7 @@ export interface ApiContextProviderProps {
|
|
|
16
16
|
server?: string | URL;
|
|
17
17
|
prefix?: string;
|
|
18
18
|
};
|
|
19
|
-
contrib?:
|
|
19
|
+
contrib?: ContribComponentMap;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const ApiContext = React.createContext<ApiClient>(undefined as unknown as ApiClient);
|
|
@@ -27,9 +27,6 @@ export const ApiContextProvider: React.FC<React.PropsWithChildren<ApiContextProv
|
|
|
27
27
|
api: init,
|
|
28
28
|
contrib,
|
|
29
29
|
}) => {
|
|
30
|
-
contrib ??= Array.isArray(contrib) ? contrib : [];
|
|
31
|
-
const contribMap = new Map(contrib.map(({ app, component }) => [app, component]));
|
|
32
|
-
|
|
33
30
|
const [api, setApi] = React.useState<ApiClient>();
|
|
34
31
|
const { enqueueSnackbar } = useSnackbar();
|
|
35
32
|
|
|
@@ -44,9 +41,14 @@ export const ApiContextProvider: React.FC<React.PropsWithChildren<ApiContextProv
|
|
|
44
41
|
.then(async (api) => {
|
|
45
42
|
// Add a component for rendering the operation result if found.
|
|
46
43
|
for (const [tag, operations] of Object.entries(api.contrib)) {
|
|
47
|
-
for (const [
|
|
48
|
-
const hit =
|
|
49
|
-
|
|
44
|
+
for (const [_, operation] of Object.entries(operations)) {
|
|
45
|
+
const hit = contrib ? contrib[tag] : null;
|
|
46
|
+
if (hit != null) {
|
|
47
|
+
operation.component = {
|
|
48
|
+
title: hit.title,
|
|
49
|
+
component: hit.component(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import Box from "@mui/material/Box";
|
|
4
4
|
import Typography from "@mui/material/Typography";
|
|
5
5
|
|
|
6
|
-
const countryCodeFormatter = new Intl.DisplayNames("
|
|
6
|
+
const countryCodeFormatter = new Intl.DisplayNames("en", { type: "region" });
|
|
7
7
|
|
|
8
8
|
export interface AddressInfoProps {
|
|
9
9
|
name?: string;
|
|
@@ -12,6 +12,7 @@ export interface AddressInfoProps {
|
|
|
12
12
|
careOf?: string;
|
|
13
13
|
postalCode: string;
|
|
14
14
|
city: string;
|
|
15
|
+
region?: string;
|
|
15
16
|
countryCode: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -22,19 +23,22 @@ export const AddressInfo: React.FC<AddressInfoProps> = ({
|
|
|
22
23
|
careOf,
|
|
23
24
|
postalCode,
|
|
24
25
|
city,
|
|
26
|
+
region,
|
|
25
27
|
countryCode,
|
|
26
28
|
}) => {
|
|
27
29
|
return (
|
|
28
30
|
<Box>
|
|
29
31
|
{name != null && name !== "" ? <Typography noWrap>{name}</Typography> : null}
|
|
32
|
+
{careOf != null && careOf !== "" ? <Typography noWrap>c/o {careOf}</Typography> : null}
|
|
30
33
|
<Typography noWrap>{streetAddress}</Typography>
|
|
31
34
|
{streetAddress2 != null && streetAddress2 !== "" ? (
|
|
32
35
|
<Typography noWrap>{streetAddress2}</Typography>
|
|
33
36
|
) : null}
|
|
34
|
-
|
|
35
|
-
<Typography noWrap>
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
<Typography noWrap>{`${postalCode} ${city}`}</Typography>
|
|
38
|
+
{region != null && region !== "" ? <Typography noWrap>{region}</Typography> : null}
|
|
39
|
+
{countryCode != null && countryCode !== "" ? (
|
|
40
|
+
<Typography noWrap>{countryCodeFormatter.of(countryCode)}</Typography>
|
|
41
|
+
) : null}
|
|
38
42
|
</Box>
|
|
39
43
|
);
|
|
40
44
|
};
|
|
@@ -1,42 +1,67 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
+
import PersonOutlinedIcon from "@mui/icons-material/PersonOutlined";
|
|
3
4
|
import Card from "@mui/material/Card";
|
|
4
5
|
import CardContent from "@mui/material/CardContent";
|
|
5
6
|
import CardHeader from "@mui/material/CardHeader";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import List from "@mui/material/List";
|
|
8
|
+
import ListItem from "@mui/material/ListItem";
|
|
9
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
9
10
|
import Typography from "@mui/material/Typography";
|
|
10
11
|
|
|
11
12
|
import { Recipient } from "../types/recipient";
|
|
13
|
+
import { AddressInfo } from "./AddressInfo";
|
|
12
14
|
|
|
13
15
|
interface RecipientCard {
|
|
14
16
|
recipient: Recipient;
|
|
17
|
+
email?: string;
|
|
18
|
+
phone?: string;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
export const RecipientCard: React.FC<RecipientCard> = ({ recipient }) => {
|
|
18
|
-
const theme = useTheme();
|
|
19
|
-
|
|
21
|
+
export const RecipientCard: React.FC<RecipientCard> = ({ recipient, email, phone }) => {
|
|
20
22
|
return (
|
|
21
23
|
<Card>
|
|
22
|
-
<CardHeader
|
|
24
|
+
<CardHeader
|
|
25
|
+
title={
|
|
26
|
+
<Typography variant="h6">
|
|
27
|
+
<b>Recipient</b>
|
|
28
|
+
</Typography>
|
|
29
|
+
}
|
|
30
|
+
avatar={<PersonOutlinedIcon />}
|
|
31
|
+
/>
|
|
23
32
|
<CardContent>
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
<List dense>
|
|
34
|
+
<ListItem>
|
|
35
|
+
<ListItemText
|
|
36
|
+
primary="Address"
|
|
37
|
+
secondary={
|
|
38
|
+
<AddressInfo
|
|
39
|
+
name={
|
|
40
|
+
recipient.company_name
|
|
41
|
+
? recipient.company_name
|
|
42
|
+
: `${recipient.given_name} ${recipient.family_name}`
|
|
43
|
+
}
|
|
44
|
+
streetAddress={recipient.street_address}
|
|
45
|
+
streetAddress2={recipient.street_address2}
|
|
46
|
+
careOf={recipient.care_of}
|
|
47
|
+
postalCode={recipient.postal_code}
|
|
48
|
+
city={recipient.city}
|
|
49
|
+
region={recipient.region}
|
|
50
|
+
countryCode={recipient.country_code}
|
|
51
|
+
/>
|
|
52
|
+
}
|
|
53
|
+
/>
|
|
54
|
+
</ListItem>
|
|
55
|
+
<ListItem>
|
|
56
|
+
<ListItemText primary="Email" secondary={email ?? "-"} />
|
|
57
|
+
</ListItem>
|
|
58
|
+
<ListItem>
|
|
59
|
+
<ListItemText primary="Phone" secondary={phone ?? "-"} />
|
|
60
|
+
</ListItem>
|
|
61
|
+
</List>
|
|
39
62
|
</CardContent>
|
|
40
63
|
</Card>
|
|
41
64
|
);
|
|
42
65
|
};
|
|
66
|
+
|
|
67
|
+
export default RecipientCard;
|
|
@@ -1,79 +1,73 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LocalShippingOutlinedIcon from "@mui/icons-material/LocalShippingOutlined";
|
|
4
4
|
import Card from "@mui/material/Card";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import CardContent from "@mui/material/CardContent";
|
|
6
|
+
import CardHeader from "@mui/material/CardHeader";
|
|
7
|
+
import Link from "@mui/material/Link";
|
|
8
|
+
import List from "@mui/material/List";
|
|
9
|
+
import ListItem from "@mui/material/ListItem";
|
|
10
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
7
11
|
import Typography from "@mui/material/Typography";
|
|
8
|
-
import Stack from "@mui/system/Stack";
|
|
9
12
|
|
|
10
|
-
import {
|
|
11
|
-
import { formatPurchaseNumber } from "../../../util/format_purchase_number";
|
|
12
|
-
import { ShipmentListItem } from "../types/shipment";
|
|
13
|
-
import { ContactInfo } from "./ContactInfo";
|
|
14
|
-
import { ShipmentDestinationIcon } from "./ShipmentDestinationIcon";
|
|
15
|
-
|
|
16
|
-
const dateTimeFormatter = new Intl.DateTimeFormat("sv");
|
|
13
|
+
import { Shipment } from "../types/shipment";
|
|
17
14
|
|
|
18
15
|
export interface ShipmentCardProps {
|
|
19
|
-
shipment:
|
|
16
|
+
shipment: Shipment;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
export const ShipmentCard: React.FC<ShipmentCardProps> = ({ shipment }) => {
|
|
23
|
-
const theme = useTheme();
|
|
24
|
-
const { navigate } = useRouter();
|
|
25
|
-
|
|
26
|
-
const onClick = () => {
|
|
27
|
-
navigate(`fulfillment.shipment:detail`, {
|
|
28
|
-
params: {
|
|
29
|
-
shipment_reference: shipment.shipment_reference,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
20
|
return (
|
|
35
21
|
<Card sx={{ width: "100%" }}>
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
<CardHeader
|
|
23
|
+
title={
|
|
24
|
+
<Typography variant="h6">
|
|
25
|
+
<b>Shipment</b>
|
|
26
|
+
</Typography>
|
|
27
|
+
}
|
|
28
|
+
avatar={<LocalShippingOutlinedIcon />}
|
|
29
|
+
/>
|
|
30
|
+
<CardContent>
|
|
31
|
+
<List dense>
|
|
32
|
+
<ListItem>
|
|
33
|
+
<ListItemText primary="Carrier" secondary={shipment.carrier} />
|
|
34
|
+
</ListItem>
|
|
35
|
+
<ListItem>
|
|
36
|
+
<ListItemText
|
|
37
|
+
primary="Tracking number"
|
|
38
|
+
secondary={
|
|
39
|
+
shipment.tracking_number !== "" ? shipment.tracking_number : "Not received yet"
|
|
40
|
+
}
|
|
47
41
|
/>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</Stack>
|
|
76
|
-
</CardActionArea>
|
|
42
|
+
</ListItem>
|
|
43
|
+
<ListItem>
|
|
44
|
+
<ListItemText
|
|
45
|
+
primary="Tracking URL"
|
|
46
|
+
secondary={
|
|
47
|
+
shipment.tracking_url !== "" ? (
|
|
48
|
+
<Link href={shipment.tracking_url} noWrap>
|
|
49
|
+
{shipment.tracking_url}
|
|
50
|
+
</Link>
|
|
51
|
+
) : (
|
|
52
|
+
"Not received yet"
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
</ListItem>
|
|
57
|
+
<ListItem>
|
|
58
|
+
<ListItemText
|
|
59
|
+
primary="Date sent"
|
|
60
|
+
secondary={
|
|
61
|
+
shipment.date_sent != null && shipment.date_sent !== ""
|
|
62
|
+
? new Date(shipment.date_sent).toISOString().substring(0, 10)
|
|
63
|
+
: "Not shipped yet"
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
</ListItem>
|
|
67
|
+
</List>
|
|
68
|
+
</CardContent>
|
|
77
69
|
</Card>
|
|
78
70
|
);
|
|
79
71
|
};
|
|
72
|
+
|
|
73
|
+
export default ShipmentCard;
|
|
@@ -9,7 +9,7 @@ import Content from "../../../../containers/Content";
|
|
|
9
9
|
import { ContribComponent } from "../../../../types";
|
|
10
10
|
import { OrderListItem } from "../../types/order";
|
|
11
11
|
import { LimitOffset } from "../../types/util";
|
|
12
|
-
import
|
|
12
|
+
import OrderDetail from "../order/OrderDetail";
|
|
13
13
|
|
|
14
14
|
const PurchaseOrderList: ContribComponent<LimitOffset<OrderListItem>> = ({
|
|
15
15
|
data: { next: _next, previous: _previous, results },
|
|
@@ -33,7 +33,7 @@ const PurchaseOrderList: ContribComponent<LimitOffset<OrderListItem>> = ({
|
|
|
33
33
|
</Typography>
|
|
34
34
|
) : null}
|
|
35
35
|
{results.map((order) => (
|
|
36
|
-
<
|
|
36
|
+
<OrderDetail key={order.reference} order={order} />
|
|
37
37
|
))}
|
|
38
38
|
</Stack>
|
|
39
39
|
</Grid>
|