Skip to content

Commit cd3facf

Browse files
committed
prettier --write
1 parent e84672e commit cd3facf

7 files changed

Lines changed: 64 additions & 68 deletions

File tree

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { FC } from "react";
1+
import type { FC } from 'react';
22

3-
import type { Group, NewGroup } from "../../types/backend";
4-
import { BaseDialog } from "../common/BaseDialog";
5-
import { Button } from "../common/Button";
3+
import type { Group, NewGroup } from '../../types/backend';
4+
import { BaseDialog } from '../common/BaseDialog';
5+
import { Button } from '../common/Button';
66

77
type ExistingGroupsModalProps = {
88
isOpen: boolean;
@@ -14,51 +14,47 @@ type ExistingGroupsModalProps = {
1414
isSubmitting: boolean;
1515
};
1616

17-
export const ExistingGroupsModal: FC<ExistingGroupsModalProps> = ({isOpen, onClose, title, newGroup, existingGroups, submitFromModal, isSubmitting}) => {
17+
export const ExistingGroupsModal: FC<ExistingGroupsModalProps> = ({
18+
isOpen,
19+
onClose,
20+
title,
21+
newGroup,
22+
existingGroups,
23+
submitFromModal,
24+
isSubmitting,
25+
}) => {
1826
return (
1927
<BaseDialog title={title} isOpen={isOpen} onClose={onClose} fullWidth={false}>
2028
<div className='min-w-[1000px]'></div>
2129

2230
<p className='mb-4'>
23-
One or more groups with the name <span className='font-semibold'>"{newGroup.groupName}"</span> already exist.
24-
Please choose another group name or make a request to join an existing group using the contact information provided in the table below.
31+
One or more groups with the name <span className='font-semibold'>"{newGroup.groupName}"</span> already
32+
exist. Please choose another group name or make a request to join an existing group using the contact
33+
information provided in the table below.
2534
</p>
2635

2736
<p className='mb-4'>
28-
Alternatively, you can go ahead and create an additional group called <span className='font-semibold'>"{newGroup.groupName}"</span> anyway, but be aware this may cause confusion in the future.
37+
Alternatively, you can go ahead and create an additional group called{' '}
38+
<span className='font-semibold'>"{newGroup.groupName}"</span> anyway, but be aware this may cause
39+
confusion in the future.
2940
</p>
30-
41+
3142
<div className='overflow-x-auto max-h-[150px]'>
3243
<table className='w-full border border-gray-200 rounded-md'>
3344
<thead className='bg-gray-50'>
3445
<tr>
35-
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>
36-
Group Name
37-
</th>
38-
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>
39-
Institute
40-
</th>
41-
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>
42-
Email
43-
</th>
46+
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>Group Name</th>
47+
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>Institute</th>
48+
<th className='px-4 py-2 text-left text-sm font-medium text-gray-600'>Email</th>
4449
</tr>
4550
</thead>
4651

4752
<tbody>
48-
{existingGroups.map(group => (
49-
<tr
50-
key={group.groupId}
51-
className='border-t hover:bg-gray-50'
52-
>
53-
<td className='px-4 py-2 text-sm text-gray-800'>
54-
{group.groupName}
55-
</td>
56-
<td className='px-4 py-2 text-sm text-gray-800'>
57-
{group.institution}
58-
</td>
59-
<td className='px-4 py-2 text-sm text-gray-800'>
60-
{group.contactEmail}
61-
</td>
53+
{existingGroups.map((group) => (
54+
<tr key={group.groupId} className='border-t hover:bg-gray-50'>
55+
<td className='px-4 py-2 text-sm text-gray-800'>{group.groupName}</td>
56+
<td className='px-4 py-2 text-sm text-gray-800'>{group.institution}</td>
57+
<td className='px-4 py-2 text-sm text-gray-800'>{group.contactEmail}</td>
6258
</tr>
6359
))}
6460
</tbody>
@@ -72,9 +68,9 @@ export const ExistingGroupsModal: FC<ExistingGroupsModalProps> = ({isOpen, onClo
7268
onClick={() => void submitFromModal(newGroup)}
7369
disabled={isSubmitting}
7470
>
75-
{isSubmitting ? "Creating group..." : `Create additional group called "${newGroup.groupName}"`}
71+
{isSubmitting ? 'Creating group...' : `Create additional group called "${newGroup.groupName}"`}
7672
</Button>
7773
</div>
7874
</BaseDialog>
79-
)
80-
}
75+
);
76+
};

website/src/components/Group/GroupForm.spec.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@ const dummyGetAllGroups = async (_groupName?: string): Promise<GetAllGroupsResul
1313
return {
1414
succeeded: true,
1515
groups: [],
16-
}
16+
};
1717
};
1818

1919
describe('GroupForm', () => {
2020
test('test empty form', () => {
2121
const formTitle = 'Create group';
2222
const buttonText = 'Submit';
2323

24-
render(<GroupForm title={formTitle} buttonText={buttonText} onSubmit={noOpSubmit} getAllGroups={dummyGetAllGroups} />);
24+
render(
25+
<GroupForm
26+
title={formTitle}
27+
buttonText={buttonText}
28+
onSubmit={noOpSubmit}
29+
getAllGroups={dummyGetAllGroups}
30+
/>,
31+
);
2532

2633
expect(screen.getByRole('heading', { name: formTitle })).toBeVisible();
2734
expect(screen.getByRole('button', { name: buttonText })).toBeVisible();

website/src/components/Group/GroupForm.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import { ErrorFeedback } from '../ErrorFeedback.tsx';
2020
import { Button } from '../common/Button';
2121

2222
const PLACEHOLDER_NEWGROUP: NewGroup = {
23-
groupName: "",
24-
institution: "",
23+
groupName: '',
24+
institution: '',
2525
address: {
26-
line1: "",
27-
city: "",
28-
postalCode: "",
29-
country: "",
26+
line1: '',
27+
city: '',
28+
postalCode: '',
29+
country: '',
3030
},
31-
contactEmail: "",
32-
}
31+
contactEmail: '',
32+
};
3333

3434
interface GroupFormProps {
3535
/**
@@ -51,13 +51,13 @@ interface GroupFormProps {
5151
*/
5252
onSubmit: (group: NewGroup) => Promise<GroupSubmitResult>;
5353
/**
54-
* Handler that can be used to check if the name of the group being created is
54+
* Handler that can be used to check if the name of the group being created is
5555
* already in use by another group in the database.
5656
* @param groupName Group name to filter the results by
57-
* @returns A result object where the `groups` property
57+
* @returns A result object where the `groups` property
5858
* is an array of existing Groups
5959
*/
60-
getAllGroups: (groupName?: string) => Promise<GetAllGroupsResult>
60+
getAllGroups: (groupName?: string) => Promise<GetAllGroupsResult>;
6161
}
6262

6363
export type GroupSubmitSuccess = {
@@ -122,7 +122,6 @@ export const GroupForm: FC<GroupFormProps> = ({ title, buttonText, defaultGroupD
122122
await submitGroup(group);
123123
};
124124

125-
126125
return (
127126
<div className='p-4 max-w-6xl mx-auto'>
128127
<h2 className='title'>{title}</h2>

website/src/components/User/GroupCreationForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const getContinueSubmissionFromSearchParams = (searchParamsString: string): Cont
2525
};
2626

2727
const InnerGroupCreationForm: FC<GroupManagerProps> = ({ clientConfig, accessToken, searchParams }) => {
28-
const { getAllGroups } = useGetAllGroups({
28+
const { getAllGroups } = useGetAllGroups({
2929
clientConfig,
3030
accessToken,
3131
});

website/src/components/User/GroupEditForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface GroupEditFormProps {
1616
const InnerGroupEditForm: FC<GroupEditFormProps> = ({ prefetchedGroupDetails, clientConfig, accessToken }) => {
1717
const { groupId, ...groupInfo } = prefetchedGroupDetails.group;
1818

19-
const { getAllGroups } = useGetAllGroups({
19+
const { getAllGroups } = useGetAllGroups({
2020
clientConfig,
2121
accessToken,
2222
});

website/src/hooks/useGroupOperations.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,8 @@ export const useGroupCreation = ({
7676
};
7777
};
7878

79-
export const useGetAllGroups = ({
80-
clientConfig,
81-
accessToken,
82-
}: {
83-
clientConfig: ClientConfig;
84-
accessToken: string;
85-
}) => {
86-
const {zodios} = useGroupManagementClient(clientConfig);
79+
export const useGetAllGroups = ({ clientConfig, accessToken }: { clientConfig: ClientConfig; accessToken: string }) => {
80+
const { zodios } = useGroupManagementClient(clientConfig);
8781

8882
const getAllGroups = useCallback(
8983
async (groupName?: string) => callGetAllGroups(accessToken, zodios)(groupName),
@@ -93,7 +87,7 @@ export const useGetAllGroups = ({
9387
return {
9488
getAllGroups,
9589
};
96-
}
90+
};
9791

9892
export const useGroupEdit = ({ clientConfig, accessToken }: { clientConfig: ClientConfig; accessToken: string }) => {
9993
const { zodios } = useGroupManagementClient(clientConfig);
@@ -148,12 +142,12 @@ function callCreateGroup(accessToken: string, zodios: ZodiosInstance<typeof grou
148142
}
149143

150144
type GetAllGroupsSuccess = {
151-
succeeded: true,
152-
groups: Group[],
145+
succeeded: true;
146+
groups: Group[];
153147
};
154148
type GetAllGroupsError = {
155-
succeeded: false,
156-
errorMessage: string,
149+
succeeded: false;
150+
errorMessage: string;
157151
};
158152
export type GetAllGroupsResult = GetAllGroupsSuccess | GetAllGroupsError;
159153

@@ -162,7 +156,7 @@ function callGetAllGroups(accessToken: string, zodios: ZodiosInstance<typeof gro
162156
try {
163157
const existingGroups = await zodios.getAllGroups({
164158
headers: createAuthorizationHeader(accessToken),
165-
queries: { name: groupName }
159+
queries: { name: groupName },
166160
});
167161
return {
168162
succeeded: true,
@@ -175,7 +169,7 @@ function callGetAllGroups(accessToken: string, zodios: ZodiosInstance<typeof gro
175169
errorMessage: message,
176170
} as GetAllGroupsError;
177171
}
178-
}
172+
};
179173
}
180174

181175
type EditGroupSuccess = {

website/src/services/groupManagementApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ const getAllGroupsEndpoint = makeEndpoint({
7272
parameters: [
7373
authorizationHeader,
7474
{
75-
name: "name",
76-
type: "Query",
75+
name: 'name',
76+
type: 'Query',
7777
schema: z.string().optional(),
7878
},
7979
],

0 commit comments

Comments
 (0)