Skip to content

Commit

Permalink
Make public group registration more general (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag authored May 26, 2024
1 parent 1f3522e commit 38e80c1
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions packages/berlin/src/pages/PublicGroupRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ function PublicGroupRegistration() {
const [searchParams] = useSearchParams();
const groupCategoryNameParam = searchParams.get('groupCategory');

const capitalizedParam =
groupCategoryNameParam &&
groupCategoryNameParam?.slice(0, 1).toUpperCase() + groupCategoryNameParam?.slice(1);

const {
control,
getValues,
Expand Down Expand Up @@ -79,7 +75,7 @@ function PublicGroupRegistration() {
return;
}
queryClient.invalidateQueries({ queryKey: ['user', user?.id, 'users-to-groups'] });
toast.success(`Joined ${groupCategoryNameParam} group successfully!`);
toast.success(`Joined group successfully!`);
},
onError: () => {
toast.error('Something went wrong.');
Expand All @@ -99,7 +95,7 @@ function PublicGroupRegistration() {
}

queryClient.invalidateQueries({ queryKey: ['user', user?.id, 'users-to-groups'] });
toast.success(`Updated ${groupCategoryNameParam} group successfully!`);
toast.success(`Updated group successfully!`);
},
onError: () => {
toast.error('Something went wrong.');
Expand Down Expand Up @@ -133,15 +129,11 @@ function PublicGroupRegistration() {
name="group"
control={control}
rules={{
required: `${capitalizedParam} group is required`,
required: `Group is required`,
}}
render={({ field }) => (
<Select
placeholder={
prevUserToGroup
? prevUserToGroup.group.name
: `Select your ${groupCategoryNameParam} group`
}
placeholder={prevUserToGroup ? prevUserToGroup.group.name : `Select your group`}
options={selectData}
value={field.value}
errors={[errors.group?.message ?? '']}
Expand All @@ -151,7 +143,7 @@ function PublicGroupRegistration() {
/>
)}
/>
<Button type="submit">Join {groupCategoryNameParam} group</Button>
<Button type="submit">Join group</Button>
</Form>
</FlexColumn>
);
Expand Down

0 comments on commit 38e80c1

Please sign in to comment.