Commit 0dfa1735 authored by Will Binns-Smith's avatar Will Binns-Smith

fixup! feat: add GitHub Discussion Router app

parent 3b97df09
'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { Search } from 'lucide-react'
export function SearchForm() {
const router = useRouter()
const [title, setTitle] = useState('')
const [description, setDescription] = useState('')
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault()
if (!title.trim()) return
const params = new URLSearchParams({
title: title.trim(),
})
if (description.trim()) {
params.set('description', description.trim())
}
router.push(`/search?${params.toString()}`)
}
return (
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-2">
<label
htmlFor="title"
className="block text-sm font-medium text-foreground"
>
Discussion Title *
</label>
<input
id="title"
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Enter discussion title..."
required
className="w-full px-4 py-2 border border-input rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring"
/>
</div>
<div className="space-y-2">
<label
htmlFor="description"
className="block text-sm font-medium text-foreground"
>
Description (optional)
</label>
<textarea
id="description"
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="Enter description..."
rows={4}
className="w-full px-4 py-2 border border-input rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring resize-none"
/>
</div>
<Button type="submit" className="w-full" disabled={!title.trim()}>
<Search className="mr-2 h-4 w-4" />
Search Discussions
</Button>
</form>
)
}
...@@ -18,27 +18,11 @@ const envSchema = z.object({ ...@@ -18,27 +18,11 @@ const envSchema = z.object({
.pipe(z.number().positive()), .pipe(z.number().positive()),
}) })
let cachedEnv: z.infer<typeof envSchema> | null = null export const env = Object.freeze(
envSchema.parse({
function getEnv() {
if (cachedEnv) {
return cachedEnv
}
cachedEnv = envSchema.parse({
GITHUB_TOKEN: process.env.GITHUB_TOKEN, GITHUB_TOKEN: process.env.GITHUB_TOKEN,
GITHUB_REPO: process.env.GITHUB_REPO, GITHUB_REPO: process.env.GITHUB_REPO,
SIMILARITY_THRESHOLD: process.env.SIMILARITY_THRESHOLD, SIMILARITY_THRESHOLD: process.env.SIMILARITY_THRESHOLD,
MAX_DISCUSSIONS_TO_FETCH: process.env.MAX_DISCUSSIONS_TO_FETCH, MAX_DISCUSSIONS_TO_FETCH: process.env.MAX_DISCUSSIONS_TO_FETCH,
}) })
)
return cachedEnv
}
export const env = new Proxy({} as z.infer<typeof envSchema>, {
get(_target, prop) {
return getEnv()[prop as keyof z.infer<typeof envSchema>]
},
})
export type Env = z.infer<typeof envSchema>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment