bcgov / bcgov/entity

Edit UI: Use VueRouter to pass the businessID to views

Aperta
#15,653 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
ENTITY - DO NOT USE techdebt
Lingua principale
JavaScript
Stelle
23
Fork
62
Merge medio
24m
PR unite (30g)
1

Descrizione

## What is the problem?
At present, we're not using VueRouter to pass the businessID to the views as property. Instead, we're using a non-standard approach that uses custom code, from a function called `fetchConfig()` called from App.vue. Like this:

```javascript
// get Business ID and validate that it looks OK
// it should be first token after Base URL in Pathname
// FUTURE: improve Business ID validation
const id = windowLocationPathname.replace(processEnvBaseUrl, '').split('/', 1)[0]
const businessIdRegex = /^(BC|C|CP|FM)\d{7}$/
if (businessIdRegex.test(id)) { // Allow corps/firms/coop
sessionStorage.setItem('BUSINESS_ID', id)
} else {
return Promise.reject(new Error('Missing or invalid Business ID.'))
}
```

## What is the impact?
A custom solution to pass the businessID to Vue:
- makes onboarding new developers more difficult
- requires additional testing and documentation
- may have undiscovered security weaknesses

## Proposed solution
Use VueRouter's beautiful, declarative syntax to handle the businessID instead like this:

```javascript
{
path: '/businesses/edit/:businessId/limitedRestorationExtension',
name: RouteNames.LIMITED_RESTORATION_EXTENSION,
component: LimitedRestorationExtension,
props: true
},
```

Then in the view component, `businessId` is available as a prop. The businessId validation should be performed by a "navigation guard" inside VueRouter.

See: https://v3.router.vuejs.org/guide/essentials/passing-props.html

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start in App.vue and trace the custom fetchConfig() flow that extracts and stores BUSINESS_ID. Review the existing VueRouter route definitions and the linked VueRouter passing-props guidance; done means views receive businessId through route props and validation is handled by a navigation guard instead of the custom sessionStorage flow.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
frontend
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
32/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.