-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps(SPV-1286): update eslint and fix errors
- Loading branch information
1 parent
cd6bec0
commit 4b2c41b
Showing
16 changed files
with
517 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
export * from './form.tsx'; | ||
export * from './use-form-field.tsx'; | ||
export * from './form-item.tsx'; | ||
export * from './form-item-context.tsx'; | ||
export * from './form-label.tsx'; | ||
export * from './form-message.tsx'; | ||
export * from './form-field.tsx'; | ||
export * from './form-field-context.tsx'; | ||
export * from './form-control.tsx'; | ||
export * from './form-description.tsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { useState } from 'react'; | ||
import { AuthContext, Role, useSpvWalletClient } from '@/contexts'; | ||
|
||
export const AuthProvider = ({ children }: { children: React.ReactNode }) => { | ||
const { spvWalletClient } = useSpvWalletClient(); | ||
|
||
const [loginKey, setLoginKey] = useState<string>(''); | ||
const isAuthenticated = !!spvWalletClient; | ||
|
||
const isAdmin = isAuthenticated && spvWalletClient?.role === Role.Admin; | ||
const isUser = isAuthenticated && spvWalletClient?.role === Role.User; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ isAdmin, isAuthenticated, loginKey, setLoginKey, isUser }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './AuthContext.tsx'; | ||
export * from './AuthProvider.tsx'; | ||
export * from './types.ts'; | ||
export * from './useAuth.tsx'; | ||
export * from './useServerUrl.tsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { SpvWalletClientExtended, SpvWalletContext, useServerUrl } from '@/contexts'; | ||
import React, { useMemo, useState } from 'react'; | ||
|
||
export const SpvWalletProvider = ({ children }: { children: React.ReactNode }) => { | ||
const { serverUrl, setServerUrl } = useServerUrl(); | ||
|
||
const [spvWalletClient, setSpvWalletClient] = useState<SpvWalletClientExtended | null>(null); | ||
|
||
const contextValue = useMemo( | ||
() => ({ | ||
serverUrl, | ||
setServerUrl, | ||
spvWalletClient, | ||
setSpvWalletClient, | ||
}), | ||
[serverUrl, setServerUrl, spvWalletClient, setSpvWalletClient], | ||
); | ||
return <SpvWalletContext.Provider value={contextValue}>{children}</SpvWalletContext.Provider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './SpvWalletContext.tsx'; | ||
export * from './SpvWalletProvider.tsx'; | ||
export * from './useSpvWalletClient.tsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Theme, ThemeProviderContext } from './ThemeProviderContext'; | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
type ThemeProviderProps = { | ||
children: React.ReactNode; | ||
defaultTheme?: Theme; | ||
storageKey?: string; | ||
}; | ||
|
||
export function ThemeProvider({ | ||
children, | ||
defaultTheme = 'system', | ||
storageKey = 'vite-ui-theme', | ||
...props | ||
}: ThemeProviderProps) { | ||
const [theme, setTheme] = useState<Theme>(() => (localStorage.getItem(storageKey) as Theme) || defaultTheme); | ||
|
||
useEffect(() => { | ||
const root = window.document.documentElement; | ||
|
||
root.classList.remove('light', 'dark'); | ||
|
||
if (theme === 'system') { | ||
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | ||
|
||
root.classList.add(systemTheme); | ||
return; | ||
} | ||
|
||
root.classList.add(theme); | ||
}, [theme]); | ||
|
||
const value = { | ||
theme, | ||
setTheme: (theme: Theme) => { | ||
localStorage.setItem(storageKey, theme); | ||
setTheme(theme); | ||
}, | ||
}; | ||
|
||
return ( | ||
<ThemeProviderContext.Provider {...props} value={value}> | ||
{children} | ||
</ThemeProviderContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './ThemeProviderContext.tsx'; | ||
export * from './ThemeProvider.tsx'; | ||
export * from './useTheme.tsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.