side-panels.ts23 lines · main
1import { proxy, snapshot, useSnapshot } from 'valtio'
2
3export type SidePanelTypeProps = 'VERCEL_CONNECTIONS' | 'GITHUB_CONNECTIONS'
4
5export const sidePanelsState = proxy({
6 /**
7 * Vercel connections
8 */
9 vercelConnectionsOpen: false as boolean,
10 setVercelConnectionsOpen: (bool: boolean) => {
11 sidePanelsState.vercelConnectionsOpen = bool
12 },
13 // ID to determine which vercel integration installation to use
14 vercelConnectionsIntegrationId: undefined as undefined | string,
15 setVercelConnectionsIntegrationId: (id: string) => {
16 sidePanelsState.vercelConnectionsIntegrationId = id
17 },
18})
19
20export const getSidePanelsState = () => snapshot(sidePanelsState)
21
22export const useSidePanelsStateSnapshot = (options?: Parameters<typeof useSnapshot>[1]) =>
23 useSnapshot(sidePanelsState, options)