mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-29 02:04:48 +08:00
32 lines
687 B
TypeScript
32 lines
687 B
TypeScript
import { create } from "zustand";
|
|
import { Connection, Database } from "@/types";
|
|
|
|
interface ExecuteQueryContext {
|
|
connection: Connection;
|
|
database?: Database;
|
|
statement: string;
|
|
}
|
|
|
|
interface QueryState {
|
|
context?: ExecuteQueryContext;
|
|
showDrawer: boolean;
|
|
toggleDrawer: (show?: boolean) => void;
|
|
setContext: (context: ExecuteQueryContext | undefined) => void;
|
|
}
|
|
|
|
export const useQueryStore = create<QueryState>()((set) => ({
|
|
showDrawer: false,
|
|
toggleDrawer: (show) => {
|
|
set((state) => ({
|
|
...state,
|
|
showDrawer: show ?? !state.showDrawer,
|
|
}));
|
|
},
|
|
setContext: (context) => {
|
|
set((state) => ({
|
|
...state,
|
|
context,
|
|
}));
|
|
},
|
|
}));
|