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): Add municipality #17109

Merged
merged 35 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c9399dc
TS-936 Municipality
birkirkristmunds Dec 3, 2024
14a326c
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Dec 9, 2024
525e7f7
TS-936 Municipality
birkirkristmunds Dec 10, 2024
d1108ea
TS-936 Municipality
birkirkristmunds Dec 10, 2024
a2ce8ec
TS-936 Municipality
birkirkristmunds Dec 13, 2024
900ae14
TS-936 Municipality
birkirkristmunds Dec 16, 2024
7e4ddbb
TS-936 Municipality
birkirkristmunds Dec 16, 2024
956bbd9
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Dec 16, 2024
582ac4c
TS-936 Municipality
birkirkristmunds Dec 16, 2024
4336424
TS-936 Municipality
birkirkristmunds Dec 16, 2024
5985196
TS-936 Municipality
birkirkristmunds Dec 16, 2024
c08c62e
TS-936 Municipality
birkirkristmunds Dec 16, 2024
d98ff09
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Dec 16, 2024
3eb50de
TS-936 Municipality
birkirkristmunds Dec 16, 2024
00bb7f3
TS-936 Municipality
birkirkristmunds Dec 16, 2024
8e384b3
TS-936 Municipality
birkirkristmunds Dec 16, 2024
0151c27
TS-936 Municipality
birkirkristmunds Dec 17, 2024
9955863
TS-936 Municipality
birkirkristmunds Dec 17, 2024
9921511
TS-936 Municipality
birkirkristmunds Dec 17, 2024
d7d7cd9
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Dec 18, 2024
4906b4c
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Dec 19, 2024
557e7e2
TS-936 Municipality
birkirkristmunds Dec 23, 2024
abd46a4
TS-936 Municipality
birkirkristmunds Dec 23, 2024
9105ddd
TS-936 Municipality
birkirkristmunds Dec 23, 2024
7cb4964
TS-936 Municipality
birkirkristmunds Dec 23, 2024
f17ae44
TS-936 Municipality
birkirkristmunds Dec 27, 2024
87e8dd6
TS-936 Municipality
birkirkristmunds Dec 27, 2024
04f7ad3
TS-936 Municipality
birkirkristmunds Dec 27, 2024
ddc2114
TS-936 Municipality
birkirkristmunds Dec 27, 2024
d302107
TS-936 Municipality
birkirkristmunds Jan 9, 2025
e53196f
TS-936 Municipality
birkirkristmunds Jan 9, 2025
e4395d9
Merge branch 'main' into feat/skilavottord-add-municipality
birkirkristmunds Jan 9, 2025
680b5f9
TS-936 Municipality
birkirkristmunds Jan 9, 2025
0dcb452
TS-936 Municipality
birkirkristmunds Jan 9, 2025
c6e53e7
Merge branch 'main' into feat/skilavottord-add-municipality
kodiakhq[bot] Jan 9, 2025
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
8 changes: 4 additions & 4 deletions apps/skilavottord/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ See role description further down.
### Dev

- [Dev - role: company](https://beta.dev01.devland.is/app/skilavottord/deregister-vehicle)
- [Dev - role: fund](https://beta.dev01.devland.is/app/skilavottord/recycled-vehicles)
- [Dev - role: fund/municipality](https://beta.dev01.devland.is/app/skilavottord/recycled-vehicles)

### Staging

- [Staging - role: company](https://beta.staging01.devland.is/app/skilavottord/deregister-vehicle)
- [Staging - role: fund](https://beta.staging01.devland.is/app/skilavottord/recycled-vehicles)
- [Staging - role: fund/municipality](https://beta.staging01.devland.is/app/skilavottord/recycled-vehicles)

### Prod

- [Prod - role: company](https://island.is/app/skilavottord/deregister-vehicle)
- [Prod - role: fund](https://island.is/app/skilavottord/recycled-vehicles)
- [Prod - role: fund/municipality](https://island.is/app/skilavottord/recycled-vehicles)

## Getting started

Expand Down Expand Up @@ -106,7 +106,7 @@ URL:
If users are registered as an employee of a recycling company, they can log in
here to deregister vehicles that citizens have marked for recycling.

### Fund frontend
### Fund/municipality frontend

URL:
[https://island.is/app/skilavottord/recycled-vehicles](https://island.is/app/skilavottord/recycled-vehicles)
Expand Down
24 changes: 15 additions & 9 deletions apps/skilavottord/web/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,35 @@ type Page =
| 'accessControl'
| 'accessControlCompany'
| 'companyInfo'
| 'deregisterVehicleKM'

export const isDeveloper = (role: Role) => role === Role.developer
export const hasDeveloperRole = (role: Role | undefined) =>
role === Role.developer
birkirkristmunds marked this conversation as resolved.
Show resolved Hide resolved
export const hasMunicipalityRole = (role: Role | undefined) =>
role === Role.municipality

export const hasRecyclingFundRole = (role: Role | undefined) =>
role === Role.recyclingFund

export const hasPermission = (page: Page, role: Role) => {
if (!role) return false

if (role === Role.developer) return true

const permittedRoutes = {
recyclingCompany: [
'deregisterVehicle',
'companyInfo',
'deregisterVehicleKM',
],
recyclingCompany: ['deregisterVehicle', 'companyInfo'],
recyclingCompanyAdmin: [
'deregisterVehicle',
'companyInfo',
'accessControlCompany',
'deregisterVehicleKM',
],
citizen: ['myCars', 'recycleVehicle'],
recyclingFund: ['recycledVehicles', 'recyclingCompanies', 'accessControl'],
recyclingFund: [
'recycledVehicles',
'recyclingCompanies',
'accessControl',
'municipalities',
],
municipality: ['recycledVehicles', 'recyclingCompanies', 'accessControl'],
}

return permittedRoutes[role].includes(page)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { hasMunicipalityRole } from '@island.is/skilavottord-web/auth/utils'
import { UserContext } from '@island.is/skilavottord-web/context'
import { useI18n } from '@island.is/skilavottord-web/i18n'
import { useContext } from 'react'
import Sidenav from '../Sidenav/Sidenav'

export const NavigationLinks = ({
activeSection,
}: {
activeSection: number
}) => {
const {
t: { recyclingFundSidenav: sidenavText, routes },
} = useI18n()

const { user } = useContext(UserContext)

let title = sidenavText.title
if (hasMunicipalityRole(user?.role)) {
title = sidenavText.municipalityTitle
}

return (
<Sidenav
title={title}
sections={[
{
icon: 'car',
title: `${sidenavText.recycled}`,
link: `${routes.recycledVehicles}`,
},
{
icon: 'people',
title: `${sidenavText.municipalities}`,
link: `${routes.municipalities.baseRoute}`,
hidden: hasMunicipalityRole(user?.role),
},
{
icon: 'business',
title: `${sidenavText.companies}`,
link: `${routes.recyclingCompanies.baseRoute}`,
},
{
icon: 'lockClosed',
title: `${sidenavText.accessControl}`,
link: `${routes.accessControl}`,
},
]}
activeSection={activeSection}
/>
)
}
export default NavigationLinks
30 changes: 30 additions & 0 deletions apps/skilavottord/web/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { FC } from 'react'

import {
Box,
GridColumn,
GridRow,
Text,
Tooltip,
} from '@island.is/island-ui/core'

export const PageHeader: FC<{ title: string; info: string }> = ({
title,
info,
}) => {
return (
<Box display="flex" alignItems="flexStart" justifyContent="spaceBetween">
<GridRow>
<GridColumn order={[2, 1]}>
<Text variant="h1" as="h1" marginBottom={4}>
{title}
</Text>
</GridColumn>
<GridColumn order={[1, 2]}>
<Tooltip text={info} />
birkirkristmunds marked this conversation as resolved.
Show resolved Hide resolved
</GridColumn>
</GridRow>
</Box>
)
}
export default PageHeader
15 changes: 4 additions & 11 deletions apps/skilavottord/web/components/Sidenav/Sidenav.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import React, { FC } from 'react'
import {
Box,
Divider,
FocusableBox,
Icon,
Stack,
Text,
} from '@island.is/island-ui/core'
import { Box, FocusableBox, Icon, Stack, Text } from '@island.is/island-ui/core'

interface SidenavSection {
title: string
link: string
icon?: string
hidden?: boolean
}

interface SidenavProps {
Expand All @@ -20,7 +13,7 @@ interface SidenavProps {
activeSection: number
}

type SidenavIcon = 'car' | 'business' | 'lockClosed'
type SidenavIcon = 'car' | 'business' | 'lockClosed' | 'municipality'

export const Sidenav = ({ title, sections, activeSection }: SidenavProps) => (
<Box background="blue100" padding={4} borderRadius="large">
Expand All @@ -30,7 +23,7 @@ export const Sidenav = ({ title, sections, activeSection }: SidenavProps) => (
</Text>
<Stack space={3}>
{sections.map((section, index) => {
if (!section?.title) return null
if (!section?.title || section.hidden) return null
return (
<FocusableBox
key={index}
Expand Down
61 changes: 47 additions & 14 deletions apps/skilavottord/web/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,11 @@
},
"recyclingFundSidenav": {
"title": "Service",
"municipalityTitle": "Municipality",
"recycled": "Recycled cars",
"companies": "Recycling companies",
"accessControl": "Access Control"
"accessControl": "Access Control",
"municipalities": "Municipalities"
},
"recyclingCompanies": {
"title": "Recycling companies",
Expand All @@ -390,7 +392,8 @@
},
"buttons": {
"add": "Add recycling company",
"view": "View"
"view": "View",
"addMunicipality": "Add municipality"
},
"recyclingCompany": {
"view": {
Expand All @@ -409,32 +412,32 @@
"form": {
"inputs": {
"companyId": {
"label": "Company ID",
"placeholder": "Company ID",
"label": "ID",
"placeholder": "ID",
"rules": {
"required": "Company ID is required"
"required": "ID is required"
}
},
"companyName": {
"label": "Company name",
"placeholder": "Company name",
"label": "Name",
"placeholder": "Name",
"rules": {
"required": "Company name is required"
"required": "Name is required"
}
},
"nationalId": {
"label": "Company national ID",
"placeholder": "Company national ID",
"label": "National ID",
"placeholder": "National ID",
"rules": {
"required": "Company national ID is required",
"required": "National ID is required",
"validate": "National ID is incorrect"
}
},
"email": {
"label": "Company email",
"placeholder": "Company email",
"label": "Email",
"placeholder": "Email",
"rules": {
"required": "Company email is required",
"required": "Email is required",
"validate": "Invalid email"
}
},
Expand Down Expand Up @@ -575,6 +578,13 @@
"rules": {
"required": "Partner is required"
}
},
"municipality": {
"label": "Municipality",
"placeholder": "Municipality",
"rules": {
"required": "Municipality is required"
}
}
},
"buttons": {
Expand Down Expand Up @@ -627,6 +637,29 @@
"baseRoute": "/en/company-info",
"add": "/en/company-info/edit",
"edit": "/en/company-info/add"
},
"municipalities": {
"baseRoute": "/en/municipalities",
"add": "/en/municipalities/add",
"edit": "/en/municipalities/[id]"
}
},
"municipalities": {
"title": "Municipalities",
"municipality": {
"view": {
"title": "Municipality",
"breadcrumb": "View",
"info": "You can update the municipality. Please confirm that the information are correct.",
"updated": "Updated",
"deleted": "Deleted"
},
"add": {
"title": "Add municipality",
"breadcrumb": "Add new",
"info": "Adding a new municipality will make it available to access control. Please verify that the municipality information is correct.",
"added": "Added"
}
}
}
}
Loading
Loading