|
168 | 168 | await syncTutorialsTodos() |
169 | 169 | } |
170 | 170 |
|
171 | | - // Reset a single tutorial |
172 | | - async function resetSingleTutorial(tutorialId: string) { |
| 171 | + // Update a single tutorial's completion status |
| 172 | + async function updateSingleTutorial(tutorialId: string, completed: boolean) { |
173 | 173 | const tutorial = currentTabConfig.tutorials.find((t) => t.id === tutorialId) |
174 | 174 | if (!tutorial || tutorial.index === undefined) { |
175 | 175 | console.warn(`Tutorial not found or has no index: ${tutorialId}`) |
176 | 176 | return |
177 | 177 | } |
178 | 178 |
|
179 | 179 | try { |
180 | | - await resetTutorialByIndex(tutorial.index) |
181 | | - await syncTutorialsTodos() |
182 | | - } catch (error) { |
183 | | - console.error('Error resetting tutorial:', error) |
184 | | - } |
185 | | - } |
186 | | -
|
187 | | - // Mark a single tutorial as completed |
188 | | - async function completeSingleTutorial(tutorialId: string) { |
189 | | - const tutorial = currentTabConfig.tutorials.find((t) => t.id === tutorialId) |
190 | | - if (!tutorial || tutorial.index === undefined) { |
191 | | - console.warn(`Tutorial not found or has no index: ${tutorialId}`) |
192 | | - return |
193 | | - } |
194 | | -
|
195 | | - try { |
196 | | - await completeTutorialByIndex(tutorial.index) |
| 180 | + if (completed) { |
| 181 | + await completeTutorialByIndex(tutorial.index) |
| 182 | + } else { |
| 183 | + await resetTutorialByIndex(tutorial.index) |
| 184 | + } |
197 | 185 | await syncTutorialsTodos() |
198 | 186 | } catch (error) { |
199 | | - console.error('Error completing tutorial:', error) |
| 187 | + console.error(`Error ${completed ? 'completing' : 'resetting'} tutorial:`, error) |
200 | 188 | } |
201 | 189 | } |
202 | 190 |
|
|
391 | 379 | isCompleted={isTutorialCompleted(tutorial.id)} |
392 | 380 | disabled={tutorial.active === false} |
393 | 381 | comingSoon={tutorial.comingSoon} |
394 | | - onReset={() => resetSingleTutorial(tutorial.id)} |
395 | | - onComplete={() => completeSingleTutorial(tutorial.id)} |
| 382 | + onReset={() => updateSingleTutorial(tutorial.id, false)} |
| 383 | + onComplete={() => updateSingleTutorial(tutorial.id, true)} |
396 | 384 | /> |
397 | 385 | {/each} |
398 | 386 | </div> |
|
0 commit comments