Skip to content

Commit 5f38065

Browse files
committed
make sendTo a string[] in all models
1 parent d569217 commit 5f38065

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/components/notification-picker.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function NotificationPicker({
3535
const [enableNotification, setEnableNotification] = useState<boolean>(
3636
model.notification?.enableNotification ?? true
3737
);
38+
const sendToString = model.notification?.sendTo?.join(', ') || '';
3839

3940
const enableNotificationChange = (e: React.ChangeEvent<HTMLInputElement>) => {
4041
const updatedEnableNotification = e.target.checked;
@@ -68,8 +69,12 @@ export function NotificationPicker({
6869

6970
const sendToChange = useCallback(
7071
(e: React.ChangeEvent<HTMLInputElement>) => {
71-
const { name, value } = e.target;
72-
const updatedNotification = { ...model.notification, [name]: value };
72+
const { value } = e.target;
73+
const sendToArray = value.split(',').map(sendToStr => sendToStr.trim());
74+
const updatedNotification = {
75+
...model.notification,
76+
sendTo: sendToArray
77+
};
7378
modelChange({ ...model, notification: updatedNotification });
7479
},
7580
[model, modelChange]
@@ -108,7 +113,7 @@ export function NotificationPicker({
108113

109114
<TextField
110115
label={trans.__('Send To')}
111-
value={model.notification?.sendTo || ''}
116+
value={sendToString}
112117
name="sendTo"
113118
variant="outlined"
114119
onChange={sendToChange}

src/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export type ModelWithScheduleFields = {
7575
};
7676

7777
export type Notification = {
78-
sendTo?: string;
78+
sendTo?: string[];
7979
enableNotification?: boolean;
8080
availableEvents?: string[];
8181
selectedEvents?: string[];

0 commit comments

Comments
 (0)