Skip to content

Commit

Permalink
Update after cr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thordurhhh committed Sep 25, 2024
1 parent 4d04dd2 commit 7d3ae74
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { asDiv, HTMLText } from '@island.is/regulations'
import { GroupedDraftImpactForms, RegDraftForm } from '../state/types'
import format from 'date-fns/format'
import isSameDay from 'date-fns/isSameDay'
import is from 'date-fns/locale/is'
import compact from 'lodash/compact'
import flatten from 'lodash/flatten'
Expand Down Expand Up @@ -35,15 +36,9 @@ const allSameDay = (objects: AdditionObject[]): boolean => {
const validObjects = objects.filter((obj) => obj.date !== undefined)

if (validObjects.length === 0) return true
const firstDate = validObjects[0].date!

const getDateString = (date: string | Date): string => {
const d = new Date(date)
return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`
}

const firstDate = getDateString(validObjects[0].date!)

return validObjects.every((obj) => getDateString(obj.date!) === firstDate)
return validObjects.every((obj) => isSameDay(obj.date!, firstDate))
}

const formatAffectedAndPlaceAffectedAtEnd = (
Expand Down

0 comments on commit 7d3ae74

Please sign in to comment.