|
1 | 1 | import dayjs from "dayjs"; |
2 | 2 | import { flow, keyBy, map, mapValues, sum } from "lodash"; |
3 | | -import React, { useCallback, useContext, useState } from "react"; |
| 3 | +import React, { useContext, useState } from "react"; |
4 | 4 |
|
5 | 5 | import { RenterApproval } from "src/apiClient/approvals"; |
6 | 6 | import { GearSummary } from "src/apiClient/gear"; |
@@ -72,31 +72,28 @@ function useMakePersonPageContext({ person, refreshPerson, approvals }: Props) { |
72 | 72 | return startDate.isSameOrBefore(today) && endDate.isSameOrAfter(today); |
73 | 73 | }); |
74 | 74 |
|
75 | | - const isApproved = useCallback( |
76 | | - (gearId: string, typeId: number) => { |
77 | | - return activeApprovals.some(({ items }) => { |
78 | | - return items.some((item) => { |
79 | | - if (item.type === "specificItem") { |
80 | | - return item.item.gearItem.id === gearId; |
81 | | - } |
82 | | - if (item.item.gearType.id !== typeId) { |
83 | | - return false; |
84 | | - } |
85 | | - const checkedOut = checkoutBasketBase.items.filter( |
86 | | - ({ type }) => type.id === item.item.gearType.id, |
87 | | - ); |
88 | | - if (checkedOut.length < item.item.quantity) { |
89 | | - return true; |
90 | | - } |
91 | | - return checkedOut |
92 | | - .slice(0, item.item.quantity) |
93 | | - .map((g) => g.id) |
94 | | - .includes(gearId); |
95 | | - }); |
| 75 | + const isApproved = (gearId: string, typeId: number) => { |
| 76 | + return activeApprovals.some(({ items }) => { |
| 77 | + return items.some((item) => { |
| 78 | + if (item.type === "specificItem") { |
| 79 | + return item.item.gearItem.id === gearId; |
| 80 | + } |
| 81 | + if (item.item.gearType.id !== typeId) { |
| 82 | + return false; |
| 83 | + } |
| 84 | + const checkedOut = checkoutBasketBase.items.filter( |
| 85 | + ({ type }) => type.id === item.item.gearType.id, |
| 86 | + ); |
| 87 | + if (checkedOut.length < item.item.quantity) { |
| 88 | + return true; |
| 89 | + } |
| 90 | + return checkedOut |
| 91 | + .slice(0, item.item.quantity) |
| 92 | + .map((g) => g.id) |
| 93 | + .includes(gearId); |
96 | 94 | }); |
97 | | - }, |
98 | | - [activeApprovals], |
99 | | - ); |
| 95 | + }); |
| 96 | + }; |
100 | 97 |
|
101 | 98 | const calculatedTotalRentals = sum( |
102 | 99 | map(rentalsWithOverride, (item) => { |
|
0 commit comments