Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 1x 8x 8x 8x 8x 8x 6x | import { Input } from '@core/components/ui/input'
import { Label } from '@core/components/ui/label'
import { Textarea } from '@core/components/ui/textarea'
import { Checkbox } from '@core/components/ui/checkbox'
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@core/components/ui/card'
import { useFormContext, useWatch } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { ReceiptForm } from './ReceiptForm'
export const CommunicationForm = () => {
const { t } = useTranslation()
const { register, setValue, control } = useFormContext() // Added control back if needed elsewhere, though mostly used in sub-forms
const sharingEnabled = useWatch({ control, name: 'sharing.enabled' })
const networks = useWatch({ control, name: 'sharing.networks' }) || []
return (
<div className="space-y-6">
{/* Contact Points */}
<Card
style={{
backgroundColor: 'var(--admin-card-bg)',
borderColor: 'var(--admin-border-color)',
}}
>
<CardHeader>
<CardTitle>{t('admin_branding.communication.contact.title')}</CardTitle>
<CardDescription>
{t('admin_branding.communication.contact.description')}
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="grid gap-2">
<Label htmlFor="email">
{t('admin_branding.communication.contact.email')}
</Label>
<Input
id="email"
{...register('email')}
placeholder={t(
'admin_branding.communication.contact.email_placeholder',
)}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="phone">
{t('admin_branding.communication.contact.phone')}
</Label>
<Input
id="phone"
{...register('phone')}
placeholder={t(
'admin_branding.communication.contact.phone_placeholder',
)}
/>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="grid gap-2">
<Label>{t('admin_branding.communication.contact.tax_id')}</Label>
<Input
{...register('taxId')}
placeholder={t(
'admin_branding.communication.contact.tax_id_placeholder',
)}
/>
</div>
<div className="grid gap-2">
<Label>
{t('admin_branding.communication.contact.signature_text')}
</Label>
<Input
{...register('signatureText')}
placeholder={t(
'admin_branding.communication.contact.signature_text_placeholder',
)}
/>
</div>
</div>
<div className="grid gap-2">
<Label>{t('admin_branding.communication.contact.signature_image')}</Label>
<Input
{...register('signatureImage')}
placeholder={t(
'admin_branding.communication.contact.signature_image_placeholder',
)}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="address">
{t('admin_branding.communication.contact.address')}
</Label>
<Textarea id="address" {...register('address')} rows={3} />
</div>
</CardContent>
</Card>
{/* Receipt & Notifications */}
<ReceiptForm />
{/* Social Sharing Configuration */}
<Card
style={{
backgroundColor: 'var(--admin-card-bg)',
borderColor: 'var(--admin-border-color)',
}}
>
<CardHeader>
<div className="flex items-center justify-between">
<CardTitle>{t('admin_branding.communication.sharing.title')}</CardTitle>
<div className="flex items-center space-x-2">
<Checkbox
id="sharingEnabled"
checked={sharingEnabled}
onCheckedChange={(checked: boolean) =>
setValue('sharing.enabled', checked === true)
}
/>
<label htmlFor="sharingEnabled" className="text-sm font-medium">
{t('admin_branding.communication.sharing.enable')}
</label>
</div>
</div>
<CardDescription>
{t('admin_branding.communication.sharing.description')}
</CardDescription>
</CardHeader>
{sharingEnabled && (
<CardContent className="space-y-4">
<Label>{t('admin_branding.communication.sharing.networks')}</Label>
<div className="flex flex-col gap-2">
{['facebook', 'twitter', 'linkedin'].map((network) => (
<div key={network} className="flex items-center space-x-2">
<Checkbox
id={`network-${network}`}
checked={networks.includes(network)}
onCheckedChange={(checked: boolean) => {
const isChecked = checked === true
const newNetworks = isChecked
? [...networks, network]
: networks.filter((n: string) => n !== network)
setValue('sharing.networks', newNetworks)
}}
/>
<Label htmlFor={`network-${network}`}>
{t(`admin_branding.communication.sharing.${network}`)}
</Label>
</div>
))}
</div>
</CardContent>
)}
</Card>
</div>
)
}
|