preparing landing page

This commit is contained in:
balzack 2024-07-31 16:34:19 +02:00
parent 5f3ad8ed25
commit bb83b87cb3
2 changed files with 27 additions and 25 deletions

View File

@ -0,0 +1,24 @@
import { WebStore } from 'databag-client-sdk'
export class SessionStore implements WebStore {
public async getValue (key: string): Promise<any> {
console.log('web store get: ', key)
const value = localStorage.getItem(key)
if (!value) {
return null
}
return JSON.parse(value)
}
public async setValue (key: string, value: any): Promise<void> {
localStorage.setItem(key, JSON.stringify(value))
}
public async clearValue (key: string): Promise<void> {
localStorage.removeItem(key)
}
public async clearAll (): Promise<void> {
localStorage.clear()
}
}

View File

@ -1,28 +1,6 @@
import { useState, useEffect } from 'react'
import { DatabagSDK, WebStore, Session } from 'databag-client-sdk'
class Store implements WebStore {
public async getValue (key: string): Promise<any> {
console.log('web store get: ', key)
const value = localStorage.getItem(key)
if (!value) {
return null
}
return JSON.parse(value)
}
public async setValue (key: string, value: any): Promise<void> {
localStorage.setItem(key, JSON.stringify(value))
}
public async clearValue (key: string): Promise<void> {
localStorage.removeItem(key)
}
public async clearAll (): Promise<void> {
localStorage.clear()
}
};
import { DatabagSDK, Session } from 'databag-client-sdk'
import { SessionStore } from '../SessionStore'
export function useAppContext () {
const [state, setState] = useState({})
@ -38,7 +16,7 @@ export function useAppContext () {
const init = async () => {
const sdk = new DatabagSDK(null)
const store = new Store()
const store = new SessionStore()
const session: Session | null = await sdk.initOnlineStore(store)
console.log(session)
if (session) {