Edit UI: Use VueRouter to pass the businessID to views
- Lenguaje dominante
- JavaScript
- Estrellas
- 23
- Forks
- 62
- Merge medio
- 24 min
- PR fusionados (30 d)
- 1
Descripción
## 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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza en App.vue y sigue el flujo personalizado de fetchConfig() que extrae y almacena BUSINESS_ID. Revisa las definiciones de rutas existentes de VueRouter y la guía enlazada sobre el paso de props en VueRouter; se considera terminado cuando las vistas reciben businessId mediante props de ruta y la validación se gestiona mediante un navigation guard en lugar del flujo personalizado de sessionStorage.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- frontend
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 32/100