diff --git a/apps/cms/src/admin/views/MerchPromotion.tsx b/apps/cms/src/admin/views/MerchPromotion.tsx
index fbfbe256..81a4d1da 100644
--- a/apps/cms/src/admin/views/MerchPromotion.tsx
+++ b/apps/cms/src/admin/views/MerchPromotion.tsx
@@ -111,22 +111,18 @@ const MerchPromotion: AdminView = ({ user, canAccessAdmin }) => {
keywords=""
title="Merchandise Promotion"
>
-
+
+
-
-
-
+
+
);
};
diff --git a/apps/cms/src/admin/views/MerchSales.tsx b/apps/cms/src/admin/views/MerchSales.tsx
index 81d2d3f2..4cc6138d 100644
--- a/apps/cms/src/admin/views/MerchSales.tsx
+++ b/apps/cms/src/admin/views/MerchSales.tsx
@@ -3,19 +3,18 @@ import { Button } from "payload/components/elements";
import { AdminView } from "payload/config";
import ViewTemplate from "./ViewTemplate";
import { Column } from "payload/dist/admin/components/elements/Table/types";
-import { Order } from "../../@types/Order";
-import OrdersApi from "../../apis/orders.api";
-import { IOrder } from "../../@types/IOrder";
import { RenderCellFactory } from "../utils/RenderCellFactory";
import SortedColumn from "../utils/SortedColumn";
import { Table } from "payload/dist/admin/components/elements/Table";
+import { Promotion } from "types";
+import PromotionsApi from "../../apis/promotions.api";
-const MerchSales: AdminView = ({ user, canAccessAdmin }) => {
+const MerchPromotion: AdminView = ({ user, canAccessAdmin }) => {
// Get data from API
- const [data, setData] = useState
(null);
+ const [data, setData] = useState(null);
useEffect(() => {
- OrdersApi.getOrders()
- .then((res: IOrder[]) => setData(res))
+ PromotionsApi.getPromotions()
+ .then((res: Promotion[]) => setData(res))
.catch((error) => console.log(error));
}, []);
@@ -30,34 +29,34 @@ const MerchSales: AdminView = ({ user, canAccessAdmin }) => {
// Do not load table until we receive the data
if (data == null) {
- return Loading...
;
+ return Loading...
;
}
const tableCols = new Array();
- for (const key of Object.keys(new Order())) {
- const renderCellComponent = RenderCellFactory.get(data[0], key);
- const renderCell: React.FC<{ children?: React.ReactNode }> =
- renderCellComponent instanceof Promise
- ? renderCellComponent
- : renderCellComponent;
-
- const col: Column = {
- accessor: key,
- components: {
- Heading: (
-
- ),
- renderCell: renderCell,
- },
- label: "",
- name: "",
- active: true,
- };
- tableCols.push(col);
+ if (data && data.length > 0) {
+ const sampleProduct = data[0];
+ const keys = Object.keys(sampleProduct);
+ for (const key of keys) {
+ const renderCell: React.FC<{ children?: React.ReactNode }> =
+ RenderCellFactory.get(sampleProduct, key);
+ const col: Column = {
+ accessor: key,
+ components: {
+ Heading: (
+
+ ),
+ renderCell: renderCell,
+ },
+ label: "",
+ name: "",
+ active: true,
+ };
+ tableCols.push(col);
+ }
}
const editColumn: Column = {
@@ -90,15 +89,17 @@ const MerchSales: AdminView = ({ user, canAccessAdmin }) => {
tableCols.push(deleteColumn);
- const handleEdit = (orderId: string) => {
- console.log(`Dummy. Order ID: ${orderId}`);
+ const handleEdit = (promotionID: string) => {
+ console.log(`Dummy. Promotion ID: ${promotionID}`);
};
- const handleDelete = (orderId: string) => {
- console.log(`Dummy. Order ID: ${orderId}`);
+ const handleDelete = (promotionID: string) => {
+ console.log(`Dummy. Promotion ID: ${promotionID}`);
};
- console.log(tableCols);
+ const handleCreatePromotion = () => {
+ console.log("Creating a new promotion...");
+ };
return (
{
canAccessAdmin={canAccessAdmin}
description=""
keywords=""
- title="Merchandise Sales"
+ title="Merchandise Promotion"
>
-
+
+
+
+
-
+ {/* Wrapper div with flexbox */}
+
);
};
-export default MerchSales;
+export default MerchPromotion;