+ {(() => {
+ const currentSpecs = form.watch("specs") || {};
+ const displayBadges: string[] = currentSpecs.displayBadges || ['power', 'length', 'capacity'];
+ const allBadgeOptions = [
+ { key: 'power', label: 'Công suất', icon: '⚡', color: 'bg-orange-100 border-orange-200 text-orange-700' },
+ { key: 'length', label: 'Độ dài', icon: '📏', color: 'bg-emerald-100 border-emerald-200 text-emerald-700' },
+ { key: 'capacity', label: 'Dung lượng', icon: '🔋', color: 'bg-purple-100 border-purple-200 text-purple-700' },
+ { key: 'interface', label: 'Kết nối', icon: '🔌', color: 'bg-blue-100 border-blue-200 text-blue-700' },
+ { key: 'bandwidth', label: 'Tốc độ', icon: '⚡', color: 'bg-cyan-100 border-cyan-200 text-cyan-700' },
+ ];
+
+ const toggleBadge = (key: string) => {
+ let newBadges = [...displayBadges];
+ if (newBadges.includes(key)) {
+ newBadges = newBadges.filter(b => b !== key);
+ } else {
+ newBadges.push(key);
+ }
+ form.setValue("specs", { ...currentSpecs, displayBadges: newBadges }, { shouldDirty: true });
+ };
+
+ return (
+
+ {allBadgeOptions.map(opt => {
+ const isChecked = displayBadges.includes(opt.key);
+ const hasValue = currentSpecs[opt.key];
+ return (
+
+ );
+ })}
+
+ );
+ })()}
+