mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Replace per-field Required labels with a consolidated validation summary above the save button
This commit is contained in:
1 file changed
+35
-28
@@ -422,31 +422,21 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) {
|
||||
|
||||
{/* Name & Description */}
|
||||
<div className="space-y-2">
|
||||
<div>
|
||||
<Input
|
||||
value={formData.name}
|
||||
onChange={e => updateField('name', e.target.value)}
|
||||
placeholder="App Name"
|
||||
disabled={isSaving}
|
||||
className={submitted && !formData.name.trim() ? 'border-destructive focus-visible:ring-destructive' : ''}
|
||||
/>
|
||||
{submitted && !formData.name.trim() && (
|
||||
<p className="text-xs text-destructive mt-1">Required</p>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<Textarea
|
||||
value={formData.about}
|
||||
onChange={e => updateField('about', e.target.value)}
|
||||
placeholder="A short description of your app..."
|
||||
rows={2}
|
||||
disabled={isSaving}
|
||||
className={`resize-none${submitted && !formData.about.trim() ? ' border-destructive focus-visible:ring-destructive' : ''}`}
|
||||
/>
|
||||
{submitted && !formData.about.trim() && (
|
||||
<p className="text-xs text-destructive mt-1">Required</p>
|
||||
)}
|
||||
</div>
|
||||
<Input
|
||||
value={formData.name}
|
||||
onChange={e => updateField('name', e.target.value)}
|
||||
placeholder="App Name"
|
||||
disabled={isSaving}
|
||||
className={submitted && !formData.name.trim() ? 'border-destructive focus-visible:ring-destructive' : ''}
|
||||
/>
|
||||
<Textarea
|
||||
value={formData.about}
|
||||
onChange={e => updateField('about', e.target.value)}
|
||||
placeholder="A short description of your app..."
|
||||
rows={2}
|
||||
disabled={isSaving}
|
||||
className={`resize-none${submitted && !formData.about.trim() ? ' border-destructive focus-visible:ring-destructive' : ''}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Website */}
|
||||
@@ -459,9 +449,6 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) {
|
||||
disabled={isSaving}
|
||||
className={`text-sm${submitted && !formData.website.trim() ? ' border-destructive focus-visible:ring-destructive' : ''}`}
|
||||
/>
|
||||
{submitted && !formData.website.trim() && (
|
||||
<p className="text-xs text-destructive mt-1">Required</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -610,6 +597,26 @@ export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) {
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
{/* Validation summary */}
|
||||
{submitted && (() => {
|
||||
const missing = [
|
||||
!formData.banner && 'banner',
|
||||
!formData.picture && 'icon',
|
||||
!formData.name.trim() && 'name',
|
||||
!formData.about.trim() && 'description',
|
||||
!formData.website.trim() && 'website',
|
||||
].filter(Boolean) as string[];
|
||||
if (!missing.length) return null;
|
||||
const list = missing.length === 1
|
||||
? missing[0]
|
||||
: missing.slice(0, -1).join(', ') + ' and ' + missing[missing.length - 1];
|
||||
return (
|
||||
<p className="text-sm text-destructive">
|
||||
Please add a {list} before publishing.
|
||||
</p>
|
||||
);
|
||||
})()}
|
||||
|
||||
{/* Save Button */}
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
|
||||
Reference in new issue
Block a user