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

feat(Skilavottord): Handle number plates and information about pre-deregistered vehicles #15878

Merged
merged 23 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d048088
TS-866 Rough first implementation
birkirkristmunds Aug 29, 2024
c8cfd53
TS-866 Implemented Samgöngustofa Traffic REST call.
birkirkristmunds Sep 4, 2024
6073551
Merge branch 'main' into feat/skilavottord-handle-unregister-vehicles
birkirkristmunds Sep 4, 2024
d6d07fe
TS-866 Fix unit test
birkirkristmunds Sep 4, 2024
0d079e1
TS-866 Continue working
birkirkristmunds Sep 5, 2024
f875da1
TS-866 Remove deregister column
birkirkristmunds Sep 9, 2024
434cc76
TS-866 Fixing wrong data sent to Samgöngustofu
birkirkristmunds Sep 9, 2024
1877970
TS-866 Fixing show right alert box and hide selection box
birkirkristmunds Sep 9, 2024
0ffdfc3
TS-866 Refactoring code
birkirkristmunds Sep 9, 2024
8018de0
Merge branch 'main' into feat/skilavottord-handle-unregister-vehicles
birkirkristmunds Sep 9, 2024
39fd638
TS-866 Fix after Coderabbit review
birkirkristmunds Sep 9, 2024
a234396
Merge remote-tracking branch 'origin/feat/skilavottord-handle-unregis…
birkirkristmunds Sep 9, 2024
ee01473
TS-866 Fix after Coderabbit review
birkirkristmunds Sep 9, 2024
022bcad
TS-866 Fix after Coderabbit review
birkirkristmunds Sep 9, 2024
606a42d
TS-866 Fix after Coderabbit review
birkirkristmunds Sep 9, 2024
e565f9c
TS-866 Code refactoring
birkirkristmunds Sep 10, 2024
4718dfa
TS-866 Removed checkbox blue background
birkirkristmunds Sep 10, 2024
93bd06e
TS-866 Fix 0 mileage
birkirkristmunds Sep 10, 2024
6198451
TS-866 Fix after coderabbit review
birkirkristmunds Sep 10, 2024
db14866
TS-866 Add back owner
birkirkristmunds Sep 11, 2024
02878b6
TS-866 improve logging
birkirkristmunds Sep 11, 2024
24d3b99
Merge branch 'main' into feat/skilavottord-handle-unregister-vehicles
kodiakhq[bot] Sep 11, 2024
7d45fc0
Merge branch 'main' into feat/skilavottord-handle-unregister-vehicles
kodiakhq[bot] Sep 11, 2024
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
Expand Up @@ -2,36 +2,19 @@ import { Box, Stack, Text } from '@island.is/island-ui/core'
import { OutlinedBox } from '@island.is/skilavottord-web/components'
import React, { FC } from 'react'

import { useI18n } from '@island.is/skilavottord-web/i18n'

import { InputController } from '@island.is/shared/form-fields'
import { Control, FieldValues } from 'react-hook-form'

interface BoxProps {
vehicleId: string
vehicleType: string
modelYear: string
vehicleOwner?: string | null
mileage?: number
control?: Control<FieldValues>
showMileage?: boolean
}

export const CarDetailsBox: FC<React.PropsWithChildren<BoxProps>> = ({
vehicleId,
vehicleType,
modelYear,
vehicleOwner,
mileage,
control,
showMileage,
}) => {
const {
t: {
deregisterVehicle: { deregister: t },
},
} = useI18n()

return (
<OutlinedBox>
<Box
Expand All @@ -43,23 +26,9 @@ export const CarDetailsBox: FC<React.PropsWithChildren<BoxProps>> = ({
>
<Stack space={1}>
<Text variant="h3">{vehicleId}</Text>
{showMileage && <Text variant="h5">{mileage} km</Text>}
<Text>{`${vehicleType}, ${modelYear}`}</Text>
</Stack>
<Text variant="h5">{vehicleOwner}</Text>

{showMileage && (
<Box>
<InputController
id="mileage"
control={control}
label={t.currentMileage}
name="mileage"
type="number"
defaultValue={mileage?.toString()}
/>
</Box>
)}
</Box>
</OutlinedBox>
)
Expand Down
181 changes: 181 additions & 0 deletions apps/skilavottord/web/components/CarDetailsBox2/CarDetailsBox2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import {
AlertMessage,
Box,
Checkbox,
GridColumn,
GridContainer,
GridRow,
Stack,
Text,
} from '@island.is/island-ui/core'
import React, { FC, useState } from 'react'

import { useI18n } from '@island.is/skilavottord-web/i18n'

import {
InputController,
SelectController,
} from '@island.is/shared/form-fields'

import {
OutInUsage,
PlateInfo,
UseStatus,
} from '@island.is/skilavottord-web/utils/consts'
import { Controller } from 'react-hook-form'

interface BoxProps {
vehicleId: string
vehicleType: string
modelYear: string
mileage?: number
vehicleOwner?: string | null
vinNumber?: string
outInStatus: number
useStatus: string
}

export const CarDetailsBox2: FC<React.PropsWithChildren<BoxProps>> = ({
vehicleId,
vehicleType,
modelYear,
vehicleOwner,
vinNumber,
mileage,
outInStatus,
useStatus,
}) => {
const {
t: {
deregisterVehicle: { deregister: t },
},
} = useI18n()

const [missingPlates, setMissingPlates] = useState(false)
const [lostPlate, setLostPlate] = useState(false)

return (
<GridContainer>
<Stack space={3}>
<GridRow>
<GridColumn span={['12/12', '12/12', '12/12', '6/12']}>
<Box
display="flex"
justifyContent="spaceBetween"
alignItems="center"
>
<Stack space={1}>
<Text variant="h3">{vehicleId}</Text>
<Text variant="h5">{mileage} km</Text>
<Text>{`${vehicleType}, ${modelYear}`}</Text>
{vinNumber && <Text variant="small">VIN: {vinNumber}</Text>}
<Text>{vehicleOwner}</Text>
</Stack>
</Box>
</GridColumn>
<GridColumn
span={['12/12', '12/12', '12/12', '6/12']}
paddingTop={[3, 3, 3, 2]}
>
<InputController
id="mileage"
label={t.currentMileage}
name="mileage"
type="number"
defaultValue={mileage?.toString()}
/>
</GridColumn>
</GridRow>
<GridRow>
<GridColumn span="12/12" paddingTop={[3, 3, 3, 3]}>
<Text variant="h5">{t.numberplate.sectionTitle}</Text>
</GridColumn>
</GridRow>

{outInStatus === OutInUsage.OUT && (
<GridRow>
<GridColumn span="12/12">
{useStatus !== UseStatus.OUT_TICKET && (
<AlertMessage
type="info"
title={t.numberplate.alert.info.title}
message={t.numberplate.alert.info.message}
/>
)}
{useStatus === UseStatus.OUT_TICKET && (
<AlertMessage
type="warning"
title={t.numberplate.alert.warning.title}
message={t.numberplate.alert.warning.message}
/>
)}
</GridColumn>
</GridRow>
)}

{(outInStatus === OutInUsage.IN ||
(outInStatus === OutInUsage.OUT &&
useStatus === UseStatus.OUT_TICKET)) && (
<GridRow>
<GridColumn span="12/12">
<SelectController
label={t.numberplate.count}
id="plateCount"
name="plateCount"
options={[
{ label: '0', value: 0 },
{ label: '1', value: 1 },
{ label: '2', value: 2 },
]}
onSelect={(option) => {
if (option?.value === 2) {
setMissingPlates(false)
setLostPlate(false)
} else {
setMissingPlates(true)
}
}}
defaultValue={2}
/>
</GridColumn>
</GridRow>
)}
{missingPlates && (
<GridRow>
<GridColumn span="12/12">
<Controller
name="plateLost"
render={({ field: { onChange, value, name } }) => {
return (
<Checkbox
large
name={name}
label={t.numberplate.lost}
onChange={() => {
if (!lostPlate) {
onChange(PlateInfo.PLATE_LOST)
} else {
onChange()
}

setLostPlate(!lostPlate)
}}
/>
)
}}
/>
</GridColumn>
</GridRow>
)}

{lostPlate && (
<GridRow>
<GridColumn span="12/12">
<AlertMessage type="info" message={t.numberplate.missingInfo} />
</GridColumn>
</GridRow>
)}
</Stack>
</GridContainer>
)
}
1 change: 1 addition & 0 deletions apps/skilavottord/web/components/CarDetailsBox2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './CarDetailsBox2'
16 changes: 9 additions & 7 deletions apps/skilavottord/web/components/InlineError/InlineError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, Button, Icon, Stack, Text } from '@island.is/island-ui/core'
export interface InlineErrorProps {
title: string
message: string
primaryButton: Button
primaryButton?: Button
secondaryButton?: Button
}

Expand Down Expand Up @@ -40,12 +40,14 @@ export const InlineError: FC<React.PropsWithChildren<InlineErrorProps>> = ({
{secondaryButton.text}
</Button>
)}
<Button
variant={secondaryButton ? 'primary' : 'ghost'}
onClick={primaryButton.action}
>
{primaryButton.text}
</Button>
{primaryButton && (
<Button
variant={secondaryButton ? 'primary' : 'ghost'}
onClick={primaryButton.action}
>
{primaryButton.text}
</Button>
)}
</Stack>
</Box>
)
Expand Down
1 change: 1 addition & 0 deletions apps/skilavottord/web/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './Sidenav/Sidenav'
export * from './GDPR'
export * from './Modal/Modal'
export * from './CarDetailsBox/CarDetailsBox'
export * from './CarDetailsBox2/CarDetailsBox2'
export * from './LinkProvider/LinkProvider'
export * from './Layouts/AppLayout'
export * from './Layouts/PageLayout'
18 changes: 17 additions & 1 deletion apps/skilavottord/web/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,23 @@
"primaryButton": "Try again",
"secondaryButton": "Cancel"
},
"currentMileage": "Current mileage"
"currentMileage": "Current mileage",
"numberplate": {
"sectionTitle": "Number plates information",
"alert": {
"info": {
"title": "The vehicle is registered out of use at the Icelandic Transport Authority.",
"message": "The number plates are deposited at the Icelandic Transport Authority"
},
"warning": {
"title": "The vehicle is registered out of use with a sticker at the Icelandic Transport Authority.",
"message": "The number plates must accompany the vehicle"
}
},
"count": "Number of license plates returned with the vehicle",
"lost": "Number plates are missing",
"missingInfo": "If the number plates are found, they must be returned to the Icelandic Transport Authority"
}
}
},
"recyclingFundOverview": {
Expand Down
18 changes: 17 additions & 1 deletion apps/skilavottord/web/i18n/locales/is.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,23 @@
"primaryButton": "Reyna aftur",
"secondaryButton": "Hætta við"
},
"currentMileage": "Núverandi kílómetrastaða"
"currentMileage": "Núverandi kílómetrastaða",
"numberplate": {
"sectionTitle": "Upplýsingar um númeraplötur",
"alert": {
"info": {
"title": "Ökutækið er skráð úr umferð hjá Samgöngustofu",
"message": "Númeraplöturnar eru innlagðar hjá Samgöngustofu"
},
"warning": {
"title": "Ökutækið er skráð úr umferð (miði) hjá Samgöngustofu",
"message": "Númeraplöturnar eiga að fylgja ökutækinu"
}
},
"count": "Fjöldi númeraplatna skilað með ökutækinu",
"lost": "Númeraplötur eru týndar",
"missingInfo": "Ef að númeraplöturnar finnast skal skila þeim til Samgöngustofu"
}
}
},
"recyclingFundOverview": {
Expand Down
18 changes: 18 additions & 0 deletions apps/skilavottord/web/i18n/locales/translation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ export interface Deregister {
success: string
error: CompletedError
currentMileage: string
numberplate: NumberPlate
}

export interface NumberPlate {
sectionTitle: string
alert: DeregisteredMessages
count: string
lost: string
missingInfo: string
}

export interface DeregisteredMessages {
info: Message
warning: Message
}
export interface Message {
title: string
message: string
}

export interface DeregisterButtons {
Expand Down
Loading
Loading