@evenicanpm/storefront-core 2.2.0 → 2.3.0
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/package.json +7 -3
- package/src/api-manager/README.md +52 -27
- package/src/api-manager/datasources/d365/d365-cart.datasource.ts +166 -17
- package/src/api-manager/datasources/d365/d365-invoice.datasource.ts +100 -0
- package/src/api-manager/datasources/d365/d365-order.datasource.ts +75 -18
- package/src/api-manager/datasources/d365/d365-product.datasource.ts +19 -1
- package/src/api-manager/datasources/d365/d365-user.datasource.ts +96 -22
- package/src/api-manager/datasources/d365/d365.datasource.ts +3 -0
- package/src/api-manager/datasources/d365/utils/get-context-cookie.ts +10 -3
- package/src/api-manager/datasources/e4/e4.datasource.ts +9 -0
- package/src/api-manager/datasources/e4/order/e4-order.datasource.ts +7 -4
- package/src/api-manager/datasources/e4/user/e4-user.datasource.ts +4 -0
- package/src/api-manager/index.ts +54 -3
- package/src/api-manager/lib/get-graphql-client.ts +11 -5
- package/src/api-manager/schemas/cart.schema.ts +10 -1
- package/src/api-manager/schemas/invoice.schema.ts +55 -0
- package/src/api-manager/schemas/order.schema.ts +13 -1
- package/src/api-manager/schemas/user.schema.ts +8 -0
- package/src/api-manager/services/create-query.ts +4 -10
- package/src/api-manager/services/invoice/queries/get-invoice-details.ts +18 -0
- package/src/api-manager/services/invoice/queries/get-invoices.ts +18 -0
- package/src/api-manager/services/order/queries/get-order-details.ts +1 -1
- package/src/api-manager/services/order/queries/get-orders.ts +6 -3
- package/src/api-manager/services/user/queries/get-customer-balance.ts +20 -0
- package/src/api-manager/types/Datasource.ts +21 -2
- package/src/auth/better-auth.ts +1 -1
- package/src/cms/blocks/block-manager.tsx +18 -3
- package/src/cms/blocks/components/cta-banner.tsx +65 -0
- package/src/cms/blocks/components/hero-image.tsx +83 -0
- package/src/cms/blocks/index.tsx +2 -0
- package/src/cms/blocks/interfaces.ts +20 -0
- package/src/cms/draft-mode-badge.tsx +26 -0
- package/src/cms/queries.ts +81 -0
- package/src/components/flex-box/flex-box.tsx +2 -0
- package/src/components/header/components/user.tsx +37 -12
- package/src/components/mini-cart/mini-cart.tsx +3 -3
- package/src/components/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-header.tsx +1 -0
- package/src/pages/account/account-navigation.tsx +88 -60
- package/src/pages/account/account-routes.ts +52 -0
- package/src/pages/account/orders/order-history-filter-types.tsx +26 -0
- package/src/pages/account/orders/order-history-filters-panel.tsx +375 -0
- package/src/pages/account/orders/order-history-header.tsx +54 -0
- package/src/pages/account/orders/order-history-pagination.tsx +55 -0
- package/src/pages/account/orders/order-history-root.tsx +125 -0
- package/src/pages/account/orders/order-history-row.tsx +110 -0
- package/src/pages/account/orders/order-history-search-and-filter.tsx +449 -0
- package/src/pages/account/orders/order-history-search-bar.tsx +84 -0
- package/src/pages/account/orders/order-history-search-dropdown.tsx +53 -0
- package/src/pages/account/orders/order-history-sort.tsx +90 -0
- package/src/pages/account/orders/order-history-table.tsx +54 -0
- package/src/pages/account/orders/order-row.tsx +2 -2
- package/src/pages/account/orders/orders-drop-down-handler.tsx +19 -0
- package/src/pages/account/table-header.tsx +20 -0
- package/src/pages/account/wishlist/wishlist-item.tsx +1 -1
- package/src/pages/blog/blog-card.tsx +9 -3
- package/src/pages/blog/blog-detail-view.tsx +150 -0
- package/src/pages/blog/blog-list-view.tsx +59 -0
- package/src/pages/cart/estimate-shipping.tsx +6 -5
- package/src/pages/checkout/checkout-alt-form/checkout-form.tsx +43 -21
- package/src/pages/checkout/checkout-alt-form/steps/payment/payment-details.tsx +144 -19
- package/src/pages/cms-page-view.tsx +53 -0
- package/src/pages/quickorder/order-upload.tsx +12 -6
- package/src/pages/quickorder/quick-order.tsx +25 -20
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
import MuiPagination from "@mui/material/Pagination";
|
|
3
|
+
import { Box } from "@mui/system";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import type { ChangeEvent } from "react";
|
|
6
|
+
import { PAGE_SIZE, useOrderHistory } from "./order-history-root";
|
|
7
|
+
|
|
8
|
+
const OrdersPagination = ({ children }: { children: React.ReactNode }) => {
|
|
9
|
+
return (
|
|
10
|
+
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
|
|
11
|
+
{children}
|
|
12
|
+
</Box>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const ResultNumber = () => {
|
|
17
|
+
const { pageNumber, orders } = useOrderHistory();
|
|
18
|
+
const t = useTranslations("Account.Orders");
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Typography color="grey.600">
|
|
22
|
+
{t("showingRange", {
|
|
23
|
+
start: (pageNumber - 1) * PAGE_SIZE,
|
|
24
|
+
end: (pageNumber - 1) * PAGE_SIZE + orders.length,
|
|
25
|
+
total: 500,
|
|
26
|
+
})}
|
|
27
|
+
</Typography>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const PaginationControl = () => {
|
|
32
|
+
const { pageNumber, setPageNumber } = useOrderHistory();
|
|
33
|
+
|
|
34
|
+
const handleMuiPaginationChange = (
|
|
35
|
+
_event: ChangeEvent<unknown>,
|
|
36
|
+
newPage: number,
|
|
37
|
+
) => {
|
|
38
|
+
setPageNumber(newPage);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<MuiPagination
|
|
43
|
+
color="primary"
|
|
44
|
+
variant="outlined"
|
|
45
|
+
count={25}
|
|
46
|
+
page={pageNumber}
|
|
47
|
+
onChange={handleMuiPaginationChange}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
OrdersPagination.ResultNumber = ResultNumber;
|
|
53
|
+
OrdersPagination.PaginationControl = PaginationControl;
|
|
54
|
+
|
|
55
|
+
export default OrdersPagination;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { SalesOrder } from "@evenicanpm/storefront-core/src/api-manager/schemas/order.schema";
|
|
2
|
+
import getOrders from "@evenicanpm/storefront-core/src/api-manager/services/order/queries/get-orders";
|
|
3
|
+
import type {
|
|
4
|
+
OrderSearchCriteria,
|
|
5
|
+
SortColumn,
|
|
6
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
7
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
8
|
+
import OrdersSearchAndFilter from "./order-history-search-and-filter";
|
|
9
|
+
import OrdersSort from "./order-history-sort";
|
|
10
|
+
import OrderHistoryTable from "./order-history-table";
|
|
11
|
+
|
|
12
|
+
export const PAGE_SIZE = 10;
|
|
13
|
+
|
|
14
|
+
export type OrderHistoryContextType = {
|
|
15
|
+
orderSearchCriteria: OrderSearchCriteria;
|
|
16
|
+
setOrderSearchCriteria: (criteria: OrderSearchCriteria) => void;
|
|
17
|
+
sortColumn: SortColumn;
|
|
18
|
+
setSortColumn: (sort: SortColumn) => void;
|
|
19
|
+
pageNumber: number;
|
|
20
|
+
setPageNumber: (page: number) => void;
|
|
21
|
+
orders: SalesOrder[];
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const OrderHistoryContext = createContext<
|
|
26
|
+
OrderHistoryContextType | undefined
|
|
27
|
+
>(undefined);
|
|
28
|
+
|
|
29
|
+
export const useOrderHistory = () => {
|
|
30
|
+
const context = useContext(OrderHistoryContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error("Context must be used within a OrderHistoryProvider");
|
|
33
|
+
}
|
|
34
|
+
return context;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const OrderHistory = ({ children }: { children: React.ReactNode }) => {
|
|
38
|
+
const [orderSearchCriteria, setOrderSearchCriteria] =
|
|
39
|
+
useState<OrderSearchCriteria>({});
|
|
40
|
+
const [pageNumber, setPageNumber] = useState<number>(1);
|
|
41
|
+
const [sortColumn, setSortColumn] = useState<SortColumn>({
|
|
42
|
+
ColumnName: "CREATEDDATETIME",
|
|
43
|
+
IsDescending: true,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const { data: orders, isLoading } = getOrders.useData({
|
|
47
|
+
orderSearchCriteria,
|
|
48
|
+
paging: {
|
|
49
|
+
Top: PAGE_SIZE,
|
|
50
|
+
Skip: (pageNumber - 1) * PAGE_SIZE,
|
|
51
|
+
},
|
|
52
|
+
sort: sortColumn,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const value = useMemo(
|
|
56
|
+
() => ({
|
|
57
|
+
orderSearchCriteria,
|
|
58
|
+
setOrderSearchCriteria,
|
|
59
|
+
sortColumn,
|
|
60
|
+
setSortColumn,
|
|
61
|
+
pageNumber,
|
|
62
|
+
setPageNumber,
|
|
63
|
+
orders: orders ?? [],
|
|
64
|
+
isLoading,
|
|
65
|
+
}),
|
|
66
|
+
[orderSearchCriteria, sortColumn, pageNumber, orders, isLoading],
|
|
67
|
+
);
|
|
68
|
+
return (
|
|
69
|
+
<OrderHistoryContext.Provider value={value}>
|
|
70
|
+
{children}
|
|
71
|
+
</OrderHistoryContext.Provider>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
OrderHistory.SearchAndFilter = OrdersSearchAndFilter;
|
|
76
|
+
|
|
77
|
+
OrderHistory.Sort = () => {
|
|
78
|
+
const { setSortColumn } = useOrderHistory();
|
|
79
|
+
return <OrdersSort setSortColumn={setSortColumn} />;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
OrderHistory.Table = OrderHistoryTable;
|
|
83
|
+
|
|
84
|
+
// OrderHistory.Table = () => {
|
|
85
|
+
// const { orders, isLoading } = useOrderHistory();
|
|
86
|
+
|
|
87
|
+
// return (
|
|
88
|
+
// <OrderHistoryTable>
|
|
89
|
+
// <OrderHistoryTable.Header>
|
|
90
|
+
// <OrderHistoryTable.Header.OrderNumber />
|
|
91
|
+
// <OrderHistoryTable.Header.OrderStatus />
|
|
92
|
+
// <OrderHistoryTable.Header.TransactionDate />
|
|
93
|
+
// <OrderHistoryTable.Header.TransactionAmount />
|
|
94
|
+
// </OrderHistoryTable.Header>
|
|
95
|
+
|
|
96
|
+
// {!isLoading ? (
|
|
97
|
+
// orders && orders.length > 0 ? (
|
|
98
|
+
// <Fragment>
|
|
99
|
+
// {orders.map((order: SalesOrder) => (
|
|
100
|
+
// <OrderHistoryTable.Row order={order} key={order.RecordId}>
|
|
101
|
+
// <OrderHistoryTable.Row.OrderNumber />
|
|
102
|
+
// <OrderHistoryTable.Row.OrderStatus />
|
|
103
|
+
// <OrderHistoryTable.Row.TransactionDate />
|
|
104
|
+
// <OrderHistoryTable.Row.TransactionAmount />
|
|
105
|
+
// <OrderHistoryTable.Row.DetailsIcon />
|
|
106
|
+
// </OrderHistoryTable.Row>
|
|
107
|
+
// ))}
|
|
108
|
+
// <OrderHistoryTable.Pagination>
|
|
109
|
+
// <OrderHistoryTable.Pagination.ResultNumber />
|
|
110
|
+
// <OrderHistoryTable.Pagination.PaginationControl />
|
|
111
|
+
// </OrderHistoryTable.Pagination>
|
|
112
|
+
// </Fragment>
|
|
113
|
+
// ) : (
|
|
114
|
+
// <NoRecords message="Account.Orders.noOrders" />
|
|
115
|
+
// )
|
|
116
|
+
// ) : (
|
|
117
|
+
// <Box sx={{ display: "flex", justifyContent: "center", mt: 2 }}>
|
|
118
|
+
// <CircularProgress size={30} />
|
|
119
|
+
// </Box>
|
|
120
|
+
// )}
|
|
121
|
+
// </OrderHistoryTable>
|
|
122
|
+
// );
|
|
123
|
+
// };
|
|
124
|
+
|
|
125
|
+
export default OrderHistory;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { SalesOrder } from "@evenicanpm/storefront-core/src/api-manager/schemas/order.schema";
|
|
2
|
+
// GLOBAL CUSTOM COMPONENT
|
|
3
|
+
import {
|
|
4
|
+
H6,
|
|
5
|
+
Paragraph,
|
|
6
|
+
} from "@evenicanpm/storefront-core/src/components/Typography";
|
|
7
|
+
import useCurrencyFormatter from "@evenicanpm/storefront-core/src/lib/currency-formatter";
|
|
8
|
+
// CUSTOM UTILS LIBRARY FUNCTION;
|
|
9
|
+
import TableRow from "@evenicanpm/storefront-core/src/pages/account/table-row";
|
|
10
|
+
import type { ChipProps } from "@mui/material";
|
|
11
|
+
import Box from "@mui/material/Box";
|
|
12
|
+
import Chip from "@mui/material/Chip";
|
|
13
|
+
import IconButton from "@mui/material/IconButton";
|
|
14
|
+
import { format } from "date-fns";
|
|
15
|
+
import Link from "next/link";
|
|
16
|
+
import { createContext, useContext } from "react";
|
|
17
|
+
import { MdEast as East } from "react-icons/md";
|
|
18
|
+
|
|
19
|
+
const STATUS_MAP: Record<number, { label: string; color: ChipProps["color"] }> =
|
|
20
|
+
{
|
|
21
|
+
1: { label: "Created", color: "secondary" },
|
|
22
|
+
2: { label: "Processing", color: "secondary" },
|
|
23
|
+
3: { label: "Delivered", color: "success" },
|
|
24
|
+
4: { label: "Invoiced", color: "primary" },
|
|
25
|
+
7: { label: "Cancelled", color: "primary" },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getStatusInfo = (status: number) => {
|
|
29
|
+
return STATUS_MAP[status] ?? { label: "Pending", color: "default" };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type OrderHistoryTableRowContextType = {
|
|
33
|
+
order: SalesOrder;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const OrderHistoryTableRowContext = createContext<
|
|
37
|
+
OrderHistoryTableRowContextType | undefined
|
|
38
|
+
>(undefined);
|
|
39
|
+
|
|
40
|
+
export const useOrderHistoryTableRow = () => {
|
|
41
|
+
const context = useContext(OrderHistoryTableRowContext);
|
|
42
|
+
if (!context) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"Context must be used within a OrderHistoryTableRowContextProvider",
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return context;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const OrderHistoryTableRow = ({ children }: { children: React.ReactNode }) => {
|
|
51
|
+
const { order } = useOrderHistoryTableRow();
|
|
52
|
+
const useTransactionId = order.Id && order.Id !== " ";
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Link
|
|
56
|
+
href={`/account/orders/${useTransactionId ? order.Id : order.SalesId}/?id=${useTransactionId ? "TransactionId" : "SalesId"}`}
|
|
57
|
+
>
|
|
58
|
+
<TableRow sx={{ gridTemplateColumns: "2fr 1fr 1fr 1fr 1fr" }}>
|
|
59
|
+
{children}
|
|
60
|
+
</TableRow>
|
|
61
|
+
</Link>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
OrderHistoryTableRow.OrderNumber = () => {
|
|
66
|
+
const { order } = useOrderHistoryTableRow();
|
|
67
|
+
return <H6 ellipsis>{order?.ChannelReferenceId}</H6>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
OrderHistoryTableRow.OrderStatus = () => {
|
|
71
|
+
const { order } = useOrderHistoryTableRow();
|
|
72
|
+
const { label, color } = getStatusInfo(order.StatusValue ?? 0);
|
|
73
|
+
return (
|
|
74
|
+
<Box textAlign="center">
|
|
75
|
+
<Chip size="small" label={label} color={color} />
|
|
76
|
+
</Box>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
OrderHistoryTableRow.TransactionDate = () => {
|
|
81
|
+
const { order } = useOrderHistoryTableRow();
|
|
82
|
+
return (
|
|
83
|
+
<Paragraph textAlign={{ sm: "center", xs: "left" }}>
|
|
84
|
+
{format(new Date(order.CreatedDateTime ?? ""), "MMM dd, yyyy")}
|
|
85
|
+
</Paragraph>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
OrderHistoryTableRow.TransactionAmount = () => {
|
|
90
|
+
const { order } = useOrderHistoryTableRow();
|
|
91
|
+
const { formatCurrency } = useCurrencyFormatter();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Paragraph textAlign="center">
|
|
95
|
+
{formatCurrency(order.TotalAmount ?? 0)}
|
|
96
|
+
</Paragraph>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
OrderHistoryTableRow.DetailsIcon = () => {
|
|
101
|
+
return (
|
|
102
|
+
<Box display={{ sm: "inline-flex", xs: "none" }} justifyContent="end">
|
|
103
|
+
<IconButton sx={{ color: "grey.500" }}>
|
|
104
|
+
<East fontSize="large" />
|
|
105
|
+
</IconButton>
|
|
106
|
+
</Box>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default OrderHistoryTableRow;
|