fix: update error

This commit is contained in:
hanif salafi 2025-12-02 07:27:23 +07:00
parent ad8f362744
commit c3c3cc18b2
5 changed files with 25 additions and 25 deletions

View File

@ -288,11 +288,11 @@ export default function ContentBlast() {
<div className="flex gap-6"> <div className="flex gap-6">
<label className="flex items-center gap-2"> <label className="flex items-center gap-2">
<Checkbox <Checkbox
checked={field.value.includes("wa")} checked={field.value?.includes("wa") ?? false}
onCheckedChange={(checked) => { onCheckedChange={(checked) => {
checked checked
? field.onChange([...field.value, "wa"]) ? field.onChange([...(field.value ?? []), "wa"])
: field.onChange(field.value.filter((v) => v !== "wa")); : field.onChange((field.value ?? []).filter((v) => v !== "wa"));
}} }}
/> />
WhatsApp WhatsApp
@ -300,12 +300,12 @@ export default function ContentBlast() {
<label className="flex items-center gap-2"> <label className="flex items-center gap-2">
<Checkbox <Checkbox
checked={field.value.includes("email")} checked={field.value?.includes("email") ?? false}
onCheckedChange={(checked) => { onCheckedChange={(checked) => {
checked checked
? field.onChange([...field.value, "email"]) ? field.onChange([...(field.value ?? []), "email"])
: field.onChange( : field.onChange(
field.value.filter((v) => v !== "email") (field.value ?? []).filter((v) => v !== "email")
); );
}} }}
/> />

View File

@ -1748,13 +1748,13 @@ export default function FormAudio() {
{options.map((option) => { {options.map((option) => {
const isAllChecked = const isAllChecked =
field.value.length === (field.value?.length ?? 0) ===
options.filter((opt: any) => opt.id !== "all").length; options.filter((opt: any) => opt.id !== "all").length;
const isChecked = const isChecked =
option.id === "all" option.id === "all"
? isAllChecked ? isAllChecked
: field.value.includes(option.id); : field.value?.includes(option.id) ?? false;
const handleChange = () => { const handleChange = () => {
let updated: string[] = []; let updated: string[] = [];
@ -1767,8 +1767,8 @@ export default function FormAudio() {
.map((opt: any) => opt.id); .map((opt: any) => opt.id);
} else { } else {
updated = isChecked updated = isChecked
? field.value.filter((val) => val !== option.id) ? (field.value ?? []).filter((val) => val !== option.id)
: [...field.value, option.id]; : [...(field.value ?? []), option.id];
if (isAllChecked && option.id !== "all") { if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all"); updated = updated.filter((val) => val !== "all");

View File

@ -1673,13 +1673,13 @@ export default function FormImage() {
{options.map((option) => { {options.map((option) => {
const isAllChecked = const isAllChecked =
field.value.length === (field.value?.length ?? 0) ===
options.filter((opt: any) => opt.id !== "all").length; options.filter((opt: any) => opt.id !== "all").length;
const isChecked = const isChecked =
option.id === "all" option.id === "all"
? isAllChecked ? isAllChecked
: field.value.includes(option.id); : field.value?.includes(option.id) ?? false;
const handleChange = () => { const handleChange = () => {
let updated: string[] = []; let updated: string[] = [];
@ -1692,8 +1692,8 @@ export default function FormImage() {
.map((opt: any) => opt.id); .map((opt: any) => opt.id);
} else { } else {
updated = isChecked updated = isChecked
? field.value.filter((val) => val !== option.id) ? (field.value ?? []).filter((val) => val !== option.id)
: [...field.value, option.id]; : [...(field.value ?? []), option.id];
if (isAllChecked && option.id !== "all") { if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all"); updated = updated.filter((val) => val !== "all");

View File

@ -1715,13 +1715,13 @@ export default function FormTeks() {
{options.map((option) => { {options.map((option) => {
const isAllChecked = const isAllChecked =
field.value.length === (field.value?.length ?? 0) ===
options.filter((opt: any) => opt.id !== "all").length; options.filter((opt: any) => opt.id !== "all").length;
const isChecked = const isChecked =
option.id === "all" option.id === "all"
? isAllChecked ? isAllChecked
: field.value.includes(option.id); : field.value?.includes(option.id) ?? false;
const handleChange = () => { const handleChange = () => {
let updated: string[] = []; let updated: string[] = [];
@ -1734,8 +1734,8 @@ export default function FormTeks() {
.map((opt: any) => opt.id); .map((opt: any) => opt.id);
} else { } else {
updated = isChecked updated = isChecked
? field.value.filter((val) => val !== option.id) ? (field.value ?? []).filter((val) => val !== option.id)
: [...field.value, option.id]; : [...(field.value ?? []), option.id];
if (isAllChecked && option.id !== "all") { if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all"); updated = updated.filter((val) => val !== "all");

View File

@ -1713,7 +1713,7 @@ export default function FormVideo() {
if (e.key === "Enter" && e.currentTarget.value.trim()) { if (e.key === "Enter" && e.currentTarget.value.trim()) {
e.preventDefault(); e.preventDefault();
field.onChange([ field.onChange([
...field.value, ...(field.value ?? []),
e.currentTarget.value.trim(), e.currentTarget.value.trim(),
]); ]);
e.currentTarget.value = ""; e.currentTarget.value = "";
@ -1722,7 +1722,7 @@ export default function FormVideo() {
/> />
<div className="mt-3"> <div className="mt-3">
{field.value.map((tag: string, index: number) => ( {(field.value ?? []).map((tag: string, index: number) => (
<span <span
key={index} key={index}
className="px-1 py-1 rounded-lg bg-black text-white mr-2 text-sm font-sans" className="px-1 py-1 rounded-lg bg-black text-white mr-2 text-sm font-sans"
@ -1731,7 +1731,7 @@ export default function FormVideo() {
<button <button
type="button" type="button"
onClick={() => { onClick={() => {
const updatedTags = field.value.filter( const updatedTags = (field.value ?? []).filter(
(_, i) => i !== index (_, i) => i !== index
); );
field.onChange(updatedTags); field.onChange(updatedTags);
@ -1764,13 +1764,13 @@ export default function FormVideo() {
{options.map((option) => { {options.map((option) => {
const isAllChecked = const isAllChecked =
field.value.length === (field.value?.length ?? 0) ===
options.filter((opt: any) => opt.id !== "all").length; options.filter((opt: any) => opt.id !== "all").length;
const isChecked = const isChecked =
option.id === "all" option.id === "all"
? isAllChecked ? isAllChecked
: field.value.includes(option.id); : field.value?.includes(option.id) ?? false;
const handleChange = () => { const handleChange = () => {
let updated: string[] = []; let updated: string[] = [];
@ -1783,8 +1783,8 @@ export default function FormVideo() {
.map((opt: any) => opt.id); .map((opt: any) => opt.id);
} else { } else {
updated = isChecked updated = isChecked
? field.value.filter((val) => val !== option.id) ? (field.value ?? []).filter((val) => val !== option.id)
: [...field.value, option.id]; : [...(field.value ?? []), option.id];
if (isAllChecked && option.id !== "all") { if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all"); updated = updated.filter((val) => val !== "all");