-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vehicles): Add operator to lookup screen (#16119)
* Add operator to lookup screen * Markup fix * Update operator on vehicle search * Fix --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2197961
commit 29a1854
Showing
10 changed files
with
218 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
libs/api/domains/vehicles/src/lib/utils/operatorStatusMapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { OperatorAnonymityStatus } from '../models/getVehicleSearch.model' | ||
|
||
export const operatorStatusMapper = ( | ||
names: string[] | undefined | null, | ||
allOperatorsAreAnonymous: boolean, | ||
someOperatorsAreAnonymous: boolean, | ||
): OperatorAnonymityStatus => { | ||
if (allOperatorsAreAnonymous) { | ||
return OperatorAnonymityStatus.ALL | ||
} | ||
|
||
if (someOperatorsAreAnonymous && names?.length) { | ||
return OperatorAnonymityStatus.SOME | ||
} | ||
|
||
return OperatorAnonymityStatus.UNKNOWN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { VehicleSearchDto } from '@island.is/clients/vehicles' | ||
import { OperatorAnonymityStatus } from './models/getVehicleSearch.model' | ||
|
||
export interface VehicleSearchOperatorDto { | ||
operatorNames?: Array<string> | null | ||
operatorAnonymityStatus?: OperatorAnonymityStatus | ||
} | ||
|
||
export interface VehicleSearchCustomDto | ||
extends VehicleSearchDto, | ||
VehicleSearchOperatorDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
libs/service-portal/assets/src/components/LookupOperator/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react' | ||
import { Box, Text } from '@island.is/island-ui/core' | ||
import { useLocale, useNamespaces } from '@island.is/localization' | ||
|
||
import { vehicleMessage as messages } from '../../lib/messages' | ||
import { OperatorAnonymityStatus } from '@island.is/api/schema' | ||
|
||
interface PropTypes { | ||
names?: string[] | ||
operatorAnonymityStatus?: OperatorAnonymityStatus | ||
} | ||
|
||
const LookupOperator = ({ names, operatorAnonymityStatus }: PropTypes) => { | ||
useNamespaces('sp.vehicles') | ||
const { formatMessage } = useLocale() | ||
|
||
if (operatorAnonymityStatus === OperatorAnonymityStatus.ALL) { | ||
return <span>{formatMessage(messages.anonymous)}</span> | ||
} | ||
|
||
if (names?.length) { | ||
return ( | ||
<div> | ||
{names?.map((name, i) => ( | ||
<React.Fragment key={i}> | ||
{i + 1}. {name} | ||
<br /> | ||
</React.Fragment> | ||
))} | ||
{operatorAnonymityStatus === OperatorAnonymityStatus.SOME ? ( | ||
<Box marginTop={1}> | ||
<Text variant="small"> | ||
{formatMessage(messages.anonymousPartial)} | ||
</Text> | ||
</Box> | ||
) : undefined} | ||
</div> | ||
) | ||
} | ||
|
||
return '' | ||
} | ||
|
||
export default LookupOperator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters