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

Datepicker min max fix #1325

Merged
merged 3 commits into from
Nov 6, 2023
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
@@ -1,5 +1,14 @@
# @navikt/ekstra-omsorgsdager-andre-forelder-ikke-tilsyn

## 1.17.13

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 1.17.12

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Søknad om ekstra omsorgsdager når den andre forelderen ikke kan ha tilsyn med barn",
"license": "MIT",
"name": "@navikt/ekstra-omsorgsdager-andre-forelder-ikke-tilsyn",
"version": "1.17.12",
"version": "1.17.13",
"repository": "https://github.com/navikt/sif-brukerdialog",
"private": true,
"type": "module",
Expand Down
10 changes: 10 additions & 0 deletions apps/endringsmelding-pleiepenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 2.20.13

### Patch Changes

- cb7e6653: Oppdatere ds pakker etter at versjon 5.9.1 hadde feil. Fikset i v. 5.9.2
- Updated dependencies [5c44f78b]
- Updated dependencies [5c44f78b]
Expand Down
2 changes: 1 addition & 1 deletion apps/endringsmelding-pleiepenger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"name": "@navikt/endringsmelding-pleiepenger",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "2.20.12",
"version": "2.20.13",
"private": true,
"dependencies": {
"@formatjs/intl-pluralrules": "5.2.7",
Expand Down
10 changes: 10 additions & 0 deletions apps/omsorgsdager-aleneomsorg-dialog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @navikt/omsorgsdager-aleneomsorg-dialog

## 2.10.13

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 2.10.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/omsorgsdager-aleneomsorg-dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/omsorgsdager-aleneomsorg-dialog",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "2.10.12",
"version": "2.10.13",
"private": true,
"type": "module",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions apps/omsorgspengerutbetaling-soknad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @navikt/omsorgspengerutbetaling-soknad

## 1.3.14

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 1.3.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/omsorgspengerutbetaling-soknad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/omsorgspengerutbetaling-soknad",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "1.3.13",
"version": "1.3.14",
"private": true,
"type": "module",
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions apps/omsorgspengesoknad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @navikt/omsorgspengesoknad

## 1.19.13

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 1.19.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/omsorgspengesoknad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/omsorgspengesoknad",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "1.19.12",
"version": "1.19.13",
"private": true,
"type": "module",
"dependencies": {
Expand Down
11 changes: 11 additions & 0 deletions apps/pleiepenger-i-livets-sluttfase-soknad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @navikt/pleiepenger-i-livets-sluttfase-soknad

## 1.0.13

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 1.0.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/pleiepenger-i-livets-sluttfase-soknad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/pleiepenger-i-livets-sluttfase-soknad",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "1.0.12",
"version": "1.0.13",
"private": true,
"type": "module",
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions apps/pleiepenger-sykt-barn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @navikt/pleiepenger-sykt-barn

## 3.1.2

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 3.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/pleiepenger-sykt-barn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/pleiepenger-sykt-barn",
"repository": "https://github.com/navikt/sif-brukerdialog",
"version": "3.1.1",
"version": "3.1.2",
"private": true,
"type": "module",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions apps/sif-ettersending/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @navikt/sif-ettersending

## 3.23.11

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]
- @navikt/[email protected]

## 3.23.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/sif-ettersending/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"name": "@navikt/sif-ettersending",
"repository": "https://github.com/navikt/sif-ettersending",
"version": "3.23.10",
"version": "3.23.11",
"private": true,
"type": "module",
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/sif-common-formik-ds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @navikt/sif-common-formik-ds

## 1.1.5

### Patch Changes

- 1d7c508f: Feilfiks når maks og min dato er på samme dag. Da ble undefined returnert, noe som igjen førte til at dropdownCaption ikke virket som forventet. Nå returneres alltid en min eller maks dato dersom dette er satt.

## 1.1.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/sif-common-formik-ds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"name": "@navikt/sif-common-formik-ds",
"types": "lib/index.d.js",
"version": "1.1.4",
"version": "1.1.5",
"bugs": {
"url": "https://github.com/navikt/sif-common-formik-ds/issues"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ export const getRangesEndingBeforeDate = (date: Date, dateRanges: DateRange[] =
};

export const findClosestDateAfterDate = (fromDate: Date, dates: Date[]): Date | undefined => {
const dayjss = dates.map((d) => dayjs(d)).filter((m) => m.isAfter(fromDate, 'day'));
return dayjss.length > 0 ? dayjs.min(dayjss)!.toDate() : undefined;
const days = dates.map((d) => dayjs(d)).filter((m) => m.isAfter(fromDate, 'day'));
return days.length > 0 ? dayjs.min(days)!.toDate() : undefined;
};

export const findClosestDateBeforeDate = (fromDate: Date, dates: Date[]): Date | undefined => {
const dayjss = dates.map((d) => dayjs(d)).filter((m) => m.isBefore(fromDate, 'day'));
const maxDate = dayjss.length > 0 ? dayjs.max(dayjss)!.toDate() : undefined;
const days = dates.map((d) => dayjs(d)).filter((m) => m.isBefore(fromDate, 'day'));
const maxDate = days.length > 0 ? dayjs.max(days)!.toDate() : undefined;
return maxDate;
};

export const findClosestDateBeforeOrEqualDate = (fromDate: Date, dates: Date[]): Date | undefined => {
const dayjss = dates.map((d) => dayjs(d)).filter((m) => m.isSameOrBefore(fromDate, 'day'));
const maxDate = dayjss.length > 0 ? dayjs.max(dayjss)!.toDate() : undefined;
const days = dates.map((d) => dayjs(d)).filter((m) => m.isSameOrBefore(fromDate, 'day'));
const maxDate = days.length > 0 ? dayjs.max(days)!.toDate() : undefined;
return maxDate;
};

Expand Down Expand Up @@ -82,13 +82,13 @@ export const getMaxDateForRangeStart = ({
return toDate || maxDate;
}
const follwingDateRange = getClosestDateRangeAfterDate(fromDate, dateRanges);
const followingRangeeDate = getFollowingDate(follwingDateRange, allowRangesToStartAndStopOnSameDate);
const followingRangeDate = getFollowingDate(follwingDateRange, allowRangesToStartAndStopOnSameDate);
const dates: Date[] = [
...(toDate ? [toDate] : []),
...(maxDate ? [maxDate] : []),
...(followingRangeeDate ? [followingRangeeDate] : []),
...(followingRangeDate ? [followingRangeDate] : []),
];
return findClosestDateAfterDate(fromDate, dates);
return findClosestDateAfterDate(fromDate, dates) || maxDate;
};
export const getMaxDateForRangeEnd = ({
fromDate,
Expand Down Expand Up @@ -141,7 +141,7 @@ export const getMinDateForRangeStart = ({
const preceedingDate = getPreceedingDate(preceedingDateRange, allowRangesToStartAndStopOnSameDate);
const dates: Date[] = [...(minDate ? [minDate] : []), ...(preceedingDate ? [preceedingDate] : [])];

return findClosestDateBeforeDate(toDate, dates);
return findClosestDateBeforeDate(toDate, dates) || minDate;
};

export const getMinDateForRangeEnd = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ const defaultProps: FormikDateRangePickerProps<any, any> = {
label: 'To',
name: 'to',
},
minDate: new Date('2023-08-03'),
maxDate: new Date('2023-10-12'),
dropdownCaption: true,
minDate: new Date('2023-11-06'),
maxDate: new Date('2023-11-06'),
};

Default.args = {
Expand Down
8 changes: 8 additions & 0 deletions packages/sif-common-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @navikt/sif-common-ui

## 0.0.13

### Patch Changes

- Updated dependencies [1d7c508f]
- @navikt/[email protected]
- @navikt/[email protected]

## 0.0.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/sif-common-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@navikt/sif-common-ui",
"main": "src/index.ts",
"types": "src/index.ts",
"version": "0.0.12",
"version": "0.0.13",
"private": true,
"dependencies": {
"@navikt/ds-css": "5.9.2",
Expand Down
Loading