Skip to content

Commit 2468cc1

Browse files
committed
✨ Auto-fix formatting
1 parent f9f14dd commit 2468cc1

File tree

3 files changed

+67
-42
lines changed

3 files changed

+67
-42
lines changed

admin/src/Components/MessageForm.tsx

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type GroupOption = {
1313
type: "group";
1414
label: string;
1515
value: string;
16-
}
16+
};
1717

1818
const groupOption = (d: Group): GroupOption => {
1919
const id = d.id;
@@ -31,14 +31,14 @@ type MemberOption = {
3131
type: "member";
3232
label: string;
3333
value: string;
34-
}
34+
};
3535

3636
type CombinedOption = {
37-
type: "combined",
38-
label: string,
39-
value: string,
40-
inner: (MemberOption | GroupOption)[],
41-
}
37+
type: "combined";
38+
label: string;
39+
value: string;
40+
inner: (MemberOption | GroupOption)[];
41+
};
4242

4343
const memberOption = (d: Member): MemberOption => {
4444
const id = d.member_id;
@@ -52,9 +52,19 @@ const memberOption = (d: Member): MemberOption => {
5252
};
5353
};
5454

55-
const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, onSave: ()=>void, recipientSelect: boolean }) => {
55+
const MessageForm = ({
56+
message,
57+
onSave,
58+
recipientSelect,
59+
}: {
60+
message: Message;
61+
onSave: () => void;
62+
recipientSelect: boolean;
63+
}) => {
5664
const [sendDisabled, setSendDisabled] = useState(true);
57-
const [recipients, setRecipients] = useState<(MemberOption | GroupOption)[]>([]);
65+
const [recipients, setRecipients] = useState<
66+
(MemberOption | GroupOption)[]
67+
>([]);
5868
const [bodyLength, setBodyLength] = useState(message.body.length);
5969
const memberCache = React.useRef(new Map<number, Member>()).current;
6070

@@ -70,7 +80,9 @@ const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, o
7080
useEffect(() => {
7181
const unsubscribe = message.subscribe(() => {
7282
setSendDisabled(!message.canSave());
73-
setRecipients(message.recipients as any as (MemberOption | GroupOption)[]);
83+
setRecipients(
84+
message.recipients as any as (MemberOption | GroupOption)[],
85+
);
7486
setBodyLength(message.body.length);
7587
});
7688

@@ -79,20 +91,25 @@ const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, o
7991
};
8092
}, [message]);
8193

82-
const loadOptions = (inputValue: string, callback: (options: (MemberOption | GroupOption | CombinedOption)[]) => void) => {
94+
const loadOptions = (
95+
inputValue: string,
96+
callback: (
97+
options: (MemberOption | GroupOption | CombinedOption)[],
98+
) => void,
99+
) => {
83100
const intListMatch = inputValue.match(/^(\d+[\s,]*)+$/);
84101
if (intListMatch) {
85102
const ids = inputValue
86103
.split(/[\s,]+/)
87104
.map((v) => parseInt(v, 10))
88105
.filter((v) => !isNaN(v));
89106
if (ids.length > 0) {
90-
Promise.all(ids.map(getMember)).then(members => {
107+
Promise.all(ids.map(getMember)).then((members) => {
91108
const options = members.map(memberOption);
92109
callback([
93110
{
94111
type: "combined",
95-
label: `${options.map(o => o.label).join(", ")}`,
112+
label: `${options.map((o) => o.label).join(", ")}`,
96113
value: "combined-" + ids.join("-"),
97114
inner: options,
98115
},
@@ -119,12 +136,18 @@ const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, o
119136
sort_order: "asc",
120137
},
121138
}),
122-
]).then(([{ data: groups }, { data: members }]: [{ data: Group[] }, { data: Member[] }]) =>
123-
callback(
124-
groups
125-
.map((d) => groupOption(d) as GroupOption | MemberOption)
126-
.concat(members.map((d) => memberOption(d))),
127-
),
139+
]).then(
140+
([{ data: groups }, { data: members }]: [
141+
{ data: Group[] },
142+
{ data: Member[] },
143+
]) =>
144+
callback(
145+
groups
146+
.map(
147+
(d) => groupOption(d) as GroupOption | MemberOption,
148+
)
149+
.concat(members.map((d) => memberOption(d))),
150+
),
128151
);
129152
};
130153

@@ -141,7 +164,10 @@ const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, o
141164
Mottagare
142165
</label>
143166
<div className="uk-form-controls">
144-
<Async<(MemberOption | GroupOption | CombinedOption), true>
167+
<Async<
168+
MemberOption | GroupOption | CombinedOption,
169+
true
170+
>
145171
name="recipients"
146172
isMulti
147173
placeholder="Type to search for member or group"
@@ -151,7 +177,7 @@ const MessageForm = ({ message, onSave, recipientSelect }: { message: Message, o
151177
value={recipients}
152178
onChange={(values) => {
153179
const flattened = values.flatMap((v) =>
154-
v.type === "combined" ? v.inner : v
180+
v.type === "combined" ? v.inner : v,
155181
);
156182
message.recipients = flattened;
157183
setRecipients(flattened);

admin/src/Models/Group.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Base from "./Base";
22

33
export default class Group extends Base<Group> {
4-
created_at!: string | null
5-
updated_at!: string | null
6-
deleted_at!: string | null
7-
name!: string
8-
title!: string
9-
description!: string
10-
num_members!: number
4+
created_at!: string | null;
5+
updated_at!: string | null;
6+
deleted_at!: string | null;
7+
name!: string;
8+
title!: string;
9+
description!: string;
10+
num_members!: number;
1111

1212
static model = {
1313
id: "group_id",
@@ -23,7 +23,6 @@ export default class Group extends Base<Group> {
2323
},
2424
};
2525

26-
2726
override deleteConfirmMessage() {
2827
return `Are you sure you want to delete group ${this.title}?`;
2928
}

admin/src/Models/Message.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import Base from "./Base";
22

33
export type MessageRecipient = {
4-
id: number,
5-
type: "member" | "group"
6-
}
4+
id: number;
5+
type: "member" | "group";
6+
};
77

88
export default class Message extends Base<Message> {
9-
subject!: string
10-
body!: string
11-
status!: string
12-
template!: string
13-
recipient!: string
14-
recipients!: MessageRecipient[]
15-
created_at!: string | null
16-
updated_at!: string | null
17-
sent_at!: string | null
18-
member_id!: number
9+
subject!: string;
10+
body!: string;
11+
status!: string;
12+
template!: string;
13+
recipient!: string;
14+
recipients!: MessageRecipient[];
15+
created_at!: string | null;
16+
updated_at!: string | null;
17+
sent_at!: string | null;
18+
member_id!: number;
1919

2020
static model = {
2121
id: "id",

0 commit comments

Comments
 (0)