Convert to TS - builds (#36)

Liberal use of any, but it builds now; on to actually implementing types...
This commit is contained in:
Daniel J. Summers 2019-11-21 21:15:00 -06:00
parent 7624ecf83c
commit e59472a683
8 changed files with 40 additions and 29 deletions

View File

@ -1 +0,0 @@
[{"tagName":"script","closeTag":true,"attributes":{"type":"text/javascript","src":"/js/chunk-vendors-legacy.fc4b9fd6.js"}},{"tagName":"script","closeTag":true,"attributes":{"type":"text/javascript","src":"/js/app-legacy.7e012dcd.js"}}]

View File

@ -23,6 +23,7 @@
"vuex": "^3.0.1"
},
"devDependencies": {
"@types/auth0-js": "^9.10.6",
"@typescript-eslint/eslint-plugin": "^2.8.0",
"@typescript-eslint/parser": "^2.8.0",
"@vue/cli-plugin-babel": "^4.0.5",

View File

@ -1,7 +1,7 @@
'use strict'
/* eslint-disable */
import auth0 from 'auth0-js'
import EventEmitter from 'events'
import auth0 from 'auth0-js'
import { EventEmitter } from 'events'
import AUTH_CONFIG from './auth0-variables'
import mutations from '@/store/mutation-types'
@ -26,7 +26,7 @@ class AuthService extends EventEmitter {
AUTH_SESSION = 'auth-session'
// Received and calculated values for our ssesion (initially loaded from local storage if present)
session = {}
session: any = {}
constructor() {
super()
@ -64,7 +64,7 @@ class AuthService extends EventEmitter {
*/
async handleAuthentication (store) {
try {
const authResult = await this.parseHash()
const authResult: any = await this.parseHash()
if (authResult && authResult.accessToken && authResult.idToken) {
this.setSession(authResult)
store.commit(mutations.USER_LOGGED_ON, this.session.profile)
@ -102,7 +102,7 @@ class AuthService extends EventEmitter {
refreshSession () {
this.session =
localStorage.getItem(this.AUTH_SESSION)
? JSON.parse(localStorage.getItem(this.AUTH_SESSION))
? JSON.parse(localStorage.getItem(this.AUTH_SESSION) || '{}')
: { profile: {},
id: {
token: null,
@ -182,7 +182,7 @@ class AuthService extends EventEmitter {
return this.session.access.token
} else {
try {
const authResult = await this.renewTokens()
const authResult: any = await this.renewTokens()
return authResult.accessToken
} catch (reject) {
throw reject

View File

@ -21,11 +21,11 @@ import { MdApp,
MdTooltip } from 'vue-material/dist/components'
// myPrayerJournal components
import App from './App'
import App from './App.vue'
import router from './router'
import store from './store'
import DateFromNow from './components/common/DateFromNow'
import PageTitle from './components/common/PageTitle'
import DateFromNow from './components/common/DateFromNow.vue'
import PageTitle from './components/common/PageTitle.vue'
import AuthPlugin from './plugins/auth'
/* eslint-enable */

View File

@ -5,12 +5,12 @@ import Vue from 'vue'
import Router from 'vue-router'
import auth from './auth/AuthService'
import Home from '@/components/Home'
import Home from '@/components/Home.vue'
/* eslint-enable */
Vue.use(Router)
export default new Router({
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
scrollBehavior (to, from, savedPosition) {
@ -20,12 +20,6 @@ export default new Router({
return { x: 0, y: 0 }
}
},
beforeEach (to, from, next) {
if (to.path === '/' || to.path === '/user/log-on' || auth.isAuthenticated()) {
return next()
}
auth.login({ target: to.path })
},
routes: [
{
path: '/',
@ -35,49 +29,58 @@ export default new Router({
{
path: '/journal',
name: 'Journal',
component: () => import('@/components/Journal')
component: () => import('@/components/Journal.vue')
},
{
path: '/legal/privacy-policy',
name: 'PrivacyPolicy',
component: () => import('@/components/legal/PrivacyPolicy')
component: () => import('@/components/legal/PrivacyPolicy.vue')
},
{
path: '/legal/terms-of-service',
name: 'TermsOfService',
component: () => import('@/components/legal/TermsOfService')
component: () => import('@/components/legal/TermsOfService.vue')
},
{
path: '/request/:id/edit',
name: 'EditRequest',
component: () => import('@/components/request/EditRequest'),
component: () => import('@/components/request/EditRequest.vue'),
props: true
},
{
path: '/request/:id/full',
name: 'FullRequest',
component: () => import('@/components/request/FullRequest'),
component: () => import('@/components/request/FullRequest.vue'),
props: true
},
{
path: '/requests/active',
name: 'ActiveRequests',
component: () => import('@/components/request/ActiveRequests')
component: () => import('@/components/request/ActiveRequests.vue')
},
{
path: '/requests/answered',
name: 'AnsweredRequests',
component: () => import('@/components/request/AnsweredRequests')
component: () => import('@/components/request/AnsweredRequests.vue')
},
{
path: '/requests/snoozed',
name: 'SnoozedRequests',
component: () => import('@/components/request/SnoozedRequests')
component: () => import('@/components/request/SnoozedRequests.vue')
},
{
path: '/user/log-on',
name: 'LogOn',
component: () => import('@/components/user/LogOn')
component: () => import('@/components/user/LogOn.vue')
}
]
})
router.beforeEach((to, from, next) => {
if (to.path === '/' || to.path === '/user/log-on' || auth.isAuthenticated()) {
return next()
}
auth.login({ target: to.path })
})
export default router

View File

@ -61,11 +61,13 @@ const sortValue = x => x.showAfter === 0 ? x.asOf : x.showAfter
*/
const journalSort = (a, b) => sortValue(a) - sortValue(b)
const emptyJournal: any = []
export default new Vuex.Store({
state: {
user: auth.session.profile,
isAuthenticated: auth.isAuthenticated(),
journal: [],
journal: emptyJournal,
isLoadingJournal: false
},
mutations: {
@ -137,7 +139,7 @@ export default new Vuex.Store({
progress.$emit('show', 'indeterminate')
try {
await setBearer()
const oldReq = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {}
const oldReq: any = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {}
if (!(status === 'Prayed' && updateText === '')) {
if (status !== 'Answered' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) {
await api.updateRecurrence(requestId, recurType, recurCount)

View File

@ -9,6 +9,7 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noImplicitAny": false,
"baseUrl": ".",
"types": [
"webpack-env"

View File

@ -781,6 +781,11 @@
error-stack-parser "^2.0.0"
string-width "^2.0.0"
"@types/auth0-js@^9.10.6":
version "9.10.6"
resolved "https://registry.yarnpkg.com/@types/auth0-js/-/auth0-js-9.10.6.tgz#9782ac28ea9cff5a2594b780fd3fd0caa615d1e6"
integrity sha512-tPdhjqzQRJOdILFLssr/zrinjNvYsKKrEzS74XK80ZkQJKejjTERbIh3+T5niFKxx3XYPB3140ys8Y4Q2UFwHw==
"@types/babel-types@*", "@types/babel-types@^7.0.0":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/babel-types/-/babel-types-7.0.7.tgz#667eb1640e8039436028055737d2b9986ee336e3"