Skip to content

Commit

Permalink
Merge branch 'main' into ci/improve-schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 13, 2024
2 parents 6f5e58e + c40a213 commit 4a30a4c
Show file tree
Hide file tree
Showing 40 changed files with 1,456 additions and 104 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ apps/**/index.html

.nx/
.zed/

# E2E outputs
test-results/
playwright-report/
tmp-sessions/
1 change: 1 addition & 0 deletions apps/judicial-system/web/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export { default as RulingAccordionItem } from './AccordionItems/RulingAccordion
export { default as RulingInput } from './RulingInput/RulingInput'
export { default as SectionHeading } from './SectionHeading/SectionHeading'
export { default as ServiceAnnouncement } from './ServiceAnnouncement/ServiceAnnouncement'
export { strings as serviceAnnouncementStrings } from './ServiceAnnouncement/ServiceAnnouncement.strings'
export { default as ServiceInterruptionBanner } from './ServiceInterruptionBanner/ServiceInterruptionBanner'
export { default as SignedDocument } from './SignedDocument/SignedDocument'
export { default as OverviewHeader } from './OverviewHeader/OverviewHeader'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { FC, useCallback, useContext, useState } from 'react'
import { useIntl } from 'react-intl'
import { useRouter } from 'next/router'

import { Accordion, Box, Button } from '@island.is/island-ui/core'
import { Accordion, AlertMessage, Box, Button } from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { normalizeAndFormatNationalId } from '@island.is/judicial-system/formatters'
import {
formatDate,
normalizeAndFormatNationalId,
} from '@island.is/judicial-system/formatters'
import {
isCompletedCase,
isDefenceUser,
isProsecutionUser,
isSuccessfulServiceStatus,
} from '@island.is/judicial-system/types'
import { titles } from '@island.is/judicial-system-web/messages'
import {
Expand All @@ -25,26 +29,64 @@ import {
PageHeader,
PageLayout,
PageTitle,
serviceAnnouncementStrings,
useIndictmentsLawsBroken,
UserContext,
} from '@island.is/judicial-system-web/src/components'
import {
CaseIndictmentRulingDecision,
CaseState,
Defendant,
IndictmentDecision,
Subpoena,
UserRole,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { ReviewDecision } from '../../PublicProsecutor/components/ReviewDecision/ReviewDecision'
import { strings } from './IndictmentOverview.strings'

interface ServiceAnnouncementProps {
defendant: Defendant
subpoena: Subpoena
}

const ServiceAnnouncement: FC<ServiceAnnouncementProps> = (props) => {
const { defendant, subpoena } = props
const { formatMessage } = useIntl()

const getTitle = (defendantName?: string | null): string => {
const successMessage = formatMessage(
serviceAnnouncementStrings.serviceStatusSuccess,
)

return defendantName
? `${successMessage} - ${defendantName}`
: successMessage
}

const getMessage = (
servedBy?: string | null,
serviceDate?: string | null,
): string => {
return [servedBy, formatDate(serviceDate, 'Pp')].filter(Boolean).join(', ')
}

return (
<AlertMessage
type="success"
title={getTitle(defendant.name)}
message={getMessage(subpoena.servedBy, subpoena.serviceDate)}
/>
)
}

const IndictmentOverview: FC = () => {
const router = useRouter()
const { workingCase, isLoadingWorkingCase, caseNotFound } =
useContext(FormContext)
const { user } = useContext(UserContext)

const { user } = useContext(UserContext)
const { formatMessage } = useIntl()
const router = useRouter()
const lawsBroken = useIndictmentsLawsBroken(workingCase)
const caseHasBeenReceivedByCourt = workingCase.state === CaseState.RECEIVED
const latestDate = workingCase.courtDate ?? workingCase.arraignmentDate
Expand All @@ -53,10 +95,16 @@ const IndictmentOverview: FC = () => {
const [modalVisible, setModalVisible] = useState<boolean>(false)
const [isReviewDecisionSelected, setIsReviewDecisionSelected] =
useState(false)

const hasLawsBroken = lawsBroken.size > 0
const hasMergeCases =
workingCase.mergedCases && workingCase.mergedCases.length > 0

const shouldDisplayReviewDecision =
isCompletedCase(workingCase.state) &&
workingCase.indictmentReviewer?.id === user?.id &&
Boolean(!workingCase.indictmentReviewDecision)

const canAddFiles =
!isCompletedCase(workingCase.state) &&
isDefenceUser(user) &&
Expand All @@ -69,6 +117,7 @@ const IndictmentOverview: FC = () => {
) &&
workingCase.indictmentDecision !==
IndictmentDecision.POSTPONING_UNTIL_VERDICT

const shouldDisplayGeneratedPdfFiles =
isProsecutionUser(user) ||
workingCase.defendants?.some(
Expand Down Expand Up @@ -96,10 +145,6 @@ const IndictmentOverview: FC = () => {
[router, workingCase.id],
)

const hasLawsBroken = lawsBroken.size > 0
const hasMergeCases =
workingCase.mergedCases && workingCase.mergedCases.length > 0

return (
<PageLayout
workingCase={workingCase}
Expand All @@ -124,6 +169,21 @@ const IndictmentOverview: FC = () => {
: formatMessage(strings.inProgressTitle)}
</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
{isDefenceUser(user) &&
workingCase.defendants?.map((defendant) =>
(defendant.subpoenas ?? [])
.filter((subpoena) =>
isSuccessfulServiceStatus(subpoena.serviceStatus),
)
.map((subpoena) => (
<Box key={`${defendant.id}${subpoena.id}`} marginBottom={2}>
<ServiceAnnouncement
defendant={defendant}
subpoena={subpoena}
/>
</Box>
)),
)}
{caseHasBeenReceivedByCourt &&
workingCase.court &&
latestDate?.date &&
Expand Down
39 changes: 34 additions & 5 deletions apps/native/app/src/graphql/fragments/vehicle.fragment.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
fragment VehicleFragment on VehicleListed {
fragment VehicleFragment on VehiclesVehicle {
isCurrent
permno
regno
make
colorName
vin
type
color
firstRegDate
modelYear
productYear
registrationType
role
operatorStartDate
operatorEndDate
outOfUse
otherOwners
termination
buyerPersidno
ownerPersidno
vehicleStatus
useGroup
vehGroup
plateStatus
nextInspection {
nextInspectionDate
nextInspectionDateIfPassedInspectionToday
}
operatorNumber
primaryOperator
ownerSsid
ownerName
lastInspectionResult
lastInspectionDate
lastInspectionType
nextInspectionDate
nextAvailableMileageReadDate
requiresMileageRegistration
canRegisterMilage
nextMainInspection
canRegisterMileage
}
4 changes: 2 additions & 2 deletions apps/native/app/src/graphql/queries/vehicles.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query ListVehiclesV2($input: GetVehiclesListV2Input!) {
vehiclesListV2(input: $input) {
query ListVehicles($input: GetVehiclesForUserInput!) {
vehiclesList(input: $input) {
vehicleList {
...VehicleFragment
}
Expand Down
7 changes: 7 additions & 0 deletions apps/native/app/src/messages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ export const en: TranslatedMessages = {
'At the moment it is not possible to add driving licenses to the phone.',
'walletPass.moreInfo': 'More information',
'walletPass.alertClose': 'Cancel',
'walletPass.errorCannotAddPasses':
'You cannot add passes. Please make sure you have Smartwallet installed on your device.',
'walletPass.errorAddingOrFetching': 'Failed to fetch or add pass.',
'walletPass.errorNotPossibleOnThisDevice':
'You cannot add passes on this device.',
'walletPass.errorNotConnectedNoBarcode':
'Not possible to scan barcode if the device is not connected to the internet.',

// wallet passport
'walletPassport.screenTitle': 'Passport',
Expand Down
8 changes: 8 additions & 0 deletions apps/native/app/src/messages/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ export const is = {
'Í augnablikinu er ekki hægt að senda ökuskírteini í síma.',
'walletPass.moreInfo': 'Nánari upplýsingar',
'walletPass.alertClose': 'Loka',
'walletPass.errorCannotAddPasses':
'Þú getur ekki bætt við skírteini. Vinsamlegast vertu viss um að þú sért með Smartwallet appið sett upp á tækinu.',
'walletPass.errorAddingOrFetching':
'Tókst ekki að sækja eða bæta við skírteini.',
'walletPass.errorNotPossibleOnThisDevice':
'Þú getur ekki bætt við skírteinum á þetta tæki.',
'walletPass.errorNotConnectedNoBarcode':
'Ekki er hægt að skanna skírteini nema að tækið sé nettengt.',

// wallet passport
'walletPassport.screenTitle': 'Vegabréf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ const useHtmlStyles = () => {
color: ${theme.color.blue400};
text-decoration: none;
}
svg {
max-width: 100%;
display: block;
}
img {
max-width: 100%;
display: block;
}
</style>
<meta name="viewport" content="width=device-width">`
}
Expand Down
6 changes: 4 additions & 2 deletions apps/native/app/src/screens/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
} from './licenses-module'
import { OnboardingModule } from './onboarding-module'
import {
useListVehiclesV2Query,
useListVehiclesQuery,
validateVehiclesInitialData,
VehiclesModule,
} from './vehicles-module'
Expand Down Expand Up @@ -174,11 +174,13 @@ export const MainHomeScreen: NavigationFunctionComponent = ({
skip: !airDiscountWidgetEnabled,
})

const vehiclesRes = useListVehiclesV2Query({
const vehiclesRes = useListVehiclesQuery({
variables: {
input: {
page: 1,
pageSize: 15,
showDeregeristered: false,
showHistory: false,
},
},
skip: !vehiclesWidgetEnabled,
Expand Down
14 changes: 7 additions & 7 deletions apps/native/app/src/screens/home/vehicles-module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import illustrationSrc from '../../assets/illustrations/le-moving-s4.png'
import { navigateTo } from '../../lib/deep-linking'
import { VehicleItem } from '../vehicles/components/vehicle-item'
import {
ListVehiclesV2Query,
useListVehiclesV2Query,
ListVehiclesQuery,
useListVehiclesQuery,
} from '../../graphql/types/schema'
import { screenWidth } from '../../utils/dimensions'

Expand All @@ -30,15 +30,15 @@ const validateVehiclesInitialData = ({
data,
loading,
}: {
data: ListVehiclesV2Query | undefined
data: ListVehiclesQuery | undefined
loading: boolean
}) => {
if (loading) {
return true
}
// Only show widget initially if there are vehicles that require mileage registration
if (
data?.vehiclesListV2?.vehicleList?.some(
data?.vehiclesList?.vehicleList?.some(
(vehicle) => vehicle.requiresMileageRegistration,
)
) {
Expand All @@ -49,7 +49,7 @@ const validateVehiclesInitialData = ({
}

interface VehiclesModuleProps {
data: ListVehiclesV2Query | undefined
data: ListVehiclesQuery | undefined
loading: boolean
error?: ApolloError | undefined
}
Expand All @@ -59,7 +59,7 @@ const VehiclesModule = React.memo(
const theme = useTheme()
const intl = useIntl()

const vehicles = data?.vehiclesListV2?.vehicleList
const vehicles = data?.vehiclesList?.vehicleList

// Reorder vehicles so vehicles that require mileage registration are shown first
const reorderedVehicles = useMemo(
Expand Down Expand Up @@ -170,4 +170,4 @@ const VehiclesModule = React.memo(
},
)

export { VehiclesModule, validateVehiclesInitialData, useListVehiclesV2Query }
export { VehiclesModule, validateVehiclesInitialData, useListVehiclesQuery }
14 changes: 7 additions & 7 deletions apps/native/app/src/screens/vehicles/components/vehicle-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import React from 'react'
import { FormattedDate, FormattedMessage } from 'react-intl'
import { SafeAreaView, TouchableHighlight, View, ViewStyle } from 'react-native'
import styled, { useTheme } from 'styled-components/native'
import { ListVehiclesV2Query } from '../../../graphql/types/schema'
import { ListVehiclesQuery } from '../../../graphql/types/schema'
import { navigateTo } from '../../../lib/deep-linking'

function differenceInMonths(a: Date, b: Date) {
return a.getMonth() - b.getMonth() + 12 * (a.getFullYear() - b.getFullYear())
}

type VehicleListItem = NonNullable<
NonNullable<ListVehiclesV2Query['vehiclesListV2']>['vehicleList']
NonNullable<ListVehiclesQuery['vehiclesList']>['vehicleList']
>[0]

const Cell = styled(TouchableHighlight)`
Expand All @@ -31,8 +31,8 @@ export const VehicleItem = React.memo(
style?: ViewStyle
}) => {
const theme = useTheme()
const nextInspection = item?.nextMainInspection
? new Date(item?.nextMainInspection)
const nextInspection = item?.nextInspection?.nextInspectionDate
? new Date(item?.nextInspection.nextInspectionDate)
: null

const isInspectionDeadline =
Expand All @@ -51,14 +51,14 @@ export const VehicleItem = React.memo(
onPress={() => {
navigateTo(`/vehicle/`, {
id: item.permno,
title: item.make,
title: item.type,
})
}}
>
<SafeAreaView>
<VehicleCard
title={item.make}
color={item.colorName}
title={item.type}
color={item.color}
number={item.regno}
minHeight={minHeight}
label={
Expand Down
4 changes: 4 additions & 0 deletions apps/native/app/src/screens/vehicles/vehicles-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const { getNavigationOptions, useNavigationOptions } =
topBar: {
visible: true,
},
bottomTabs: {
visible: false,
drawBehind: true,
},
}))

export const VehicleDetailScreen: NavigationFunctionComponent<{
Expand Down
Loading

0 comments on commit 4a30a4c

Please sign in to comment.