mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 15:49:09 +03:00
* Add pooling mode dropdown to toggle between ports * Fix * Default pooling mode to the one thats configured * Update based on feedback * Fix * Update pooling modes modal copy * Small update * Small copy update * Small copy update * Another one * One final one
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { PropsWithChildren, createContext, useContext } from 'react'
|
|
import { proxy, useSnapshot } from 'valtio'
|
|
|
|
import { useConstant } from 'common'
|
|
|
|
export function createDatabaseSettingsState() {
|
|
const state = proxy({
|
|
showPoolingModeHelper: false,
|
|
setShowPoolingModeHelper: (value: boolean) => {
|
|
state.showPoolingModeHelper = value
|
|
},
|
|
})
|
|
|
|
return state
|
|
}
|
|
|
|
export type DatabaseSettingsState = ReturnType<typeof createDatabaseSettingsState>
|
|
|
|
export const DatabaseSettingsStateContext = createContext<DatabaseSettingsState>(
|
|
createDatabaseSettingsState()
|
|
)
|
|
|
|
export const DatabaseSettingsStateContextProvider = ({ children }: PropsWithChildren) => {
|
|
const state = useConstant(createDatabaseSettingsState)
|
|
|
|
return (
|
|
<DatabaseSettingsStateContext.Provider value={state}>
|
|
{children}
|
|
</DatabaseSettingsStateContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useDatabaseSettingsStateSnapshot(options?: Parameters<typeof useSnapshot>[1]) {
|
|
const state = useContext(DatabaseSettingsStateContext)
|
|
return useSnapshot(state, options)
|
|
}
|