Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI Enhancements and Bug Fixes #55

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const PaymentDrawer = () => {
};

return (
<div className='max-w-[700px] flex flex-col p-2 rounded-lg space-y-4 font-poppins'>
<div className='w-[600px] flex flex-col p-2 rounded-lg space-y-4 font-poppins'>
<div className='flex justify-between items-center'>
<div>
<p className='font-semibold'>Order Payment</p>
Expand Down Expand Up @@ -116,7 +116,7 @@ const PaymentDrawer = () => {
Input Amount
</label>
<input
type='text'
type='number'
id='paymentInput'
value={payment}
placeholder='Enter Amount'
Expand All @@ -132,11 +132,11 @@ const PaymentDrawer = () => {
/>
</div>

<PaymentNumberPad onKeyPress={handleKeyPress} />
{/* <PaymentNumberPad onKeyPress={handleKeyPress} /> */}

{/* Three buttons for receipt email and done */}
<div className='flex flex-row justify-evenly items-center'>
<FooterButton
{/* <FooterButton
onClick={footerButtonClick}
icon={<BiReceipt />}
text='Receipt'
Expand All @@ -145,7 +145,7 @@ const PaymentDrawer = () => {
onClick={footerButtonClick}
icon={<AiOutlineMail />}
text='Email'
/>
/> */}
<FooterButton
onClick={footerButtonClick}
icon={<MdOutlineDone />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const ConfirmPaymentPopUp = () => {
className='signup_button w-28 rounded-full'
onClick={confirmClick}
>
Pay
{loading ? 'Wait...' : 'Pay'}
</button>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ type Props = {};

const FirstAidTable = (props: Props) => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [medicine, setMedicine] = useState<IMedicine[]>([]);
const { items, getAllItems } = useItemService();
const {
items,
getAllItems,
medicine,
filteredMedicine,
setFilteredMedicine,
} = useItemService();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -28,19 +33,19 @@ const FirstAidTable = (props: Props) => {
};
console.log(items);

const fetchMedicine = async () => {
const allItems = await getAllItems();
//filter only personal care
const medicine = allItems.filter(
(item: IMedicine) => item.category === 'FirstAid'
);
setMedicine(medicine);
};
// const fetchMedicine = async () => {
// const allItems = await getAllItems();
// //filter only personal care
// const medicine = allItems.filter(
// (item: IMedicine) => item.category === 'FirstAid'
// );
// setMedicine(medicine);
// };

//
useEffect(() => {
//fetchMedicine from server
fetchMedicine();
// getAllItems();
}, []);
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import useItemService from '../../services/ItemService';

const MedicalDeviceTable = () => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [medicine, setMedicine] = useState<IMedicine[]>([]);
const { getAllItems } = useItemService();
const { getAllItems, medicine, filteredMedicine } = useItemService();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -25,18 +24,18 @@ const MedicalDeviceTable = () => {
]);
};

const fetchMedicine = async () => {
const allItems = await getAllItems();
//filter only personal care
const medicine = allItems.filter(
(item: IMedicine) => item.category === 'Medical Devices'
);
setMedicine(medicine);
};
// const fetchMedicine = async () => {
// const allItems = await getAllItems();
// //filter only personal care
// const medicine = allItems.filter(
// (item: IMedicine) => item.category === 'Medical Devices'
// );
// setMedicine(medicine);
// };
//
useEffect(() => {
//fetchMedicine from server
fetchMedicine();
// fetchMedicine();
}, []);
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import useItemService from '../../services/ItemService';

const Medicine = () => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [loading, setLoading] = useState(true);
const { getAllItems } = useItemService();
const {
getAllItems,
medicine,
filteredMedicine,
setFilteredMedicine,
loading,
} = useItemService();

const { setMedicine, medicine, setFilteredMedicine, filteredMedicine } =
usePaymentContext();
// const { setMedicine, medicine, setFilteredMedicine, filteredMedicine } =
// usePaymentContext();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -27,21 +32,9 @@ const Medicine = () => {
]);
};

const fetchMedicine = async () => {
try {
const medicineData = await getAllItems();
setMedicine(medicineData);
setFilteredMedicine(medicineData);
setLoading(false);
} catch (error) {
console.error('Error fetching medicine data:', error);
}
};

//
useEffect(() => {
//fetchMedicine from server
fetchMedicine();
getAllItems();
}, []);
//

Expand Down Expand Up @@ -85,13 +78,17 @@ const Medicine = () => {
</td>
<td className='px-6 py-4'>{cashier.name}</td>
<td className='px-6 py-4'>{cashier.price}</td>
<td className='px-6 py-4'>{cashier.quantity}</td>
<td className='px-6 py-4'>
{cashier.quantity < 0 ? 0 : cashier.quantity}
</td>
<td className='px-6 py-4'>{cashier.status}</td>
<td className='px-6 py-4'>
<CountRoundButton
onClick={() => handleAddClick(cashier)}
icon={<IoIosAdd />}
/>
{cashier.quantity > 0 && (
<CountRoundButton
onClick={() => handleAddClick(cashier)}
icon={<IoIosAdd />}
/>
)}
</td>
</tr>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import useItemService from '../../services/ItemService';

const NutritionTable = () => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [medicine, setMedicine] = useState<IMedicine[]>([]);

const { getAllItems } = useItemService();
const { getAllItems, medicine, filteredMedicine } = useItemService();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -26,19 +25,19 @@ const NutritionTable = () => {
]);
};

const fetchMedicine = async () => {
const allItems = await getAllItems();
//filter only personal care
const medicine = allItems.filter(
(item: IMedicine) => item.category === 'Nutrition'
);
setMedicine(medicine);
};
// const fetchMedicine = async () => {
// const allItems = await getAllItems();
// //filter only personal care
// const medicine = allItems.filter(
// (item: IMedicine) => item.category === 'Nutrition'
// );
// setMedicine(medicine);
// };

//
useEffect(() => {
//fetchMedicine from server
fetchMedicine();
// fetchMedicine();
}, []);
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const MedicineGrid = () => {

const handleAddAmount = (index: number) => {
const updatedMedicines = [...orderedMedicine];
console.log(updatedMedicines);
console.log(filteredMedicine);

if (updatedMedicines[index].availableQuantity > 0) {
updatedMedicines[index].amount += 1;
Expand Down Expand Up @@ -147,7 +149,7 @@ const MedicineGrid = () => {
<tr>
<td className='px-6 py-1'>Total Amount</td>
<td className='px-6 py-1 text-blueDarker font-bold total-amount'>
{totalAmount}
{totalAmount.toFixed(2)}
</td>
</tr>
<tr>
Expand All @@ -167,7 +169,7 @@ const MedicineGrid = () => {
<tr>
<td className='px-6 py-1'>After Discount</td>
<td className='px-6 py-1 text-blueDarker font-bold'>
{discountedTotal}
{discountedTotal.toFixed(2)}
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import useItemService from '../../services/ItemService';

const PersonalCareTable = () => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [medicine, setMedicine] = useState<IMedicine[]>([]);
const { getAllItems } = useItemService();
const { getAllItems, medicine, filteredMedicine } = useItemService();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -25,20 +24,20 @@ const PersonalCareTable = () => {
]);
};

const fetchMedicine = async () => {
const allItems = await getAllItems();
//filter only personal care
const medicine = allItems.filter(
(item: IMedicine) => item.category === 'Personal Care'
);
setMedicine(medicine);
};
// const fetchMedicine = async () => {
// const allItems = await getAllItems();
// //filter only personal care
// const medicine = allItems.filter(
// (item: IMedicine) => item.category === 'Personal Care'
// );
// setMedicine(medicine);
// };

//
useEffect(() => {
//fetchMedicine from server
console.log('fetching medicine');
fetchMedicine();
// console.log('fetching medicine');
// fetchMedicine();
}, []);
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import useItemService from '../../services/ItemService';

const SportsTable = () => {
const { orderedMedicine, setOrderedMedicine } = usePaymentContext();
const [medicine, setMedicine] = useState<IMedicine[]>([]);
const { getAllItems } = useItemService();
const { getAllItems, medicine, filteredMedicine } = useItemService();

//function to add medicine to ordered medicine
const handleAddClick = (medicine: MedicineType) => {
Expand All @@ -25,19 +24,19 @@ const SportsTable = () => {
]);
};

const fetchMedicine = async () => {
const allItems = await getAllItems();
//filter only personal care
const medicine = allItems.filter(
(item: IMedicine) => item.category === 'Sports'
);
setMedicine(medicine);
};
// const fetchMedicine = async () => {
// const allItems = await getAllItems();
// //filter only personal care
// const medicine = allItems.filter(
// (item: IMedicine) => item.category === 'Sports'
// );
// setMedicine(medicine);
// };

//
useEffect(() => {
//fetchMedicine from server
fetchMedicine();
// fetchMedicine();
}, []);
//

Expand Down
Loading
Loading