Manage orders
+Order ID | +CUSTOMER | +PRODUCT | +DATE | +STATUS | +PRICE | +
---|---|---|---|---|---|
#{(transaction.id).slice(0, 3)} | +{transaction.user?.firstName} {transaction.user?.lastName} | +{orderItem.products.name} | ++ {new Date(transaction.createdAt).toLocaleDateString('en-US', { + year: 'numeric', + month: 'short', + day: '2-digit', + })} + | ++ + {transaction.status} + + | +{orderItem.price.toFixed(1)} | +
column.sortable && handleSort(column.key)} + className={`px-4 py-4 text-sm font-bold text-whiteColor uppercase tracking-wider ${ + column.sortable ? 'cursor-pointer' : '' + } ${column.isImage ? 'text-center' : 'text-left'}`} + > + {column.label} + {column.sortable && sortColumn === column.key && {sortDirection === 'asc' ? ' ▲' : ' ▼'}} + | + ))} +
---|
+ {renderCell(item, column)} + | + ))} +
!column.isImage && handleSort(column.key)}
- className={`pl-4 py-4 text-left text-sm font-bold text-[#6B7280] uppercase tracking-wider ${!column.isImage ? 'cursor-pointer' : ''}`}
+ className={`pl-4 py-4 text-left text-sm font-bold text-whiteColor uppercase tracking-wider ${!column.isImage ? 'cursor-pointer' : ''}`}
>
{column.label}
{!column.isImage && sortColumn === column.key && {sortDirection === 'asc' ? ' ▲' : ' ▼'}}
diff --git a/src/components/footer/Footer.tsx b/src/components/footer/Footer.tsx
index b156c9f..a7d989d 100644
--- a/src/components/footer/Footer.tsx
+++ b/src/components/footer/Footer.tsx
@@ -13,7 +13,7 @@ function Footer() {
K309 St , Makuza plaza, Nyarugenge , Kigali, Rwanda andela.mavericks@gmail.com -+250 788888888 ++250 788 888 888 - © 2024 Mavericks Shop. All rights reserved. + © {new Date().getFullYear()} Mavericks Shop. All rights reserved. > diff --git a/src/components/navbar/Navbar.tsx b/src/components/navbar/Navbar.tsx index c006e33..3636db0 100644 --- a/src/components/navbar/Navbar.tsx +++ b/src/components/navbar/Navbar.tsx @@ -114,7 +114,7 @@ const Navbar: React.FC = () => { )} {
+ variant?: keyof typeof buttonVariants
+ size?: keyof typeof buttonVariants
+}
+
+const Button = React.forwardRef Buyers ;
-}
+import React, { useEffect } from 'react';
+import Table from '../../components/dashboard/BuyersTable';
+import { BiLoader } from 'react-icons/bi';
+import { useGetBuyersQuery } from '../../services/userApi';
+import { User as Buyer } from '../../types/Types';
+
+const Buyers: React.FC = () => {
+ const {
+ data: buyersData,
+ isLoading: buyersLoading,
+ isError: buyersError,
+ refetch: refetchBuyers,
+ } = useGetBuyersQuery(undefined, {
+ pollingInterval: 30000,
+ });
+
+ const loading = buyersLoading;
+ const error = buyersError;
+
+ const buyers = buyersData?.message || [];
+
+ useEffect(() => {
+ refetchBuyers();
+ }, [refetchBuyers]);
+
+ const columns = [
+ { key: 'photoUrl', label: 'Photo', isImage: true, sortable: false },
+ { key: 'firstName', label: 'First Name', sortable: true },
+ { key: 'lastName', label: 'Last Name', sortable: true },
+ { key: 'email', label: 'Email', sortable: true },
+ { key: 'phoneNumber', label: 'Phone', sortable: true },
+ { key: 'gender', label: 'Gender', sortable: true },
+ {
+ key: 'Role.name',
+ label: 'Role',
+ render: (buyer: Buyer) => buyer.Role.name.toUpperCase(),
+ sortable: false,
+ },
+ ];
+
+ if (loading)
+ return (
+
+
+ );
+ if (error) {
+ return Error fetching data. Please try again. ;
+ }
+
+ return (
+
+
+ );
+};
+
+export default Buyers;
\ No newline at end of file
diff --git a/src/pages/admin/Messages.tsx b/src/pages/admin/Messages.tsx
deleted file mode 100644
index 365ea40..0000000
--- a/src/pages/admin/Messages.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function Messages() {
- return Messages ;
-}
diff --git a/src/pages/admin/Sellers.tsx b/src/pages/admin/Sellers.tsx
index f8bee62..5bb9d02 100644
--- a/src/pages/admin/Sellers.tsx
+++ b/src/pages/admin/Sellers.tsx
@@ -66,7 +66,7 @@ const Sellers: React.FC = () => {
{
key: 'Role.name',
label: 'Role',
- render: (seller: Seller) => seller.Role.name,
+ render: (seller: Seller) => seller.Role.name.toUpperCase(),
sortable: false,
},
{
@@ -96,7 +96,6 @@ const Sellers: React.FC = () => {
return (
- ;
-}
+// src/pages/admin/Settings.tsx
+
+import React, { useState } from 'react';
+import { FiSave, FiUser, FiLock, FiBell, FiGlobe, FiShield, FiRefreshCcw } from 'react-icons/fi';
+import { ToastContainer, toast } from 'react-toastify';
+import 'react-toastify/dist/ReactToastify.css';
+
+const Settings: React.FC = () => {
+ const defaultGeneralSettings = {
+ siteName: 'Mavericks',
+ siteUrl: 'https://mavericks.nijohn.dev',
+ adminEmail: 'admin.mavericks@gmail.com',
+ dateFormat: 'MM/DD/YYYY',
+ timeFormat: '12-hour',
+ theme: 'light',
+ profilePicture: '',
+ };
+
+ const defaultSecuritySettings = {
+ twoFactorAuth: false,
+ passwordExpiration: 90,
+ loginAttempts: 5,
+ minPasswordLength: 8,
+ specialCharRequirement: true,
+ };
+
+ const defaultNotificationSettings = {
+ emailNotifications: true,
+ pushNotifications: false,
+ smsNotifications: false,
+ newsletterFrequency: 'weekly',
+ };
+
+ const [generalSettings, setGeneralSettings] = useState(defaultGeneralSettings);
+ const [securitySettings, setSecuritySettings] = useState(defaultSecuritySettings);
+ const [notificationSettings, setNotificationSettings] = useState(defaultNotificationSettings);
+
+ const handleGeneralSettingsChange = (e: React.ChangeEventSeller Management
+
+ );
+};
+
+export default Settings;
diff --git a/src/pages/admin/UserManagement.tsx b/src/pages/admin/UserManagement.tsx
index d3d022d..56485c8 100644
--- a/src/pages/admin/UserManagement.tsx
+++ b/src/pages/admin/UserManagement.tsx
@@ -68,7 +68,7 @@ const UserManagement: React.FC = () => {
{
key: 'role',
label: 'Role',
- render: (user: User) => user.Role.name
+ render: (user: User) => user.Role.name.toUpperCase(),
},
{
key: 'action',
@@ -96,7 +96,6 @@ const UserManagement: React.FC = () => {
return (
Admin Settings+ +
- ;
+
+ return (
+ <>
+ User Management
+
+ >
+ );
}
+
diff --git a/src/redux/slices/orderSlice.ts b/src/redux/slices/orderSlice.ts
new file mode 100644
index 0000000..7a80c3e
--- /dev/null
+++ b/src/redux/slices/orderSlice.ts
@@ -0,0 +1,39 @@
+import { createSlice, PayloadAction } from '@reduxjs/toolkit';
+import { Order } from '../../types/Types';
+
+interface OrdersStateProps {
+ error: any;
+ isLoading: boolean;
+ ordersFetched: boolean;
+ ordersDataList: Order[];
+}
+
+const initialState: OrdersStateProps = {
+ isLoading: true,
+ error: null,
+ ordersFetched: false,
+ ordersDataList: [],
+};
+
+const orderSlice = createSlice({
+ name: 'orders',
+ initialState,
+ reducers: {
+ setOrdersFetched: (state, action: PayloadAction |
---|