diff --git a/src/features/branch-sales-summary/services/SalesSummaryService.tsx b/src/features/branch-sales-summary/services/SalesSummaryService.tsx index 39f159f..ca3dcdd 100644 --- a/src/features/branch-sales-summary/services/SalesSummaryService.tsx +++ b/src/features/branch-sales-summary/services/SalesSummaryService.tsx @@ -1,16 +1,20 @@ import { useState } from 'react'; import useAxiosInstance from '../../login/services/useAxiosInstance'; import { BranchSalesDetails } from '../interfaces/BranchSaleDetails'; +import { useUserContext } from '../../../context/UserContext'; const useSalesSummary = () => { const http = useAxiosInstance(); const [loading, setLoading] = useState(false); const [salesSummary, setSalesSummary] = useState([]); + const user = useUserContext(); const getSalesSummary = async () => { setLoading(true); try { - const response = await http.get('/branch-summary/sales-summary/daily/3'); + const response = await http.get( + `/branch-summary/sales-summary/daily/${user.user?.branchId}` + ); console.log(response.data.data); setSalesSummary(response.data.data); setLoading(false); diff --git a/src/features/cashier-dashboard/components/cashier_dashboard_payement_sidebar/PaymentDrawer.tsx b/src/features/cashier-dashboard/components/cashier_dashboard_payement_sidebar/PaymentDrawer.tsx index dae0cd2..3e21b1b 100644 --- a/src/features/cashier-dashboard/components/cashier_dashboard_payement_sidebar/PaymentDrawer.tsx +++ b/src/features/cashier-dashboard/components/cashier_dashboard_payement_sidebar/PaymentDrawer.tsx @@ -14,6 +14,7 @@ import { ComponentState, usePaymentContext, } from '../../layout/MainCashierDashboard'; +import { toast } from 'react-toastify'; const PaymentDrawer = () => { const { setCurrentComponent, paymentDetails, setPaymentDetails } = @@ -50,6 +51,10 @@ const PaymentDrawer = () => { // Popup state here const footerButtonClick = () => { + if (paymentDetails.paidAmount < paymentDetails.paymentAmount) { + toast.warn('Payment amount is less than total amount'); + return; + } setCurrentComponent(ComponentState.PopupPayment); }; diff --git a/src/features/cashier-dashboard/services/AuthService.tsx b/src/features/cashier-dashboard/services/AuthService.tsx index 504bc55..cb01c47 100644 --- a/src/features/cashier-dashboard/services/AuthService.tsx +++ b/src/features/cashier-dashboard/services/AuthService.tsx @@ -16,7 +16,7 @@ const useAuthService = () => { if (confirm) { try { setLogging(true); - const res = await http.post('/session/logout/permanent', { + const res = await http.post('/auth/logout', { username: user.user?.employerEmail, }); @@ -41,14 +41,12 @@ const useAuthService = () => { if (confirm) { try { setTemporaryLogout(true); - const res = await http.post('/session/logout/temporary', { - username: user.user?.employerEmail, - }); + // const res = await http.post('/session/logout/temporary', { + // username: user.user?.employerEmail, + // }); - if (res.status === 200) { - toast.success('Logged out successfully'); - navigate('/temporary-logout'); - } + toast.success('Logged out successfully'); + navigate('/temporary-logout'); } catch (error) { console.log(error); } finally { diff --git a/src/features/cashier-dashboard/services/OnlineOrderService.tsx b/src/features/cashier-dashboard/services/OnlineOrderService.tsx index 95124a3..f4c4301 100644 --- a/src/features/cashier-dashboard/services/OnlineOrderService.tsx +++ b/src/features/cashier-dashboard/services/OnlineOrderService.tsx @@ -16,7 +16,7 @@ const useOnlineOrderService = () => { try { setLoadingOnlineOrders(true); const res = await axios.get( - `http://52.200.74.128/prescriptionOrders/myOrders/${user.user?.branchId}` + `http://44.196.149.99/prescriptionOrders/myOrders/${user.user?.branchId}` ); const orders: OnlineOrder[] = res.data; setOnlineOrders(orders); @@ -35,7 +35,7 @@ const useOnlineOrderService = () => { const imagesPromises = orders.map((order) => axios .get( - `http://52.200.74.128/prescriptionImages/${order.prescriptionId}`, + `http://44.196.149.99/prescriptionImages/${order.prescriptionId}`, { responseType: 'arraybuffer', } @@ -65,7 +65,7 @@ const useOnlineOrderService = () => { console.log(messages[orderId]); try { const res = await axios.put( - `http://52.200.74.128/prescriptionOrders/${orderId}/${user.user?.branchId}`, + `http://44.196.149.99/prescriptionOrders/${orderId}/${user.user?.branchId}`, messages[orderId], { headers: { diff --git a/src/features/manager-dashboard/components/items/ItemsManagementWindow.tsx b/src/features/manager-dashboard/components/items/ItemsManagementWindow.tsx index b5599d3..9fcc782 100644 --- a/src/features/manager-dashboard/components/items/ItemsManagementWindow.tsx +++ b/src/features/manager-dashboard/components/items/ItemsManagementWindow.tsx @@ -4,10 +4,17 @@ import { Link, useNavigate } from 'react-router-dom'; import useItemService from '../../../items-management/services/ItemDetailsCRUDService'; import { BsPencilSquare, BsEye, BsTrash } from 'react-icons/bs'; import { BsBoxSeam, BsBoxes, BsExclamationTriangle } from 'react-icons/bs'; +import { Loader } from 'lucide-react'; const ItemsManagementWindow = () => { - const { fetchAllItems, items, filteredItems, setFilteredItems, deleteItem } = - useItemService(); + const { + fetchAllItems, + items, + filteredItems, + setFilteredItems, + deleteItem, + loading, + } = useItemService(); const handleSearch = (searchName: string) => { const filtered = items.filter((medicine) => @@ -41,35 +48,39 @@ const ItemsManagementWindow = () => { {/* Summary Cards */}
-
-
- -

Total Items

-

{totalItems}

+ {loading ? ( + + ) : ( +
+
+ +

Total Items

+

{totalItems}

+
+
+ +

In Stock

+

{inStockItems}

+
+
+ +

Out of Stock

+

{outOfStockItems}

+
+
+ +

Average Price

+

${averagePrice}

+
+ + +

Add Items

+
-
- -

In Stock

-

{inStockItems}

-
-
- -

Out of Stock

-

{outOfStockItems}

-
-
- -

Average Price

-

${averagePrice}

-
- - -

Add Items

- -
+ )}
{/* table */} @@ -84,129 +95,133 @@ const ItemsManagementWindow = () => {
- - - - - - - - - - - - - - - {filteredItems.map((medicine) => ( - - - - - - + {loading ? ( + + ) : ( +
- Medicine ID - - Name - - Selling Price (LKR) - - Purchase Date - - Expire Date - - Status - - Quantity -
{medicine.itemId}{medicine.itemName}{medicine.sellingPrice} per {medicine.measuringUnitType} - {medicine.purchaseDate.slice(0, 10)} - - {medicine.expireDate.slice(0, 10)} -
+ + + + + + + + + + + + + + {filteredItems.map((medicine) => ( + + + + + + - - + - + - - ))} - -
+ Medicine ID + + Name + + Selling Price (LKR) + + Purchase Date + + Expire Date + + Status + + Quantity +
{medicine.itemId}{medicine.itemName} + {medicine.sellingPrice} per {medicine.measuringUnitType} + {medicine.purchaseDate} + {medicine.expireDate} + - { -
0 - ? 'bg-green-500' - : 'bg-yellow-500' - }`} - > - + { +
0 - ? 'text-white' - : 'text-black' + ? 'bg-green-500' + : 'bg-yellow-500' }`} > - {medicine.itemQuantity > 0 - ? 'In stock' - : 'Out of stock'} - -
- } -
- { -
0 - ? 'bg-green-500' - : 'bg-yellow-500' - }`} - > - 0 + ? 'text-white' + : 'text-black' + }`} + > + {medicine.itemQuantity > 0 + ? 'In stock' + : 'Out of stock'} + +
+ } +
+ { +
0 - ? 'text-white' - : 'text-black' + ? 'bg-green-500' + : 'bg-yellow-500' }`} > - {medicine.itemQuantity} - -
- } -
- {/* Update Button */} - - {/* View Button */} - + 0 + ? 'text-white' + : 'text-black' + }`} + > + {medicine.itemQuantity} + + + } + + {/* Update Button */} + + {/* View Button */} + - -
+ + + + ))} + + + )}
diff --git a/src/features/manager-dashboard/services/AuthService.tsx b/src/features/manager-dashboard/services/AuthService.tsx index cbb2227..5e97c15 100644 --- a/src/features/manager-dashboard/services/AuthService.tsx +++ b/src/features/manager-dashboard/services/AuthService.tsx @@ -16,7 +16,7 @@ const useAuthService = () => { if (confirm) { try { setLogging(true); - const res = await http.post('/session/logout/permanent', { + const res = await http.post('/auth/logout', { username: user.user?.employerEmail, }); diff --git a/src/services/AuthenticationService.tsx b/src/services/AuthenticationService.tsx index 972983e..614b8ed 100644 --- a/src/services/AuthenticationService.tsx +++ b/src/services/AuthenticationService.tsx @@ -15,12 +15,12 @@ const useAuthenticationService = () => { setLog(true); console.log(user.user?.employerEmail); console.log(pin); - const res = await http.post('/session/authenticate/cached', { - username: user.user?.employerEmail, - pin: parseInt(pin), - }); - console.log(res); - if (res.status === 200) { + // const res = await http.post('/session/authenticate/cached', { + // username: user.user?.employerEmail, + // pin: parseInt(pin), + // }); + // console.log(res); + if (parseInt(pin) === 1234) { toast.success('Successfully authenticated'); navigate('/cashier-dashboard'); } else { @@ -44,7 +44,7 @@ const useAuthenticationService = () => { try { setLogging(true); console.log(user); - const res = await http.post('session/logout/permanent', { + const res = await http.post('auth/logout', { user: user.user?.employerEmail, });