Skip to content

Commit

Permalink
Make the contract filter url backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
mestachs committed Nov 13, 2023
1 parent 48568d6 commit a391543
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/contracts/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ export const activeAtFilter = {
if (!value) {
return contracts;
}
let cleanedValue = value
// previously was a date picker with a date formatter dd/mm/YYYY
/// so we need to turn it into a YYYYmm period
if (value.includes("/")) {
cleanedValue = value.split("/").slice(1).reverse().join("")
debugger
}
const filteredContracts = contracts.filter((c) => {
return c.matchPeriod(value)
return c.matchPeriod(cleanedValue)
});
return filteredContracts;
},
Expand Down
8 changes: 7 additions & 1 deletion src/components/shared/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,17 @@ const Filter = ({ filter, setFilterValue, onSearch, t }) => {
}

case "monthlyPeriod": {
let cleanedValue = filter.value;
// previously was a date picker with a date formatter dd/mm/YYYY
/// so we need to turn it into a YYYYmm period
if (cleanedValue && cleanedValue.includes("/")) {
cleanedValue = filter.value.split("/").slice(1).reverse().join("");
}
return (
<div style={{ marginTop: "5px" }}>
<PeriodPicker
fieldName={t(filter.key)}
currentPeriod={filter.value}
currentPeriod={cleanedValue}
mode="active"
onPeriodChange={(p) => setFilterValue(filter.id, p)}
></PeriodPicker>
Expand Down

0 comments on commit a391543

Please sign in to comment.