Refactor project structure and integrate Redux for state management. Update configuration files for new project name and add Webpack plugins for environment variables. Implement user authentication with Keycloak and create a context for challenge management. Add various components for user interaction, including dashboards and task workspaces. Enhance API integration and add error handling utilities. Introduce analytics and polling mechanisms for improved user experience.
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const STORAGE_PREFIX = 'challenge_draft_'
|
||||
|
||||
const isBrowser = () => typeof window !== 'undefined' && typeof window.localStorage !== 'undefined'
|
||||
|
||||
export function saveDraft(taskId: string, result: string) {
|
||||
if (!isBrowser()) return
|
||||
window.localStorage.setItem(`${STORAGE_PREFIX}${taskId}`, result)
|
||||
}
|
||||
|
||||
export function loadDraft(taskId: string): string | null {
|
||||
if (!isBrowser()) return null
|
||||
return window.localStorage.getItem(`${STORAGE_PREFIX}${taskId}`)
|
||||
}
|
||||
|
||||
export function clearDraft(taskId: string) {
|
||||
if (!isBrowser()) return
|
||||
window.localStorage.removeItem(`${STORAGE_PREFIX}${taskId}`)
|
||||
}
|
||||
|
||||
export function listDrafts() {
|
||||
if (!isBrowser()) return [] as string[]
|
||||
|
||||
const keys = [] as string[]
|
||||
for (let i = 0; i < window.localStorage.length; i += 1) {
|
||||
const key = window.localStorage.key(i)
|
||||
if (key?.startsWith(STORAGE_PREFIX)) {
|
||||
keys.push(key.replace(STORAGE_PREFIX, ''))
|
||||
}
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user