Skip to content

Commit

Permalink
capture a 'token' value
Browse files Browse the repository at this point in the history
  • Loading branch information
jmonster committed Mar 9, 2023
1 parent 393d218 commit 64f90c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/react-ezql/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const TRIGGERS = ['KeyK', 'Slash']

function App() {
const [shouldDisplayEzql, setShouldDisplayEzql] = useState(false)
const [token, setToken] = useState<string>('')

const suggestions = ['How many books sold last week', 'How many new users signed up today']

// listen for the trigger to display the modal
Expand All @@ -27,12 +29,21 @@ function App() {

return (
<>
<p>
<p className="text-center text-gray-400 my-2">
Press <i>Command-K</i> to display EZQL, <i>Escape</i> to dismiss.
</p>

<p className='mx-2 flex items-center'>
<label>Token</label>
<input
className="bg-gray-50 rounded-sm ml-4 border border-gray-200 p-1 flex-1"
onChange={(event) => setToken(event.target.value)}
/>
</p>

{shouldDisplayEzql && (
<EzqlPrompt
token={token}
setShouldDisplayEzql={setShouldDisplayEzql}
suggestions={suggestions}
didSubmitWithValue={(value) => {
Expand Down
2 changes: 2 additions & 0 deletions src/react-ezql/src/components/ezql-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { classNames } from '../lib/class-names'
import styles from './ezql-prompt.module.css'

export type EzqlPromptOpts = {
token: string
setShouldDisplayEzql: (value: boolean) => void
onResults: (data: object) => void
didSubmitWithValue?: (query: string) => void
Expand All @@ -14,6 +15,7 @@ export type EzqlPromptOpts = {
}

export default function EzqlPrompt({
token,
setShouldDisplayEzql,
didSubmitWithValue,
onResults,
Expand Down

0 comments on commit 64f90c8

Please sign in to comment.