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

18137 Name Examination UI to reflect NR number in the URL #1422

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "namex",
"version": "2.1.26",
"version": "2.1.27",
"description": "Webpack 5, Vue.js",
"main": "main.js",
"author": "BC Public Services",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
async setNewExaminer() {
console.log('Calling the set new examiner function-->setNewExaminer')
this.examinerDisplay = this.$store.getters.examiner
if (this.examinerDisplay.includes('account')) {
if (this.examinerDisplay && this.examinerDisplay.includes('account')) {
// fetch transactions
this.$store.commit('setPendingTransactionsRequest', true)
await this.$store.dispatch('getTransactionsHistory', this.nrNumber)
Expand Down
5 changes: 0 additions & 5 deletions client/src/components/application/NameExamination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@
$("#exact-history-match-banner").addClass("alert alert-danger");
else if (val == 'APPROVED')
$("#exact-history-match-banner").addClass("alert alert-warning");
},
auth: {
handler(selection) {
if (auth != true) { this.$router.push("/Signin") }
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/application/sections/StdHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@

<script>
/* eslint-disable */

import { formatNrNum } from '@/utils/utils.js'

export default {
name: "std-header",
data () {
Expand Down Expand Up @@ -151,10 +154,7 @@
},
submit() {
if (this.nrNum) {
let match = /(?:\s+|\s|)(\D|\D+|)(?:\s+|\s|)(\d+)(?:\s+|\s|)/
let rtnNR = () => ( 'NR ' )

let search = this.nrNum.replace(match, rtnNR('$1') + '$2')
let search = formatNrNum(this.nrNum)
if (search) {
let payload = {
search,
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/auth/Signin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
const ALLOWED_ROLES = [EXAMINER, STAFF, VIEWER]

if (!authorized) {
//keycloak = Keycloak('static/keycloak/sbcKey.json');
keycloak = Keycloak('static/keycloak/keycloak.json');
this.$store.commit('saveKeyCloak', keycloak);

var token
const vm = this

keycloak.init({token: token, onLoad: 'login-required'}).success(function (authenticated) {
if (authenticated) {

sessionStorage.setItem('KEYCLOAK_TOKEN', keycloak.token);
sessionStorage.setItem('KEYCLOAK_REFRESH', keycloak.refreshToken);
sessionStorage.setItem('KEYCLOAK_EXPIRES', keycloak.tokenParsed.exp * 1000);
Expand All @@ -53,7 +50,8 @@

});
// everthing is good, re-direct to home page
vm.$router.push('/home')
const redirect = vm.$router.currentRoute.query.redirect || '/home'
vm.$router.push(redirect)
}

} else {
Expand Down
25 changes: 22 additions & 3 deletions client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Vue from 'vue'
import Router from 'vue-router'
import Vuex from 'vuex'
import store from '@/store'
import { formatNrNum } from '@/utils/utils.js'

const LandingPage = () => import(/* webpackChunkName: "home" */'@/components/LandingPage')
const Signin = () => import(/* webpackChunkName: "signin" */'@/components/auth/Signin')
Expand Down Expand Up @@ -35,9 +36,18 @@ let router = new Router({
{
name: 'nameexamination',
component: NameExamination,
path: '/nameExamination',
path: '/nameExamination/:param',
meta: {
requiresAuth: true
},
beforeEnter: (to, from, next) => {
if (from.path == '/') { // reload the page
next({
path: '/signin',
query: { redirect: to.fullPath},
})
}
next()
}
},
{
Expand Down Expand Up @@ -75,10 +85,19 @@ router.beforeResolve((to, from, next) => {
// if not Authenticated, redirect to login page.
let auth = sessionStorage.getItem('AUTHORIZED')
if (auth == 'true') {

if (to.name == 'nameexamination' && from.name == 'Signin' && to.params.param) {
const search = formatNrNum(to.params.param)
let payload = {
search,
router: to,
refresh: false
}
store.commit('nrNumber', search)
store.dispatch('getpostgrescompInfo', search)
store.dispatch('newNrNumber', payload)
}
next()
} else {

store.dispatch("checkError",{"message": "Not Authorized please login."});
next({
path: '/'
Expand Down
6 changes: 4 additions & 2 deletions client/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ export const actions = {
if (refresh) {
commit( 'showExaminationArea', false )
}
if ( router && router.currentRoute.path !== '/nameExamination' ) {
router.push( '/nameExamination' )
if ( router && router.currentRoute.name !== 'nameexamination') {
router.push( {name: 'nameexamination',
params: {param: search.replace(/\s/g, "")}
} )
}
dispatch( 'resetValues' ).then( () => {
commit( 'nrNumber', search )
Expand Down
6 changes: 6 additions & 0 deletions client/src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const formatNrNum = (nrNum) => {
const match = /(?:\s+|\s|)(\D|\D+|)(?:\s+|\s|)(\d+)(?:\s+|\s|)/;
const rtnNR = () => ('NR ');
return nrNum.replace(match, rtnNR('$1') + '$2');
};