Skip to content

Commit

Permalink
MIJN-9578-BUG-thema-parkeren-wordt-niet-getoond-indien-persoon-alleen…
Browse files Browse the repository at this point in the history
…-vergunningen-in-mijn-parkeren-heeft (#1654)

* Name change parkeren collection id's and removed unused

* Remove unused collection id (duplicate)

* Added mock data for the JWE create route

* added jwe endpoint

* fixed

* Added no-data mock variants

* Refactored out sso url fetching. Rename function. It no longer fetches only a url...

* fix test

* removed feature toggle

* Working state

* Fallback URL no longer defined in two places

* fixed tests, removed redundant ones

* Renamed because it did not align with name in keyvault

* Added feature where button to login to parkeren is no longer shown when ONLY decos vergunningen

* Fixed undefined formdata

* Fixed tests, removed unit tests. Are now integration tests

* Last test for error

* Fix wronly named variable

* Update .env.local.template

Co-authored-by: Tim van Oostrom <[email protected]>

* Update .env.local.template

Co-authored-by: Tim van Oostrom <[email protected]>

* Suggestion 1

* Suggestion 2

* Returns true when api errors

* change template file

* Added back the fallback URL

* Removed react parkeren var, replaced with defaults to '/'

* feature toggle back

* removed error logging

* feature toggle and rename

* added comment

* renamed parkeervergunningen

* wrong mock data

* Link changed but need button styling

* changed nodatavariant

* removed loading

* Add MaButtonLink

* Update test

* Refactored in own types

* Fix broken mock, added mock documentation for variants

* Add transform hook, refine types

* Implement hook

* Change import

* Add mokum/eherkenning logic

* Backend service complete with tests

* formatter added parentheses

* Moved helpers, data to bottom. Added forTesting

* Removed redundant any type

* Added test

* Refactored

---------

Co-authored-by: Tim van Oostrom <[email protected]>
  • Loading branch information
RoanPaulus and timvanoostrom authored Dec 16, 2024
1 parent 2e30862 commit 740f328
Show file tree
Hide file tree
Showing 25 changed files with 601 additions and 374 deletions.
9 changes: 5 additions & 4 deletions .env.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ REACT_APP_SSO_URL_ERFPACHT_ZAKELIJK=$BFF_MOCK_API_BASE_URL/sso/portaal/erfpachtz
REACT_APP_SSO_URL_MILIEUZONE=$BFF_MOCK_API_BASE_URL/sso/portaal/milieuzone
REACT_APP_SSO_URL_SVWI=$BFF_MOCK_API_BASE_URL/sso/portaal/svwi


################################################
################################################
# BFF Variables referenced through process.env.
Expand All @@ -82,7 +81,7 @@ DEV_ENC_KEY_256='FaKeKeYtT9jQBEGYCvS?H2rEh3hukwDz'
DEV_ENC_KEY_128='ThIsIsFaKe+36v9y'

# Api key for data.amsterdam api's
BFF_DATA_AMSTERDAM_API_KEY=''
BFF_DATA_AMSTERDAM_API_KEY=$DEV_API_KEY

# Encryption key for general purposes
BFF_GENERAL_ENCRYPTION_KEY=$DEV_ENC_KEY_256
Expand Down Expand Up @@ -207,8 +206,10 @@ BFF_ENABLEU_ERFPACHT_API_KEY=$DEV_API_KEY
BFF_MKS_API_BASE_URL=$BFF_MOCK_API_BASE_URL/mks-koppel-api

# Parkeren
BFF_PARKEREN_API_BASE_URL=$BFF_MOCK_API_BASE_URL/parkeren
BFF_PARKEREN_EXTERNAL_FALLBACK_URL=$BFF_MOCK_API_BASE_URL/sso/portaal/parkeren
BFF_PARKEREN_FRONTOFFICE_API_BASE_URL=$BFF_MOCK_API_BASE_URL/parkeren-frontoffice
BFF_PARKEREN_API_BASE_URL=$BFF_MOCK_API_BASE_URL/parkeren-api
BFF_PARKEREN_API_TOKEN=$DEV_API_KEY
BFF_PARKEREN_PORTAAL_URL=$BFF_MOCK_API_BASE_URL/sso/portaal/parkeren

# Subsidies
BFF_SISA_API_ENDPOINT=$BFF_MOCK_API_BASE_URL/subsidies/ # trailing slash required.
Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ ENV REACT_APP_SSO_URL_MILIEUZONE=$REACT_APP_SSO_URL_MILIEUZONE
ARG REACT_APP_SSO_URL_SVWI=
ENV REACT_APP_SSO_URL_SVWI=$REACT_APP_SSO_URL_SVWI

ARG REACT_APP_SSO_URL_PARKEREN=
ENV REACT_APP_SSO_URL_PARKEREN=$REACT_APP_SSO_URL_PARKEREN


COPY public /build-space/public

Expand Down
17 changes: 17 additions & 0 deletions mocks/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Usage

## Variant switching

[Official Documentation](https://www.mocks-server.org/docs/usage/variants/)

It can be handy to switch datasets for testing.
For example, when you need to see what happens when an api would give no data, but another one does.

To use different data sets.
You can select a variant or collection with the arrow keys in the mock server menu or
permanently in the `mocks.config.js` file.

When adding a new variant try to group them under a name already present.
So we don't end up with variants called `void`, `no-data` and `nothing` for the same thing.
You can check what is already there in `collections.json` or in the menu.

# Adding a router

1. Add your endpoint in `/routes`. See example 1 below:
Expand Down
15 changes: 10 additions & 5 deletions mocks/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
"get-subsidie:standard",
"get-svwi-tegel:standard",
"get-parkeren-external-sso-url:standard",
"get-private-active-permit-request:standard",
"get-company-active-permit-request:standard",
"get-private-client-product-details:standard",
"get-company-client-product-details:standard",
"get-parkeren-create-jwe-token:standard",
"get-parkeren-active-permit-request:standard",
"get-parkeren-client-product-details:standard",
"get-patroon-c:standard",
"get-toeristische-verhuur-by-number:standard",
"post-toeristische-verhuur-with-bsn:standard",
Expand All @@ -71,13 +70,19 @@
"post-powerbrowser-search-requests:standard",
"post-powerbrowser-zaak-status:standard",
"get-powerbrowser-bb-zaak-attachment-download:standard",
"get-powerbrowser-bb-zaak-attachments:standard",
"post-powerbrowser-token:standard",
"get-powerbrowser-zaken:standard",
"post-powerbrowser-personen-zaken:standard",
"post-zorgned-persoonsgegevens:standard",
"post-zorgned-aanvragen:standard",
"post-zorgned-document:standard"
]
},
{
"id": "no-data",
"routes": [
"get-parkeren-active-permit-request:no-data",
"get-parkeren-client-product-details:no-data"
]
}
]
54 changes: 43 additions & 11 deletions mocks/routes/parkeren.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
const settings = require('../settings');

const NO_DATA_VARIANT = {
id: 'no-data',
type: 'json',
options: {
status: 200,
body: {
result: 'success',
count: 0,
data: [],
},
},
};

module.exports = [
{
id: 'get-parkeren-external-sso-url',
url: `${settings.MOCK_BASE_PATH}/parkeren/sso/get_authentication_url`,
url: `${settings.MOCK_BASE_PATH}/parkeren-frontoffice/sso/get_authentication_url`,
method: 'GET',
variants: [
{
Expand All @@ -17,9 +30,26 @@ module.exports = [
],
},
{
id: 'get-private-active-permit-request',
url: `${settings.MOCK_BASE_PATH}/parkeren/:profileType/active_permit_request`,
method: 'GET',
id: 'get-parkeren-create-jwe-token',
url: `${settings.MOCK_BASE_PATH}/parkeren-api/v1/jwe/create`,
method: 'POST',
variants: [
{
id: 'standard',
type: 'json',
options: {
status: 200,
body: {
token: 'xxxjwetokenxxx',
},
},
},
],
},
{
id: 'get-parkeren-active-permit-request',
url: `${settings.MOCK_BASE_PATH}/parkeren-api/v1/:profileType/active_permit_request`,
method: 'POST',
variants: [
{
id: 'standard',
Expand All @@ -28,26 +58,27 @@ module.exports = [
status: 200,
body: {
result: 'success',
count: 1,
data: [
{
link: 'example.org/permits',
id: 8702,
client_id: 8702,
id: 9999,
client_id: 9999,
status: 'in_progress',
permit_name: 'Bewonersvergunning',
permit_zone: 'CE02C Centrum-2c',
permit_zone: 'XX02X Centrum-1x',
},
],
},
},
},
NO_DATA_VARIANT,
],
},

{
id: 'get-private-client-product-details',
url: `${settings.MOCK_BASE_PATH}/parkeren/:profileType/client_product_details`,
method: 'GET',
id: 'get-parkeren-client-product-details',
url: `${settings.MOCK_BASE_PATH}/parkeren-api/v1/:profileType/client_product_details`,
method: 'POST',
variants: [
{
id: 'standard',
Expand All @@ -72,6 +103,7 @@ module.exports = [
},
},
},
NO_DATA_VARIANT,
],
},
];
2 changes: 1 addition & 1 deletion src/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import Krefia from './pages/Krefia/Krefia';
import { default as LandingPage } from './pages/Landing/Landing';
import MyNotifications from './pages/MyNotifications/MyNotifications';
import NotFound from './pages/NotFound/NotFound';
import Parkeren from './pages/Parkeren/Parkeren';
import { Parkeren } from './pages/Parkeren/Parkeren';
import { ParkerenList } from './pages/Parkeren/ParkerenList';
import ProfileCommercial from './pages/Profile/ProfileCommercial';
import Profile from './pages/Profile/ProfilePrivate';
Expand Down
10 changes: 10 additions & 0 deletions src/client/components/MaLink/MaLink.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@
.MaRouterLink__no-default-underline:not(:hover) {
--ams-link-standalone-text-decoration-line: none;
}

.MaButtonLink {
-webkit-appearance: button;
appearance: button;
text-decoration: none;
&:hover,
&:visited {
// color: var(--ams-color-primary-white);
}
}
34 changes: 33 additions & 1 deletion src/client/components/MaLink/MaLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Link, LinkProps } from '@amsterdam/design-system-react';
import { AnchorHTMLAttributes } from 'react';

import { ButtonProps, Link, LinkProps } from '@amsterdam/design-system-react';
import classNames from 'classnames';
import { useHistory } from 'react-router-dom';

Expand Down Expand Up @@ -53,3 +55,33 @@ export function MaRouterLink({ href, onClick, ...rest }: MaLinkProps) {
/>
);
}

type MaButtonLinkProps = Omit<
AnchorHTMLAttributes<HTMLAnchorElement>,
'placeholder'
> & {
variant?: ButtonProps['variant'];
};

export function MaButtonLink({
href,
children,
className,
variant = 'primary',
...rest
}: MaButtonLinkProps) {
return (
<a
{...rest}
className={classNames(
styles.MaButtonLink,
'ams-button',
`ams-button--${variant}`,
className
)}
href={href}
>
{children}
</a>
);
}
8 changes: 3 additions & 5 deletions src/client/config/thema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,13 @@ export const myThemasMenuItems: ThemaMenuItem[] = [
title: ThemaTitles.PARKEREN,
id: Themas.PARKEREN,
to: (appState: AppState) => {
const hasParkerenVergunningen = (
const hasOtherParkeerVegunningen = (
appState.VERGUNNINGEN?.content ?? []
).some((vergunning) =>
PARKEER_CASE_TYPES.has(vergunning.caseType as DecosCaseType)
);
const urlExternal =
appState.PARKEREN.content?.url ??
import.meta.env.REACT_APP_SSO_URL_PARKEREN;
return hasParkerenVergunningen ? AppRoutes.PARKEREN : urlExternal;
const urlExternal = appState.PARKEREN.content?.url ?? '/';
return hasOtherParkeerVegunningen ? AppRoutes.PARKEREN : urlExternal;
},
profileTypes: ['private', 'commercial'],
},
Expand Down
7 changes: 4 additions & 3 deletions src/client/helpers/themas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,18 @@ export function isThemaActive(item: ThemaMenuItem, appState: AppState) {
return !isLoading(KREFIA) && !!KREFIA.content?.deepLinks;

case Themas.PARKEREN: {
const hasDecosParkeerVergunningen =
const hasParkeerVergunningenFromThemaVergunningen =
!isLoading(VERGUNNINGEN) &&
(appState.VERGUNNINGEN?.content ?? []).some((vergunning) =>
PARKEER_CASE_TYPES.has(vergunning.caseType as DecosCaseType)
);
const hasEgisParkeerVergunningen =
const hasParkeerVergunningenFromThemaParkeren =
!isLoading(PARKEREN) && !!PARKEREN?.content?.isKnown;

return (
FeatureToggle.parkerenActive &&
(hasEgisParkeerVergunningen || hasDecosParkeerVergunningen)
(hasParkeerVergunningenFromThemaParkeren ||
hasParkeerVergunningenFromThemaVergunningen)
);
}

Expand Down
Loading

0 comments on commit 740f328

Please sign in to comment.