diff --git a/src/features/branch-sales-summary/layouts/BranchSalesSummary.tsx b/src/features/branch-sales-summary/layouts/BranchSalesSummary.tsx index 1eb0465..0dc3a97 100644 --- a/src/features/branch-sales-summary/layouts/BranchSalesSummary.tsx +++ b/src/features/branch-sales-summary/layouts/BranchSalesSummary.tsx @@ -2,14 +2,14 @@ import React, { useEffect, useState } from 'react'; import useSalesSummary from '../services/SalesSummaryService'; import SalesChart from '../components/SalesChart'; import OrdersChart from '../components/OrdersChart'; -import salesSummary from '../utils/FakeData'; +// import salesSummary from '../utils/FakeData'; import { getToday } from '../utils/getToday'; import { generateMonthlySalesSummary } from '../utils/monthlySalesSummary'; import { exportToExcel, exportToPDF } from '../utils/exportUtils'; import { AiFillFileExcel, AiFillFilePdf } from 'react-icons/ai'; function BranchSalesSummary() { - const { getSalesSummary } = useSalesSummary(); + const { getSalesSummary, salesSummary } = useSalesSummary(); const [startDate, setStartDate] = useState('2023-01-01'); const [endDate, setEndDate] = useState(getToday()); const [filterByMonth, setFilterByMonth] = useState(false); diff --git a/src/features/cashier-management/components/add-cashier/CashierBankDetails.tsx b/src/features/cashier-management/components/add-cashier/CashierBankDetails.tsx index 1de9e5f..c2c7f27 100644 --- a/src/features/cashier-management/components/add-cashier/CashierBankDetails.tsx +++ b/src/features/cashier-management/components/add-cashier/CashierBankDetails.tsx @@ -15,7 +15,7 @@ const CashierBankDetails = () => { employerId: cashierDetails.employerId, monthlyPayment: cashierDetails.employerSalary, }); - }, [cashierBankDetails]); + }, []); const goToSummary = () => { console.log('Summary', cashierDetails); @@ -132,7 +132,7 @@ const CashierBankDetails = () => { onClick={goToSummary} disabled={loading} > - {loading ? 'Loading...' : 'Update'} + {loading ? 'Loading...' : 'Create Bank Details'} diff --git a/src/features/cashier-management/components/add-cashier/CashierDetails.tsx b/src/features/cashier-management/components/add-cashier/CashierDetails.tsx index 9aa63e1..e4b4eb5 100644 --- a/src/features/cashier-management/components/add-cashier/CashierDetails.tsx +++ b/src/features/cashier-management/components/add-cashier/CashierDetails.tsx @@ -126,6 +126,7 @@ const CashierDetails = () => { id='telephone' className='mt-1 p-2 border-gray rounded-md w-64' value={cashierDetails.employerPhone} + accept='tel' onChange={(e) => setCashierDetails({ ...cashierDetails, @@ -265,6 +266,7 @@ const CashierDetails = () => { id='role' className='mt-1 p-2 border-gray rounded-md w-64' value={cashierDetails.role} + placeholder='CASHIER, OTHER' onChange={(e) => setCashierDetails({ ...cashierDetails, @@ -277,12 +279,13 @@ const CashierDetails = () => { htmlFor='baseSalary' className='block text-sm font-medium text-black mt-4' > - Base Salary + Base Salary (LKR) setCashierDetails({ @@ -363,7 +366,7 @@ const CashierDetails = () => { onClick={goToBankDetails} disabled={loading} > - {loading ? 'Loading...' : 'Create'} + {loading ? 'Loading...' : 'Create Employee'} + - -

- Nickname:{' '} - {cashierDetails.employerNicName} -

-

- Phone Number:{' '} - {cashierDetails.employerPhone} -

-

- Address:{' '} - {cashierDetails.employerAddress} -

-

- Date of Birth:{' '} - {cashierDetails.dateOfBirth.toString().slice(0, 10)} -

-
-

Employment Details

-

- Role: {cashierDetails.role} -

-

- Assign Branch:{' '} - {cashierDetails.branchId} -

-

- Base Salary:{' '} - {cashierDetails.employerSalary} -

-

- Pin: {cashierDetails.pin} -

-

- Bank Account Number:{' '} - {cashierBankDetails.bankAccountNumber} -

-

- Bank Name:{' '} - {cashierBankDetails.bankName} -

-

- Branch Name:{' '} - {cashierBankDetails.bankBranchName} -

-

- Additional Notes:{' '} - {cashierBankDetails.employerDescription} -

+ + {/* Personal Information Section */} + +
+

Employment Information

+ + + + + + + + + + + + + + +
- - + + {/* Buttons */}
); } diff --git a/src/features/cashier-management/components/update-cashier/UpdateCashierSummary.tsx b/src/features/cashier-management/components/update-cashier/UpdateCashierSummary.tsx index fef2394..dd26646 100644 --- a/src/features/cashier-management/components/update-cashier/UpdateCashierSummary.tsx +++ b/src/features/cashier-management/components/update-cashier/UpdateCashierSummary.tsx @@ -4,6 +4,7 @@ import useBankCRUDService from '../../services/BankDetailsCRUDService'; import useCashierCRUDService from '../../services/CashierCRUDService'; import { useEffect } from 'react'; import { toast } from 'react-toastify'; +import TableRow from '../../../../shared/table_row/TableRow'; const UpdateCashierSummary = () => { const { setCurrentComponent } = useCashierContext(); @@ -16,8 +17,12 @@ const UpdateCashierSummary = () => { // // const { cashierBankDetails, fetchBankDetailsById } = useBankCRUDService(); - const { cashierDetails, fetchCashierById, fetchImageOfEmployer,profileImageUrl } = - useCashierCRUDService(); + const { + cashierDetails, + fetchCashierById, + fetchImageOfEmployer, + profileImageUrl, + } = useCashierCRUDService(); useEffect(() => { if (employerId) { @@ -30,94 +35,100 @@ const UpdateCashierSummary = () => { }, []); return ( -
-
-

Personal Information

+
+ {/* Image Section */} +
Profile -

- Name:{' '} - {cashierDetails.employerFirstName} {cashierDetails.employerLastName} -

-

- Nickname:{' '} - {cashierDetails.employerNicName} -

-

- Email:{' '} - {cashierDetails.employerEmail} -

-

- Phone Number:{' '} - {cashierDetails.employerPhone} -

-

- Address:{' '} - {cashierDetails.employerAddress} -

-

- Date of Birth:{' '} - {cashierDetails.dateOfBirth?.slice(0, 10)} -

-
-
-

Employment Details

-

- Role: {cashierDetails.role} -

-

- Assign Branch:{' '} - {cashierDetails.branchId} -

-

- Base Salary:{' '} - {cashierDetails.employerSalary} + src={ + profileImageUrl || + 'https://static-00.iconduck.com/assets.00/person-icon-1901x2048-a9h70k71.png' + } + alt='Profile' + className='w-64 h-64 rounded-full' + /> +

+ Employee {cashierDetails.employerFirstName}

+
+ {/* Employment Details Section */} +

Bank Details

+ + + + + -

- Bank Account Number:{' '} - {cashierBankDetails.bankAccountNumber} -

-

- Bank Name:{' '} - {cashierBankDetails.bankName} -

-

- Branch Name:{' '} - {cashierBankDetails.bankBranchName} -

+ + +
+
+
+
+ + +
+
-

- Additional Notes:{' '} - {cashierBankDetails.employerDescription} -

+ {/* Personal Information Section */} -

- Monthly Payment:{' '} - {cashierBankDetails.monthlyPayment} -

+
+

Employment Information

+ + + + + + + + + + + + + + +
- - + + {/* Buttons */}
); }; diff --git a/src/features/cashier-management/services/CashierCRUDService.tsx b/src/features/cashier-management/services/CashierCRUDService.tsx index 4dc53f5..c099d10 100644 --- a/src/features/cashier-management/services/CashierCRUDService.tsx +++ b/src/features/cashier-management/services/CashierCRUDService.tsx @@ -99,7 +99,6 @@ const useCashierCRUDService = () => { const createCashier = async (employer: CashierDetailsType) => { if ( !employer || - !employer.branchId || !employer.employerNicName || !employer.employerFirstName || !employer.employerLastName || diff --git a/src/features/login/components/EulaComponent.tsx b/src/features/login/components/EulaComponent.tsx new file mode 100644 index 0000000..7b02e28 --- /dev/null +++ b/src/features/login/components/EulaComponent.tsx @@ -0,0 +1,128 @@ +import React from 'react'; + +type Props = { + OnClose: () => void; +}; + +const EulaComponent: React.FC = ({ OnClose }: Props) => { + return ( +
+
+
+

+ End User License Agreement (EULA) +

+

+ This End User License Agreement ("Agreement") governs your use of + the LifePill software application ("Application") provided by + LifePill ("Company"). By using the Application, you agree to be + bound by the terms of this Agreement. +

+

License Grant

+

+ Subject to the terms of this Agreement, Company grants you a + limited, non-exclusive, non-transferable license to use the + Application solely for your personal, non-commercial purposes. +

+

Restrictions

+

+ You may not: +

    +
  • + Modify, adapt, translate, reverse engineer, decompile, or + disassemble the Application. +
  • +
  • + Attempt to bypass, modify, or tamper with any security features + or measures of the Application. +
  • +
  • + Use the Application in any manner that violates applicable laws + or regulations. +
  • +
+

+

Ownership

+

+ Company retains all rights, title, and interest in and to the + Application, including all intellectual property rights. +

+

Privacy Policy

+

+ Your use of the Application is also governed by our Privacy Policy, + available{' '} + + here + + . By using the Application, you consent to the collection and use of + your information as described in the Privacy Policy. +

+

Termination

+

+ This Agreement is effective until terminated by you or Company. + Company may terminate this Agreement at any time without notice if + you fail to comply with any term of this Agreement. Upon + termination, you must cease all use of the Application. +

+

+ Disclaimer of Warranties +

+

+ THE APPLICATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. TO + THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, COMPANY DISCLAIMS + ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING + BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +

+

+ Limitation of Liability +

+

+ IN NO EVENT SHALL COMPANY BE LIABLE FOR ANY INCIDENTAL, SPECIAL, + INDIRECT, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO THE + USE OR INABILITY TO USE THE APPLICATION, WHETHER BASED ON WARRANTY, + CONTRACT, TORT (INCLUDING NEGLIGENCE), OR ANY OTHER LEGAL THEORY, + EVEN IF COMPANY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +

+

Governing Law

+

+ This Agreement shall be governed by and construed in accordance with + the laws of [Your Jurisdiction], without regard to its conflict of + law principles. +

+

+ Changes to this Agreement +

+

+ Company reserves the right to modify this Agreement at any time. Any + changes will be effective immediately upon posting of the revised + Agreement. Your continued use of the Application after the posting + of the revised Agreement constitutes your acceptance of the changes. +

+

Contact Us

+ +

+ If you have any questions about this Agreement, please contact us at{' '} + + LifePillinfo@gmail.com + + . +

+ +
+ + {/* Close button */} +
+
+ ); +}; + +export default EulaComponent; diff --git a/src/features/login/components/LogInCard.tsx b/src/features/login/components/LogInCard.tsx index af51e15..3b3a166 100644 --- a/src/features/login/components/LogInCard.tsx +++ b/src/features/login/components/LogInCard.tsx @@ -6,15 +6,21 @@ import Logo from '../../../assets/logo/logo.png'; import { useNavigate } from 'react-router-dom'; import useSignIn from '../services/AuthService'; import { useUserContext } from '../../../context/UserContext'; +import EulaComponent from './EulaComponent'; +import { Loader } from 'lucide-react'; const LogInCard = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const { setUser } = useUserContext(); + const [showEula, setShowEula] = useState(false); + const handleShowEula = () => { + setShowEula(!showEula); + }; const navigate = useNavigate(); - const { signIn } = useSignIn(); + const { signIn, loading } = useSignIn(); const handleSignIn = async () => { const user = await signIn(username, password); @@ -82,17 +88,27 @@ const LogInCard = () => {
-

Forgot Password?

+

+ Forgot Password? +

{/* Buttons */}
{/* User agreement bar */} -

End User Agreement

+

+ End User Agreement +

+ + {showEula && } ); }; diff --git a/src/features/login/services/useAxiosInstance.tsx b/src/features/login/services/useAxiosInstance.tsx index 00b603c..4818b3f 100644 --- a/src/features/login/services/useAxiosInstance.tsx +++ b/src/features/login/services/useAxiosInstance.tsx @@ -5,7 +5,7 @@ import { useEffect } from 'react'; const useAxiosInstance = () => { const instance = axios.create({ // baseURL: 'http://localhost:8079/lifepill/v1', - baseURL: 'https://3.82.134.54:8079/lifepill/v1', + baseURL: 'http://localhost:8079/lifepill/v1', headers: { 'Content-type': 'application/json', }, diff --git a/src/features/main-manager-dashboard/components/BranchDetailsCard.tsx b/src/features/main-manager-dashboard/components/BranchDetailsCard.tsx new file mode 100644 index 0000000..e6cfd2f --- /dev/null +++ b/src/features/main-manager-dashboard/components/BranchDetailsCard.tsx @@ -0,0 +1,73 @@ +import React from 'react'; +import UseBranchService from '../../manager-dashboard/services/BranchService'; +import { IBranchData } from '../../manager-dashboard/interfaces/IBranchData'; +import TableRow from '../../../shared/table_row/TableRow'; + +type Props = { + branchData: IBranchData; +}; + +function BranchDetailsCard({ branchData }: Props) { + return ( +
+
+

Branch Data

+
+
+ + + + + + + + + + + + + + + + + +
+
+
+ ); +} + +export default BranchDetailsCard; diff --git a/src/features/main-manager-dashboard/components/SummaryCard.tsx b/src/features/main-manager-dashboard/components/SummaryCard.tsx index 47e643d..ffe1998 100644 --- a/src/features/main-manager-dashboard/components/SummaryCard.tsx +++ b/src/features/main-manager-dashboard/components/SummaryCard.tsx @@ -6,14 +6,13 @@ import { GiFactory, } from 'react-icons/gi'; import useBranchService from '../../manager-dashboard/services/BranchService'; +import { IBranchData } from '../../manager-dashboard/interfaces/IBranchData'; -function SummaryCard() { - const { fetchBranchData, branchData } = useBranchService(); - - useEffect(() => { - fetchBranchData(); - }, []); +type Props = { + branchData: IBranchData; +}; +function SummaryCard({ branchData }: Props) { return (
{/* Total Sales Card */} @@ -24,7 +23,9 @@ function SummaryCard() {

Total Amount:

-

{`LKR ${branchData?.sales}`}

+

{`LKR ${branchData?.sales.toFixed( + 2 + )}`}

@@ -51,7 +52,7 @@ function SummaryCard() {

Number of Workers:

- {branchData?.manager} + {branchData?.branchDTO.branchId}

diff --git a/src/features/main-manager-dashboard/layout/MainManagerDashboard.tsx b/src/features/main-manager-dashboard/layout/MainManagerDashboard.tsx index b94d8f2..3f554bd 100644 --- a/src/features/main-manager-dashboard/layout/MainManagerDashboard.tsx +++ b/src/features/main-manager-dashboard/layout/MainManagerDashboard.tsx @@ -1,25 +1,37 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import CashierRecentTransactionCard from '../components/CashierRecentTransactionCard'; import LatestTransactionDetails from '../components/LatestTransactionDetails'; import SummaryCard from '../components/SummaryCard'; +import BranchDetailsCard from '../components/BranchDetailsCard'; +import UseBranchService from '../../manager-dashboard/services/BranchService'; function MainManagerDashboard() { + const { fetchBranchData, branchData } = UseBranchService(); + + useEffect(() => { + fetchBranchData(); + }, []); + return (
-
- -
-
-
- -
-
- -
-
+ {branchData && ( + <> +
+ +
+
+
+ +
+
+ +
+
+ + )}
); } diff --git a/src/features/manager-dashboard/components/sidebar/ManagerSidebar.tsx b/src/features/manager-dashboard/components/sidebar/ManagerSidebar.tsx index f0d0211..946070d 100644 --- a/src/features/manager-dashboard/components/sidebar/ManagerSidebar.tsx +++ b/src/features/manager-dashboard/components/sidebar/ManagerSidebar.tsx @@ -17,7 +17,7 @@ const ManagerSidebar = ({ onItemClick }: Props) => { const { logOut, logging } = useAuthService(); return (
{ testid='orders' /> {/* Logout Button */} -
+
} // Use the logout icon text={logging ? 'Logging Out' : 'LogOut'} diff --git a/src/features/manager-dashboard/services/AuthService.tsx b/src/features/manager-dashboard/services/AuthService.tsx index b33f146..cbb2227 100644 --- a/src/features/manager-dashboard/services/AuthService.tsx +++ b/src/features/manager-dashboard/services/AuthService.tsx @@ -11,27 +11,26 @@ const useAuthService = () => { const [logging, setLogging] = useState(); const logOut = async () => { - // Prompt for confirmation before logging out - const confirmed = window.confirm('Are you sure you want to log out?'); - if (!confirmed) return; // If user cancels logout, do nothing + const confirm = window.confirm('Are you sure log out ?'); - try { - setLogging(true); - console.log(user); - const res = await http.post('session/logout/permanent', { - user: user.user?.employerEmail, - }); + if (confirm) { + try { + setLogging(true); + const res = await http.post('/session/logout/permanent', { + username: user.user?.employerEmail, + }); - if (res.status === 200) { - toast.success('Successfully logged out'); - navigate('/'); - // Remove user data from local storage - localStorage.removeItem('user'); + if (res.status === 200) { + toast.success('Logged out successfully'); + navigate('/'); + // Remove user data from local storage + localStorage.removeItem('user'); + } + } catch (error) { + console.log(error); + } finally { + setLogging(false); } - } catch (error) { - console.log(error); - } finally { - setLogging(false); } }; diff --git a/src/shared/table_row/TableRow.tsx b/src/shared/table_row/TableRow.tsx new file mode 100644 index 0000000..2a01502 --- /dev/null +++ b/src/shared/table_row/TableRow.tsx @@ -0,0 +1,19 @@ +interface TableRowProps { + label: string; + value: string | number | boolean; +} + +const TableRow: React.FC = ({ label, value }) => { + return ( + + + {label} + + + {value} + + + ); +}; + +export default TableRow;