Skip to content

Commit

Permalink
fix: wrong date range in payslip display modal
Browse files Browse the repository at this point in the history
  • Loading branch information
BigSillyTiger committed Apr 18, 2024
1 parent 8efcb0a commit a331a1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
19 changes: 5 additions & 14 deletions src/components/table/tableBtn/PSDisplayBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Tbonus, Tpayslip } from "@/configs/schema/payslipSchema";
import { useAtom } from "jotai";
import { atModalOpen, atStaff } from "@/configs/atoms";
import { auToISO, checkDateRange } from "@/lib/time";
import { auToISO } from "@/lib/time";
import { mOpenOps } from "@/configs/utils/modal";
import { DocumentIcon } from "@heroicons/react/24/outline";

Expand All @@ -33,17 +33,8 @@ const PSDisplayBtn: FC<Tprops> = ({ payslip, name }) => {
const staff = allStaff.find((staff) => staff.uid === payslip.fk_uid)!;

const newStaffWL = useMemo(() => {
return allStaffWL.filter(
(s) =>
s.fk_uid === staff.uid &&
(s.wl_status === "unpaid" || s.wl_status === "completed") &&
checkDateRange(
new Date(payslip.s_date),
new Date(payslip.e_date),
new Date(auToISO(s.wl_date))
)
);
}, [staff.uid, payslip.s_date, payslip.e_date, allStaffWL]);
return allStaffWL.filter((wl) => wl.fk_psid === payslip.psid);
}, [allStaffWL, payslip.psid]);

const newDeduct = useMemo(() => {
return newStaffWL
Expand Down Expand Up @@ -79,8 +70,8 @@ const PSDisplayBtn: FC<Tprops> = ({ payslip, name }) => {
newDeduct && newDeduct.length && setDeduction(newDeduct);
newBonus && newBonus.length && setAllBonus(newBonus);
setDayRange({
from: new Date(payslip.s_date),
to: new Date(payslip.e_date),
from: new Date(auToISO(payslip.s_date)),
to: new Date(auToISO(payslip.e_date)),
});
//
setModalOpen(mOpenOps.display);
Expand Down
1 change: 1 addition & 0 deletions src/configs/i18n/scriptEn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ const en = {
openHeadBarMenu: "Open head bar menu",
closeSideBar: "Close sidebar",
closeModal: "Close modal",
viewNotifications: "View notifications",
},
},
};
Expand Down
4 changes: 3 additions & 1 deletion src/pageComponents/headBar/headBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const HeadBar: FC<Tprops> = ({ setOpen }) => {
type="button"
className="-m-2.5 p-2.5 text-gray-400 hover:text-gray-500"
>
<span className="sr-only">View notifications</span>
<span className="sr-only">
{t("sr.viewNotifications")}
</span>
<BellIcon className="h-6 w-6" aria-hidden="true" />
</button>

Expand Down

0 comments on commit a331a1b

Please sign in to comment.