Skip to content

Reset whole tutorial #513

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

Merged
merged 4 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reset to Level 1 step 1
Signed-off-by: Shubham Shah <shubhamshahrising@gmail.com>
  • Loading branch information
SavvyShah committed Sep 28, 2021
commit 640f4135508ea9ab7a2f58b637ef35ec9798493e
17 changes: 3 additions & 14 deletions web-app/src/containers/Tutorial/containers/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Button from 'components/Button'
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { Theme } from '../../../styles/theme'
import Reset from '../components/Reset'

Expand Down Expand Up @@ -46,21 +46,10 @@ const styles = {
}

interface Props {
levels: T.LevelUI[]
onResetToPosition(position: T.Position): void
onReset(): void
}

const SettingsPage = (props: Props) => {
const onReset = () => {
const level: T.LevelUI | null = props.levels.length ? props.levels[0] : null
if (level) {
props.onResetToPosition({
levelId: level.id,
stepId: null,
complete: false,
})
}
}
return (
<div css={styles.container}>
<div css={styles.header}>
Expand All @@ -78,7 +67,7 @@ const SettingsPage = (props: Props) => {
level and first task checkpoint.
</div>
</div>
<Reset style={styles.menuItemButton} warning onReset={onReset} />
<Reset style={styles.menuItemButton} warning onReset={props.onReset} />
</div>
</div>
</div>
Expand Down
16 changes: 14 additions & 2 deletions web-app/src/containers/Tutorial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,25 @@ const TutorialPage = (props: PageProps) => {

const [page, setPage] = React.useState<'about' | 'level' | 'review' | 'settings'>('level')

const onSettingsReset = () => {
//Reset to first level first step
const level: T.LevelUI | null = levels.length ? levels[1] : null
if (level) {
onResetToPosition({
levelId: level.id,
stepId: level.steps.length ? level.steps[0].id : null,
complete: false,
})
setPage('level')
}
}
// format level code with status for easy rendering
const { level, levels, levelIndex, stepIndex } = formatLevels({
position,
levels: tutorial.levels,
testStatus,
})
console.log({ position })

const disableOptions = processes.length > 0 || props.state === 'Level.TestRunning'

return (
Expand All @@ -156,7 +168,7 @@ const TutorialPage = (props: PageProps) => {
)}
{page === 'review' && <ReviewPage levels={levels} onResetToPosition={onResetToPosition} />}

{page === 'settings' && <SettingsPage levels={levels} onResetToPosition={onResetToPosition} />}
{page === 'settings' && <SettingsPage onReset={onSettingsReset} />}
</div>

{props.state === 'Completed' ? (
Expand Down
2 changes: 1 addition & 1 deletion web-app/stories/Settings.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import Settings from '../src/containers/Tutorial/containers/Settings'
storiesOf('Settings', module)
.addDecorator(SideBarDecorator)
.add('Settings Page', () => {
return <Settings />
return <Settings onReset={() => console.log('Reset...')} />
})