diff --git a/libs/portals/admin/regulations-admin/src/components/EditMeta.tsx b/libs/portals/admin/regulations-admin/src/components/EditMeta.tsx index 733e52d8d1bb..7b5c6868de28 100644 --- a/libs/portals/admin/regulations-admin/src/components/EditMeta.tsx +++ b/libs/portals/admin/regulations-admin/src/components/EditMeta.tsx @@ -1,6 +1,7 @@ import { Box, Button, + Checkbox, Column, Columns, DatePicker, @@ -11,11 +12,12 @@ import { useLocale } from '@island.is/localization' import { LawChaptersSelect } from './LawChaptersSelect' import { useDraftingState } from '../state/useDraftingState' import { RegulationDraftTypes } from '../types' -import { getNextWorkday } from '../utils' +import { getNextWorkday, getMinPublishDate } from '../utils' export const EditMeta = () => { const { formatMessage: t } = useLocale() const { draft, actions } = useDraftingState() + const { updateState } = actions const type = draft.type const typeName = @@ -29,7 +31,7 @@ export const EditMeta = () => { return ( <> - + { /> - - + + + + + {/* idealPublishDate Input */} + + updateState('idealPublishDate', date) + } + hasError={ + draft.idealPublishDate.showError && + !!draft.idealPublishDate.error + } + errorMessage={ + draft.idealPublishDate.error && t(draft.idealPublishDate.error) + } + backgroundColor="blue" + /> + + + {/* Request fastTrack */} + + { + updateState('fastTrack', !draft.fastTrack.value) + }} + /> + + + + + + { - + {formatDate(draft.idealPublishDate.value) || t(editorMsgs.idealPublishDate_default)} diff --git a/libs/portals/admin/regulations-admin/src/components/EditSignature.tsx b/libs/portals/admin/regulations-admin/src/components/EditSignature.tsx index 85e7a814302d..4ce96964fa05 100644 --- a/libs/portals/admin/regulations-admin/src/components/EditSignature.tsx +++ b/libs/portals/admin/regulations-admin/src/components/EditSignature.tsx @@ -3,10 +3,8 @@ import { AlertMessage, Box, Button, - Checkbox, Column, Columns, - DatePicker, Inline, Input, InputFileUpload, @@ -15,7 +13,6 @@ import { } from '@island.is/island-ui/core' import { useDraftingState } from '../state/useDraftingState' import { editorMsgs as msg } from '../lib/messages' -import { getMinPublishDate } from '../utils' import { EditorInput } from './EditorInput' import { HTMLText, PlainText, URLString } from '@island.is/regulations' @@ -216,42 +213,6 @@ export const EditSignature = () => { - - - {/* idealPublishDate Input */} - - updateState('idealPublishDate', date) - } - hasError={ - draft.idealPublishDate.showError && - !!draft.idealPublishDate.error - } - errorMessage={ - draft.idealPublishDate.error && - t(draft.idealPublishDate.error) - } - backgroundColor="blue" - /> - {/* Request fastTrack */} - { - updateState('fastTrack', !draft.fastTrack.value) - }} - /> - - {/* Clear idealPublishDate */} {!!draft.idealPublishDate.value && ( diff --git a/libs/portals/admin/regulations-admin/src/components/impacts/ImpactDate.tsx b/libs/portals/admin/regulations-admin/src/components/impacts/ImpactDate.tsx index 967928795eb3..14560cfc7830 100644 --- a/libs/portals/admin/regulations-admin/src/components/impacts/ImpactDate.tsx +++ b/libs/portals/admin/regulations-admin/src/components/impacts/ImpactDate.tsx @@ -1,7 +1,9 @@ -import { Box, Button, DatePicker } from '@island.is/island-ui/core' +import { Box, Button, DatePicker, Checkbox } from '@island.is/island-ui/core' import { impactMsgs } from '../../lib/messages' import { DraftImpactForm } from '../../state/types' import { useLocale } from '@island.is/localization' +import { useEffect, useState } from 'react' +import { MessageDescriptor } from 'react-intl' // --------------------------------------------------------------------------- @@ -15,37 +17,61 @@ export type ImpactDateProps = { export const ImpactDate = (props: ImpactDateProps) => { const { impact, onChange, size = 'half', minDate, readOnly } = props - + const [hasCustomDate, setHasCustomDate] = useState(false) + const [selectedDate, setSelectedDate] = useState() + const [errorMessage, setErrorMessage] = useState() const date = impact.date + useEffect(() => { + if (hasCustomDate) { + setSelectedDate(date.value || minDate) + } + }, [hasCustomDate, date.value, minDate]) + + useEffect(() => { + setErrorMessage(date.error) + }, [impact.date]) + const t = useLocale().formatMessage return ( - - {!readOnly && !!date.value && ( - - )} + + setHasCustomDate(!hasCustomDate)} + /> + + {hasCustomDate ? ( + <> + + {!readOnly && !!date.value && ( + + )} + + ) : undefined} ) } diff --git a/libs/portals/admin/regulations-admin/src/lib/messages.ts b/libs/portals/admin/regulations-admin/src/lib/messages.ts index 2a01cfcc7a69..a0e9585ad88d 100644 --- a/libs/portals/admin/regulations-admin/src/lib/messages.ts +++ b/libs/portals/admin/regulations-admin/src/lib/messages.ts @@ -386,6 +386,11 @@ export const impactMsgs = defineMessages({ defaultMessage: 'Ertu viss um að þú viljir eyða þessari skráningu?', }, + specificDateApply: { + id: 'ap.regulations-admin:change-applied-on-specific-date', + defaultMessage: 'Breyting tekur gildi á ákveðinni dagsetningu', + }, + // --------------------------------------------------------------------------- regExplainer: { diff --git a/package.json b/package.json index b57758db0d52..796fdd1b515c 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "@formatjs/intl-locale": "2.4.33", "@formatjs/intl-numberformat": "7.1.5", "@hookform/error-message": "2.0.1", - "@island.is/regulations-tools": "0.9.0", + "@island.is/regulations-tools": "0.9.1", "@keyv/redis": "2.6.1", "@livechat/widget-core": "1.3.2", "@nestjs/apollo": "10.1.0", diff --git a/yarn.lock b/yarn.lock index ce8886939434..594d4ee14dd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12131,9 +12131,9 @@ __metadata: languageName: unknown linkType: soft -"@island.is/regulations-tools@npm:0.9.0": - version: 0.9.0 - resolution: "@island.is/regulations-tools@npm:0.9.0" +"@island.is/regulations-tools@npm:0.9.1": + version: 0.9.1 + resolution: "@island.is/regulations-tools@npm:0.9.1" dependencies: "@hugsmidjan/htmldiff-js": ^1.3.0 "@hugsmidjan/qj": ^4.10.2 @@ -12147,7 +12147,7 @@ __metadata: peerDependencies: react: ">=16.8 <20" react-dom: ">=16.8 <20" - checksum: 9d4950e590721f78c60644ee7f2c16dfb132960c9383e71cce3dbe9037b8e734c6e8609eb44a623e843ec13187759efd45245078ba4e9c60d456068378a28e62 + checksum: e141dc6511c7e6e454389f44219a3784d8aa5072c2731020236b1c7964be524471644a0b3917296bb2a3505d451239639ab59f9e68960a25abef939360645c6f languageName: node linkType: hard @@ -35964,7 +35964,7 @@ __metadata: "@graphql-codegen/typescript-react-apollo": 3.3.3 "@graphql-codegen/typescript-resolvers": 2.7.3 "@hookform/error-message": 2.0.1 - "@island.is/regulations-tools": 0.9.0 + "@island.is/regulations-tools": 0.9.1 "@keyv/redis": 2.6.1 "@livechat/widget-core": 1.3.2 "@nestjs/apollo": 10.1.0