Skip to content

Commit 5f35194

Browse files
committed
Format code
1 parent 70fd888 commit 5f35194

File tree

5 files changed

+33
-38
lines changed

5 files changed

+33
-38
lines changed

app/[orgId]/groups/page.tsx

+14-16
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const fields: Field[] = [
6161
{ name: "users", label: "Users (one email per line)", type: "textarea" },
6262
];
6363

64-
6564
export default function GroupsPage() {
6665
const params = useParams();
6766
const orgId = params.orgId as string;
@@ -135,54 +134,53 @@ export default function GroupsPage() {
135134
try {
136135
// Create a copy of the group object to avoid mutating the original
137136
const groupToSave = { ...group };
138-
137+
139138
// Convert users from string to array of strings (splitting at newlines)
140-
if (typeof groupToSave.users === 'string') {
139+
if (typeof groupToSave.users === "string") {
141140
groupToSave.users = groupToSave.users
142-
.split('\n')
143-
.map(user => user.trim())
144-
.filter(user => user.length > 0); // Remove empty lines
141+
.split("\n")
142+
.map((user) => user.trim())
143+
.filter((user) => user.length > 0); // Remove empty lines
145144
}
146-
145+
147146
console.log("groups", groupToSave);
148-
147+
149148
const url = selectedGroup
150149
? `/api/orgs/${orgId}/groups/${group.nameId}`
151150
: `/api/orgs/${orgId}/groups`;
152-
151+
153152
const response = await fetch(url, {
154153
method: selectedGroup ? "PATCH" : "POST",
155154
headers: {
156155
"Content-Type": "application/json",
157156
},
158157
body: JSON.stringify(groupToSave),
159158
});
160-
159+
161160
if (!response.ok) {
162161
const errorData = await response.json().catch(() => ({}));
163162
throw new Error(formatValidationErrors(errorData));
164163
}
165-
164+
166165
const savedGroup = await response.json();
167166
// console.log('saved groups',savedGroup);
168-
169-
167+
170168
if (selectedGroup) {
171169
setGroups(groups.map((g) => (g.id === savedGroup.id ? savedGroup : g)));
172170
toast({
173171
title: "Success",
174172
description: "Group updated successfully",
175173
});
176174
} else {
177-
console.log("savedgroups",savedGroup);
178-
175+
console.log("savedgroups", savedGroup);
176+
179177
setGroups([...groups, savedGroup]);
180178
toast({
181179
title: "Success",
182180
description: "Group created successfully",
183181
});
184182
}
185-
183+
186184
setIsEditorOpen(false);
187185
} catch (error) {
188186
console.error("Error saving group:", error);

app/[orgId]/submissions/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default function SubmissionsPage({
3030
const fetchSubmissions = useCallback(async () => {
3131
try {
3232
const response = await fetch(`/api/orgs/${params.orgId}/submissions`);
33-
console.log('submission',response);
34-
33+
console.log("submission", response);
34+
3535
if (!response.ok) {
3636
const errorData = await response.json().catch(() => ({}));
3737
throw new Error(formatValidationErrors(errorData));

app/api/orgs/[orgId]/groups/[groupId]/service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export async function updateGroupMembers(
4646
.where(and(eq(groups.id, groupId), eq(groups.orgId, orgId)))
4747
.limit(1);
4848

49-
console.log("group selected",group);
50-
49+
console.log("group selected", group);
50+
5151
if (group.length === 0) {
5252
throw new Error("Group not found");
5353
}
@@ -58,11 +58,11 @@ export async function updateGroupMembers(
5858
.from(users)
5959
.where(inArray(users.email, emails));
6060

61-
console.log("users to keep",users_to_keep);
62-
61+
console.log("users to keep", users_to_keep);
62+
6363
const user_ids_to_keep = users_to_keep.map((u) => u.id);
6464

65-
console.log("users ids to keep",user_ids_to_keep);
65+
console.log("users ids to keep", user_ids_to_keep);
6666
// Remove members not in the new list
6767
await tx
6868
.delete(groupMemberships)

app/api/orgs/[orgId]/groups/route.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,26 @@ export async function POST(
2626
) {
2727
try {
2828
// console.log("request",await request.json());
29-
30-
29+
3130
const orgId = await getOrgIdFromNameId(NameIdSchema.parse(params.orgId));
3231
const requestData = await request.json();
33-
console.log("request data",requestData);
34-
32+
console.log("request data", requestData);
33+
3534
// Rename 'users' to 'emails' in the request data
3635
const { users, ...restRequestData } = requestData;
3736
const processedData = {
3837
...restRequestData,
3938
emails: users, // Rename 'users' to 'emails'
4039
};
41-
console.log("emails",processedData.emails);
42-
console.log("emails",restRequestData);
43-
40+
console.log("emails", processedData.emails);
41+
console.log("emails", restRequestData);
42+
4443
// Now validate with your schema
4544
const { emails, ...rest } = createGroupSchema.parse(processedData);
46-
45+
4746
console.log("emails", emails);
4847
console.log("rest", rest);
49-
50-
48+
5149
const group = await groupsService.createGroup(orgId, rest);
5250

5351
if (emails) {

app/api/orgs/[orgId]/submissions/route.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ export async function GET(
1919

2020
// Get numeric orgId
2121
const orgId = await getOrgIdFromNameId(orgNameId);
22-
console.log("orgid=",orgId);
23-
22+
console.log("orgid=", orgId);
23+
2424
const submissions = await submissionService.getOrgSubmissions(orgId);
25-
console.log('sub',submissions);
26-
27-
25+
console.log("sub", submissions);
26+
2827
return NextResponse.json(submissions);
2928
} catch (error) {
3029
if (error instanceof z.ZodError) {

0 commit comments

Comments
 (0)