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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
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} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance tooltip accessibility

The Tooltip component should have proper ARIA attributes for better screen reader support.

-          <Tooltip text={info} />
+          <Tooltip 
+            text={info}
+            aria-label={`Additional information about ${title}`}
+          />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Tooltip text={info} />
<Tooltip
text={info}
aria-label={`Additional information about ${title}`}
/>

</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": "Þú getur annaðhvort uppfært eða eytt móttökuaðila. Vinsamlegast staðfestið að upplýsingar fyrirtækis séu rétt slegnar inn.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix non-English content in English locale file.

These strings are in Icelandic instead of English:

  • Line 650: "Þú getur annaðhvort uppfært eða eytt móttökuaðila..."
  • Line 657: "Þegar nýju sveitarfélagi er bætt við..."

Also applies to: 657-657

"updated": "Updated",
"deleted": "Deleted"
},
"add": {
"title": "Add municipality",
"breadcrumb": "Add new",
"info": "Þegar nýju sveitarfélagi er bætt við, verður hann aðgengilegur í aðgangsstýringu. Vinsamlegast staðfestið að upplýsingar fyrirtækis séu rétt slegnar inn.",
"added": "Added"
}
}
}
}
Loading
Loading