refactor: replace checked with defaultChecked for Switch components across multiple forms

This commit is contained in:
Marco Pedone 2026-02-24 10:40:07 +01:00
parent b5dcb5e8e1
commit 51d58a3008
10 changed files with 29 additions and 30 deletions

View file

@ -161,8 +161,8 @@ export const FormBanners = ({
<FormLabel htmlFor="unskippable">Non Saltabile</FormLabel> <FormLabel htmlFor="unskippable">Non Saltabile</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="unskippable" id="unskippable"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -181,8 +181,8 @@ export const FormBanners = ({
<FormLabel htmlFor="hcta">Ha Link</FormLabel> <FormLabel htmlFor="hcta">Ha Link</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="hcta" id="hcta"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -321,8 +321,8 @@ export const FormBanners = ({
<FormLabel htmlFor="attivo">Attivo</FormLabel> <FormLabel htmlFor="attivo">Attivo</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="attivo" id="attivo"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -341,8 +341,8 @@ export const FormBanners = ({
<FormLabel htmlFor="pub">Mostra nel pubblico</FormLabel> <FormLabel htmlFor="pub">Mostra nel pubblico</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="pub" id="pub"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -361,7 +361,6 @@ export const FormBanners = ({
<FormLabel htmlFor="priv">Mostra in area riservata</FormLabel> <FormLabel htmlFor="priv">Mostra in area riservata</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value} defaultChecked={field.value}
id="priv" id="priv"

View file

@ -187,7 +187,7 @@ export const FormContattoAnnucio = ({ codice }: { codice: string }) => {
<FormControl> <FormControl>
<Checkbox <Checkbox
checked={field.value} defaultChecked={field.value}
id="checkbox" id="checkbox"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -89,8 +89,8 @@ export const FormEditServizio = ({
<FormLabel htmlFor="isSent">Inviato</FormLabel> <FormLabel htmlFor="isSent">Inviato</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isSent" id="isSent"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -113,8 +113,8 @@ export const FormEditServizio = ({
<FormLabel htmlFor="isInterrotto">Interrotto</FormLabel> <FormLabel htmlFor="isInterrotto">Interrotto</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isInterrotto" id="isInterrotto"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -202,8 +202,8 @@ export const FormEditServizio = ({
<FormLabel htmlFor="isOkAcconto">Acconto Pagato</FormLabel> <FormLabel htmlFor="isOkAcconto">Acconto Pagato</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isOkAcconto" id="isOkAcconto"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -226,8 +226,8 @@ export const FormEditServizio = ({
<FormLabel htmlFor="isOkSaldo">Saldo Pagato</FormLabel> <FormLabel htmlFor="isOkSaldo">Saldo Pagato</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isOkSaldo" id="isOkSaldo"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -252,8 +252,8 @@ export const FormEditServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isOkConsulenza" id="isOkConsulenza"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -278,8 +278,8 @@ export const FormEditServizio = ({
<FormLabel htmlFor="skipPayment">Salta Pagamento</FormLabel> <FormLabel htmlFor="skipPayment">Salta Pagamento</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipPayment" id="skipPayment"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -304,8 +304,8 @@ export const FormEditServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipControlloDoc" id="skipControlloDoc"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -330,8 +330,8 @@ export const FormEditServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipDocMotivazione" id="skipDocMotivazione"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -90,8 +90,8 @@ export const FormFlags = ({
</div> </div>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="value" id="value"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -193,7 +193,7 @@ export const FormLogin = () => {
<FormControl> <FormControl>
<Checkbox <Checkbox
checked={field.value} defaultChecked={field.value}
id="checkbox" id="checkbox"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -73,8 +73,8 @@ export const MustChangePasswordForm = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="mustChangePassword" id="mustChangePassword"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -385,8 +385,8 @@ export const FormNewServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="arredato" id="arredato"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -608,8 +608,8 @@ export const FormNewServizio = ({
<FormLabel htmlFor="skipPayment">Salta Pagamento</FormLabel> <FormLabel htmlFor="skipPayment">Salta Pagamento</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipPayment" id="skipPayment"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -634,8 +634,8 @@ export const FormNewServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipControlloDoc" id="skipControlloDoc"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -660,8 +660,8 @@ export const FormNewServizio = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipDocMotivazione" id="skipDocMotivazione"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -669,8 +669,8 @@ export const FormNewServizioAcquisto = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="arredato" id="arredato"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -1257,8 +1257,8 @@ export const FormNewServizioAcquisto = ({
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="skipPayment" id="skipPayment"
onCheckedChange={(v) => { onCheckedChange={(v) => {
field.onChange(v); field.onChange(v);

View file

@ -294,8 +294,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isAcconto">Acconto</FormLabel> <FormLabel htmlFor="isAcconto">Acconto</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isAcconto" id="isAcconto"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -314,8 +314,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isSaldo">Saldo</FormLabel> <FormLabel htmlFor="isSaldo">Saldo</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isSaldo" id="isSaldo"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -334,8 +334,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isConsulenza">Consulenza</FormLabel> <FormLabel htmlFor="isConsulenza">Consulenza</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isConsulenza" id="isConsulenza"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -354,8 +354,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isTransitorio">Transitorio</FormLabel> <FormLabel htmlFor="isTransitorio">Transitorio</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isTransitorio" id="isTransitorio"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -374,8 +374,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isStabile">Stabile</FormLabel> <FormLabel htmlFor="isStabile">Stabile</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isStabile" id="isStabile"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />
@ -395,8 +395,8 @@ export const FormPrezzo = ({
<FormLabel htmlFor="isActive">Attivo</FormLabel> <FormLabel htmlFor="isActive">Attivo</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isActive" id="isActive"
onCheckedChange={field.onChange} onCheckedChange={field.onChange}
/> />

View file

@ -185,8 +185,8 @@ export const ProfileFormAccount = ({
<FormLabel htmlFor="isAdmin">Admin</FormLabel> <FormLabel htmlFor="isAdmin">Admin</FormLabel>
<FormControl> <FormControl>
<Switch <Switch
checked={field.value}
className="data-[state=checked]:bg-neutral-700" className="data-[state=checked]:bg-neutral-700"
defaultChecked={field.value}
id="isAdmin" id="isAdmin"
onCheckedChange={(v) => { onCheckedChange={(v) => {
field.onChange(v); field.onChange(v);