We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentaad32f3 commit23082a4Copy full SHA for 23082a4
src/environment.ts
@@ -11,7 +11,7 @@ export type Env = 'test' | 'local' | 'development' | 'production'
11
exportconstNODE_ENV:Env=process.env.NODE_ENV||'development'
12
13
// toggle logging in development
14
-exportconstLOG=true
+exportconstLOG=false
15
16
// error logging tool
17
exportconstINSTRUMENTATION_KEY='6ff37c76-72f3-48e3-a1b9-d5636f519b7b'
web-app/src/Routes.tsx
@@ -21,6 +21,7 @@ const Routes = () => {
21
}
22
23
logger(`ROUTE:${route}`)
24
+logger(`POSITION:${JSON.stringify(context.position)}`)
25
26
return(
27
<Routerroute={route}>
web-app/src/environment.ts
@@ -1,10 +1,10 @@
1
// validate .env
2
-constrequiredKeys=['REACT_APP_TUTORIAL_LIST_URL']
3
-for(constrequiredofrequiredKeys){
4
-if(!process.env[required]){
5
-thrownewError(`Missing Environmental Variable:${required}`)
6
-}
7
+//const requiredKeys = ['REACT_APP_TUTORIAL_LIST_URL']
+//for (const required of requiredKeys) {
+// if (!process.env[required]) {
+// throw new Error(`Missing Environmental Variable: ${required}`)
+// }
+//}
8
9
exportconstDEBUG:boolean=(process.env.REACT_APP_DEBUG||'').toLowerCase()==='true'
10
exportconstVERSION:string=process.env.VERSION||'unknown'
web-app/src/services/logger/index.ts
@@ -1,6 +1,6 @@
import{LOG}from'../../environment'
-exporttypeLog=string|object|null
+exporttypeLog=string|object|number|null
constlogger=(...messages:Log[]):void=>{
if(!LOG){
web-app/src/services/state/actions/context.ts
@@ -4,6 +4,7 @@ import { assign, send } from 'xstate'
import*asselectorsfrom'../../selectors'
importgetStepNextfrom'./utils/stepNext'
importgetNextfrom'./utils/getNext'
+importloggerfrom'services/logger'
exportconstsetStart=assign({
env:(context:T.MachineContext,event:T.MachineEvent)=>{
@@ -34,6 +35,7 @@ export const initPosition = assign({
34
35
36
exportconstupdateStepPosition=assign({
37
position:(context:T.MachineContext,event:T.MachineEvent):any=>{
38
+logger('updateStepPosition',event)
39
returnevent.payload.position
40
},
41
})
@@ -54,8 +56,6 @@ export const loadNext = send(
54
56
exportconststepNext=send(
55
57
(context:T.MachineContext):T.Action=>{
58
constlevel:TT.Level=selectors.currentLevel(context)
-console.log(`STEP_NEXT:${JSON.stringify(context.position)}`)
-console.log(`STEP NEXT LEVEL${JSON.stringify(level)}`)
59
returngetStepNext(context.position,level)
60
61
)
web-app/src/services/state/actions/utils/stepNext.test.ts
@@ -26,7 +26,17 @@ const level: TT.Level = {
28
describe('stepNext',()=>{
29
-it('should LOAD_NEXT_STEP when there is another step',()=>{
+it('should LOAD_NEXT_STEP when there is another step (1)',()=>{
30
+constposition={levelId:'1',stepId:'1.1',complete:true}
31
+constresult=getStepNext(position,level)
32
+expect(result).toEqual({
33
+type:'LOAD_NEXT_STEP',
+payload:{
+step:level.steps[1],
+},
+})
+it('should LOAD_NEXT_STEP when there is another step (2)',()=>{
constposition={levelId:'1',stepId:'1.2',complete:false}
constresult=getStepNext(position,level)
42
expect(result).toEqual({
@@ -36,7 +46,6 @@ describe('stepNext', () => {
46
47
48
-
49
it('should LEVEL_COMPLETE when there are no steps',()=>{
50
constposition={levelId:'1',stepId:null,complete:false}
51
constresult=getStepNext(position,{ ...level,steps:[]})
web-app/src/services/state/actions/utils/stepNext.ts
@@ -3,9 +3,7 @@ import * as TT from 'typings/tutorial'
importloggerfrom'../../../../services/logger'
constgetStepNext=(position:T.Position,level:TT.Level):T.Action=>{
-logger('getStepNext position',position)
const{ steps}=level
if(steps.length){
conststepIndex=steps.findIndex((s:TT.Step)=>s.id===position.stepId)
constfinalStepIndex=steps.length-1
@@ -14,7 +12,7 @@ const getStepNext = (position: T.Position, level: TT.Level): T.Action => {
return{
type:'LOAD_NEXT_STEP',
payload:{
-step:nextStep,
+position:{levelId:position.levelId,stepId:nextStep.id,complete:false},
18
19
20
web-app/src/services/state/machine.ts
@@ -198,7 +198,7 @@ export const createMachine = (options: any) => {
198
on:{
199
LOAD_NEXT_STEP:{
200
target:'Normal',
201
-actions:['loadStep'],
+actions:['loadStep','updateStepPosition'],
202
203
LEVEL_COMPLETE:'LevelComplete',
204