Fix: Make thread_id nullable

This commit is contained in:
gpt-engineer-app[bot]
2025-10-28 18:01:00 +00:00
parent c42b34b327
commit 1cc137da96
3 changed files with 25 additions and 7 deletions

View File

@@ -244,11 +244,11 @@ export function ContactForm() {
{/* Message */}
<div className="space-y-2">
<Label htmlFor="message">Message *</Label>
<Label htmlFor="message">Message * (minimum 20 characters)</Label>
<Textarea
id="message"
{...register('message')}
placeholder="Please provide details about your inquiry..."
placeholder="Please provide details about your inquiry (minimum 20 characters)..."
rows={6}
disabled={isSubmitting}
className={errors.message ? 'border-destructive' : ''}
@@ -257,8 +257,15 @@ export function ContactForm() {
{errors.message && (
<p className="text-sm text-destructive">{errors.message.message}</p>
)}
<p className="text-sm text-muted-foreground ml-auto">
<p className={`text-sm ml-auto ${
(watch('message')?.length || 0) < 20
? 'text-destructive font-medium'
: 'text-muted-foreground'
}`}>
{watch('message')?.length || 0} / 2000
{(watch('message')?.length || 0) < 20 &&
` (${20 - (watch('message')?.length || 0)} more needed)`
}
</p>
</div>
</div>
@@ -284,8 +291,15 @@ export function ContactForm() {
<Button
type="submit"
size="lg"
disabled={isSubmitting || !captchaToken}
disabled={isSubmitting || !captchaToken || (watch('message')?.length || 0) < 20}
className="w-full"
title={
!captchaToken
? 'Please complete the CAPTCHA'
: (watch('message')?.length || 0) < 20
? `Message must be at least 20 characters (currently ${watch('message')?.length || 0})`
: ''
}
>
{isSubmitting ? (
<>

View File

@@ -538,7 +538,7 @@ export type Database = {
response_count: number | null
status: string
subject: string
thread_id: string
thread_id: string | null
updated_at: string
user_agent: string | null
user_id: string | null
@@ -559,7 +559,7 @@ export type Database = {
response_count?: number | null
status?: string
subject: string
thread_id: string
thread_id?: string | null
updated_at?: string
user_agent?: string | null
user_id?: string | null
@@ -580,7 +580,7 @@ export type Database = {
response_count?: number | null
status?: string
subject?: string
thread_id?: string
thread_id?: string | null
updated_at?: string
user_agent?: string | null
user_id?: string | null

View File

@@ -0,0 +1,4 @@
-- Make thread_id nullable in contact_submissions table
-- Contact submissions don't have a thread until an admin replies
ALTER TABLE public.contact_submissions
ALTER COLUMN thread_id DROP NOT NULL;