Enhance task navigation and progress tracking across components. Update TaskWorkspace to improve task completion handling and button interactions. Refactor ChainsPage to select the furthest accessible task based on user progress. Implement storage functions for managing furthest task indices, ensuring users can only navigate to available tasks. Update TaskPage to check task accessibility and redirect users appropriately, improving overall user experience.
Some checks failed
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
Some checks failed
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -14,6 +14,9 @@ export const STORAGE_KEYS = {
|
||||
SELECTED_TASK_ID: 'challengeSelectedTaskId',
|
||||
} as const
|
||||
|
||||
// Вспомогательная функция для ключа прогресса цепочки
|
||||
const getFurthestTaskKey = (chainId: string) => `challengeFurthestTask_${chainId}`
|
||||
|
||||
// Получение значений
|
||||
export const storage = {
|
||||
getUserId: (): string | null => {
|
||||
@@ -109,5 +112,28 @@ export const storage = {
|
||||
localStorage.removeItem(STORAGE_KEYS.SELECTED_CHAIN_ID)
|
||||
localStorage.removeItem(STORAGE_KEYS.SELECTED_TASK_ID)
|
||||
},
|
||||
|
||||
// Получение самого дальнего достигнутого индекса задания в цепочке
|
||||
getFurthestTaskIndex: (chainId: string): number => {
|
||||
if (!isBrowser()) return 0
|
||||
const value = localStorage.getItem(getFurthestTaskKey(chainId))
|
||||
return value ? parseInt(value, 10) : 0
|
||||
},
|
||||
|
||||
// Установка самого дальнего достигнутого индекса задания
|
||||
setFurthestTaskIndex: (chainId: string, index: number): void => {
|
||||
if (!isBrowser()) return
|
||||
const current = storage.getFurthestTaskIndex(chainId)
|
||||
// Обновляем только если новый индекс больше текущего
|
||||
if (index > current) {
|
||||
localStorage.setItem(getFurthestTaskKey(chainId), index.toString())
|
||||
}
|
||||
},
|
||||
|
||||
// Очистка прогресса цепочки
|
||||
clearChainProgress: (chainId: string): void => {
|
||||
if (!isBrowser()) return
|
||||
localStorage.removeItem(getFurthestTaskKey(chainId))
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user