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.
Files changed (103) hide show
  1. package/dist/cjs/api.js +13 -0
  2. package/dist/cjs/api.js.map +1 -1
  3. package/dist/cjs/contexts/ApiContext.js +13 -14
  4. package/dist/cjs/contexts/ApiContext.js.map +1 -1
  5. package/dist/cjs/extensions/fulfillment/components/AddressInfo.js +7 -5
  6. package/dist/cjs/extensions/fulfillment/components/AddressInfo.js.map +1 -1
  7. package/dist/cjs/extensions/fulfillment/components/RecipientCard.js +18 -15
  8. package/dist/cjs/extensions/fulfillment/components/RecipientCard.js.map +1 -1
  9. package/dist/cjs/extensions/fulfillment/components/ShipmentCard.js +22 -37
  10. package/dist/cjs/extensions/fulfillment/components/ShipmentCard.js.map +1 -1
  11. package/dist/cjs/extensions/fulfillment/components/contrib/PurchaseOrderList.js +2 -2
  12. package/dist/cjs/extensions/fulfillment/components/contrib/PurchaseOrderList.js.map +1 -1
  13. package/dist/cjs/extensions/fulfillment/components/order/OrderDestinationCard.js +38 -0
  14. package/dist/cjs/extensions/fulfillment/components/order/OrderDestinationCard.js.map +1 -0
  15. package/dist/cjs/extensions/fulfillment/components/order/OrderDetail.js +276 -0
  16. package/dist/cjs/extensions/fulfillment/components/order/OrderDetail.js.map +1 -0
  17. package/dist/cjs/extensions/fulfillment/index.js +21 -25
  18. package/dist/cjs/extensions/fulfillment/index.js.map +1 -1
  19. package/dist/cjs/extensions/pos/pages/purchase/detail.js +6 -21
  20. package/dist/cjs/extensions/pos/pages/purchase/detail.js.map +1 -1
  21. package/dist/esm/api.js +13 -0
  22. package/dist/esm/api.js.map +1 -1
  23. package/dist/esm/contexts/ApiContext.js +13 -14
  24. package/dist/esm/contexts/ApiContext.js.map +1 -1
  25. package/dist/esm/extensions/fulfillment/components/AddressInfo.js +7 -5
  26. package/dist/esm/extensions/fulfillment/components/AddressInfo.js.map +1 -1
  27. package/dist/esm/extensions/fulfillment/components/RecipientCard.js +18 -15
  28. package/dist/esm/extensions/fulfillment/components/RecipientCard.js.map +1 -1
  29. package/dist/esm/extensions/fulfillment/components/ShipmentCard.js +22 -37
  30. package/dist/esm/extensions/fulfillment/components/ShipmentCard.js.map +1 -1
  31. package/dist/esm/extensions/fulfillment/components/contrib/PurchaseOrderList.js +2 -2
  32. package/dist/esm/extensions/fulfillment/components/contrib/PurchaseOrderList.js.map +1 -1
  33. package/dist/esm/extensions/fulfillment/components/order/OrderDestinationCard.js +31 -0
  34. package/dist/esm/extensions/fulfillment/components/order/OrderDestinationCard.js.map +1 -0
  35. package/dist/esm/extensions/fulfillment/components/order/OrderDetail.js +248 -0
  36. package/dist/esm/extensions/fulfillment/components/order/OrderDetail.js.map +1 -0
  37. package/dist/esm/extensions/fulfillment/index.js +21 -25
  38. package/dist/esm/extensions/fulfillment/index.js.map +1 -1
  39. package/dist/esm/extensions/pos/pages/purchase/detail.js +6 -21
  40. package/dist/esm/extensions/pos/pages/purchase/detail.js.map +1 -1
  41. package/dist/types/App.d.ts +2 -2
  42. package/dist/types/api.d.ts +1 -0
  43. package/dist/types/contexts/ApiContext.d.ts +2 -2
  44. package/dist/types/extensions/fulfillment/components/AddressInfo.d.ts +1 -0
  45. package/dist/types/extensions/fulfillment/components/RecipientCard.d.ts +3 -1
  46. package/dist/types/extensions/fulfillment/components/ShipmentCard.d.ts +3 -2
  47. package/dist/types/extensions/fulfillment/components/order/OrderDestinationCard.d.ts +7 -0
  48. package/dist/types/extensions/fulfillment/components/order/OrderDetail.d.ts +7 -0
  49. package/dist/types/extensions/fulfillment/index.d.ts +2 -2
  50. package/dist/types/extensions/fulfillment/types/order.d.ts +6 -5
  51. package/dist/types/extensions/fulfillment/types/recipient.d.ts +1 -5
  52. package/dist/types/extensions/fulfillment/types/shipment.d.ts +2 -57
  53. package/dist/types/extensions/pos/types/purchase.d.ts +1 -0
  54. package/dist/types/types/index.d.ts +4 -4
  55. package/example/index.tsx +4 -1
  56. package/example/package-lock.json +1 -1
  57. package/package.json +1 -1
  58. package/src/App.tsx +2 -2
  59. package/src/api.ts +14 -0
  60. package/src/contexts/ApiContext.tsx +10 -8
  61. package/src/extensions/fulfillment/components/AddressInfo.tsx +9 -5
  62. package/src/extensions/fulfillment/components/RecipientCard.tsx +47 -22
  63. package/src/extensions/fulfillment/components/ShipmentCard.tsx +57 -63
  64. package/src/extensions/fulfillment/components/contrib/PurchaseOrderList.tsx +2 -2
  65. package/src/extensions/fulfillment/components/order/OrderDestinationCard.tsx +68 -0
  66. package/src/extensions/fulfillment/components/order/OrderDetail.tsx +262 -0
  67. package/src/extensions/fulfillment/index.tsx +13 -35
  68. package/src/extensions/fulfillment/types/order.ts +7 -5
  69. package/src/extensions/fulfillment/types/recipient.ts +1 -6
  70. package/src/extensions/fulfillment/types/shipment.ts +2 -60
  71. package/src/extensions/pos/pages/purchase/detail.tsx +8 -12
  72. package/src/extensions/pos/types/purchase.ts +1 -0
  73. package/src/types/index.ts +8 -4
  74. package/dist/cjs/extensions/fulfillment/components/ContactInfo.js +0 -21
  75. package/dist/cjs/extensions/fulfillment/components/ContactInfo.js.map +0 -1
  76. package/dist/cjs/extensions/fulfillment/components/ShipmentAccordion.js +0 -215
  77. package/dist/cjs/extensions/fulfillment/components/ShipmentAccordion.js.map +0 -1
  78. package/dist/cjs/extensions/fulfillment/components/ShipmentItemsCard.js +0 -131
  79. package/dist/cjs/extensions/fulfillment/components/ShipmentItemsCard.js.map +0 -1
  80. package/dist/cjs/extensions/fulfillment/components/ShipmentItemsTable.js +0 -85
  81. package/dist/cjs/extensions/fulfillment/components/ShipmentItemsTable.js.map +0 -1
  82. package/dist/cjs/extensions/fulfillment/components/ShipmentRow.js +0 -29
  83. package/dist/cjs/extensions/fulfillment/components/ShipmentRow.js.map +0 -1
  84. package/dist/esm/extensions/fulfillment/components/ContactInfo.js +0 -14
  85. package/dist/esm/extensions/fulfillment/components/ContactInfo.js.map +0 -1
  86. package/dist/esm/extensions/fulfillment/components/ShipmentAccordion.js +0 -208
  87. package/dist/esm/extensions/fulfillment/components/ShipmentAccordion.js.map +0 -1
  88. package/dist/esm/extensions/fulfillment/components/ShipmentItemsCard.js +0 -124
  89. package/dist/esm/extensions/fulfillment/components/ShipmentItemsCard.js.map +0 -1
  90. package/dist/esm/extensions/fulfillment/components/ShipmentItemsTable.js +0 -78
  91. package/dist/esm/extensions/fulfillment/components/ShipmentItemsTable.js.map +0 -1
  92. package/dist/esm/extensions/fulfillment/components/ShipmentRow.js +0 -22
  93. package/dist/esm/extensions/fulfillment/components/ShipmentRow.js.map +0 -1
  94. package/dist/types/extensions/fulfillment/components/ContactInfo.d.ts +0 -7
  95. package/dist/types/extensions/fulfillment/components/ShipmentAccordion.d.ts +0 -7
  96. package/dist/types/extensions/fulfillment/components/ShipmentItemsCard.d.ts +0 -6
  97. package/dist/types/extensions/fulfillment/components/ShipmentItemsTable.d.ts +0 -8
  98. package/dist/types/extensions/fulfillment/components/ShipmentRow.d.ts +0 -7
  99. package/src/extensions/fulfillment/components/ContactInfo.tsx +0 -33
  100. package/src/extensions/fulfillment/components/ShipmentAccordion.tsx +0 -209
  101. package/src/extensions/fulfillment/components/ShipmentItemsCard.tsx +0 -170
  102. package/src/extensions/fulfillment/components/ShipmentItemsTable.tsx +0 -116
  103. package/src/extensions/fulfillment/components/ShipmentRow.tsx +0 -32
@@ -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 { ContribComponents } from "./types";
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?: ContribComponents[];
12
+ contrib?: ContribComponentMap;
13
13
  } & AdminProps;
14
14
  declare const App: React.FC<AppProps>;
15
15
  export default App;
@@ -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 { ContribComponents } from "../types";
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?: ContribComponents[];
10
+ contrib?: ContribComponentMap;
11
11
  }
12
12
  declare const ApiContext: React.Context<ApiClient>;
13
13
  export declare const useApi: () => ApiClient;
@@ -6,6 +6,7 @@ export interface AddressInfoProps {
6
6
  careOf?: string;
7
7
  postalCode: string;
8
8
  city: string;
9
+ region?: string;
9
10
  countryCode: string;
10
11
  }
11
12
  export declare const AddressInfo: React.FC<AddressInfoProps>;
@@ -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 { ShipmentListItem } from "../types/shipment";
2
+ import { Shipment } from "../types/shipment";
3
3
  export interface ShipmentCardProps {
4
- shipment: ShipmentListItem;
4
+ shipment: Shipment;
5
5
  }
6
6
  export declare const ShipmentCard: React.FC<ShipmentCardProps>;
7
+ export default ShipmentCard;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { OrderDetail } from "../../types/order";
3
+ interface OrderDestinationCard {
4
+ order: OrderDetail;
5
+ }
6
+ export declare const OrderDestinationCard: React.FC<OrderDestinationCard>;
7
+ export default OrderDestinationCard;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { OrderDetail, OrderListItem } from "../../types/order";
3
+ interface OrderDetailProps {
4
+ order: OrderListItem;
5
+ }
6
+ declare const OrderDetail: React.FC<OrderDetailProps>;
7
+ export default OrderDetail;
@@ -1,5 +1,5 @@
1
1
  import { RouterExtension } from "../../router/Router";
2
- import { ContribComponents, NavigationOverrides } from "../../types";
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: ContribComponents;
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
- carrier: string;
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
- date_confirmed?: string;
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
  }
@@ -11,6 +11,7 @@ export interface PurchaseDetail {
11
11
  country_code: string;
12
12
  given_name?: string;
13
13
  family_name?: string;
14
+ company_name?: string;
14
15
  email: string;
15
16
  phone?: string;
16
17
  total_debit_amount?: string;
@@ -19,7 +19,7 @@ export interface PageContribComponent {
19
19
  title?: string;
20
20
  component: ContribComponent | Promise<ContribComponent>;
21
21
  }
22
- export interface ContribComponents {
23
- app: string;
24
- component: (tag: string) => PageContribComponent | undefined;
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={[Bananas.fulfillment.contrib]}
18
+ contrib={{
19
+ ...Bananas.fulfillment.contrib.orders,
20
+ ...Bananas.fulfillment.contrib.returns,
21
+ }}
19
22
  theme={createTheme({
20
23
  palette: {
21
24
  primary: {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "..": {
39
39
  "name": "bananas-commerce-admin",
40
- "version": "0.3.4",
40
+ "version": "0.3.20",
41
41
  "dependencies": {
42
42
  "libphonenumber-js": "^1.10.24",
43
43
  "luxon": "^3.3.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bananas-commerce-admin",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "Bananas-commerce admin interface and building blocks",
5
5
  "keywords": [
6
6
  "admin",
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 { ContribComponents } from "./types";
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?: ContribComponents[];
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 { ContribComponents } from "../types";
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?: ContribComponents[];
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 [app, operation] of Object.entries(operations)) {
48
- const hit = contribMap.get(app)?.(tag);
49
- operation.component = hit;
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("sv", { type: "region" });
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
- {careOf != null && careOf !== "" ? <Typography noWrap>c/o {careOf}</Typography> : null}
35
- <Typography noWrap>
36
- {`${postalCode} ${city}, ${countryCodeFormatter.of(countryCode)}`}
37
- </Typography>
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 Divider from "@mui/material/Divider";
7
- import Grid from "@mui/material/Grid";
8
- import { useTheme } from "@mui/material/styles";
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 title={"Recipient"} />
24
+ <CardHeader
25
+ title={
26
+ <Typography variant="h6">
27
+ <b>Recipient</b>
28
+ </Typography>
29
+ }
30
+ avatar={<PersonOutlinedIcon />}
31
+ />
23
32
  <CardContent>
24
- <Divider sx={{ marginBottom: theme.spacing(2) }} />
25
- <Grid container spacing={2}>
26
- <Grid item xs={6}>
27
- <Typography color={"text.secondary"}>{"Recipient"}</Typography>
28
- <Typography>{`${recipient.given_name} ${recipient.family_name}`}</Typography>
29
- <Typography>{recipient.street_address}</Typography>
30
- {recipient.street_address2 ? (
31
- <Typography>{recipient.street_address2}</Typography>
32
- ) : null}
33
- {recipient.care_of ? <Typography>{recipient.care_of}</Typography> : null}
34
- <Typography>
35
- {`${recipient.postal_code} ${recipient.city} ${recipient.country_code}`}
36
- </Typography>
37
- </Grid>
38
- </Grid>
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 Box from "@mui/material/Box";
3
+ import LocalShippingOutlinedIcon from "@mui/icons-material/LocalShippingOutlined";
4
4
  import Card from "@mui/material/Card";
5
- import CardActionArea from "@mui/material/CardActionArea";
6
- import { useTheme } from "@mui/material/styles";
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 { useRouter } from "../../../contexts/RouterContext";
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: ShipmentListItem;
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
- <CardActionArea onClick={onClick}>
37
- <Stack
38
- padding={1}
39
- bgcolor={theme.palette.secondary.main}
40
- justifyContent="space-between"
41
- direction="row"
42
- >
43
- <Stack spacing={1} direction="row">
44
- <ShipmentDestinationIcon
45
- type={shipment.destination_type!}
46
- htmlColor={theme.palette.secondary.contrastText}
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
- <Typography color={theme.palette.secondary.contrastText}>
49
- {shipment.option_name} for purchase {formatPurchaseNumber(shipment.purchase_number)}
50
- </Typography>
51
- </Stack>
52
- </Stack>
53
- <Stack
54
- padding={1}
55
- direction={{ sm: "column", md: "row" }}
56
- spacing={2}
57
- justifyContent="space-between"
58
- minHeight={100}
59
- >
60
- <Box sx={{ width: "100%" }}>
61
- <Typography>{shipment.shipment_reference}</Typography>
62
- <Typography>
63
- {shipment.date_sent != null
64
- ? dateTimeFormatter.format(new Date(shipment.date_sent))
65
- : "Ej skickat"}
66
- </Typography>
67
- </Box>
68
- <Box sx={{ width: "100%" }}>
69
- <ContactInfo name={shipment.name} email={shipment.email} phone={shipment.phone} />
70
- </Box>
71
- <Box sx={{ width: "100%" }}>
72
- <Typography>{shipment.carrier}</Typography>
73
- <Typography>{shipment.tracking_number}</Typography>
74
- </Box>
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 OrderAccordion from "../order/OrderAccordion";
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
- <OrderAccordion key={order.reference} order={order} />
36
+ <OrderDetail key={order.reference} order={order} />
37
37
  ))}
38
38
  </Stack>
39
39
  </Grid>