Skip to content

Commit a13f937

Browse files
committed
refactor switch handler
1 parent 54b49a2 commit a13f937

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/components/Switch/Switch.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,16 @@ const Switch = ({
101101
checked={checked}
102102
onChange={(e) => {
103103
if (tag) {
104-
if (e.target.checked) {
105-
tracker.track({
106-
event: AnalyticsEvents.SWITCH_ON,
107-
type: AnalyticsComponentType.SWITCH,
108-
tag,
109-
pages,
110-
merchantId,
111-
ip,
112-
});
113-
} else {
114-
tracker.track({
115-
event: AnalyticsEvents.SWITCH_OFF,
116-
type: AnalyticsComponentType.SWITCH,
117-
tag,
118-
pages,
119-
merchantId,
120-
ip,
121-
});
122-
}
104+
tracker.track({
105+
event: e.target.checked
106+
? AnalyticsEvents.SWITCH_ON
107+
: AnalyticsEvents.SWITCH_OFF,
108+
type: AnalyticsComponentType.SWITCH,
109+
tag,
110+
pages,
111+
merchantId,
112+
ip,
113+
});
123114
}
124115
onToggleChange(e);
125116
}}

0 commit comments

Comments
 (0)