Skip to content

Commit

Permalink
Remove @ts-expect-error comments
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed May 16, 2024
1 parent d1015ed commit 3d93f26
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
8 changes: 3 additions & 5 deletions frontend/src/lib/components/MembersList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@
});
if (response === DialogResponse.Submit) {
const notification: `${RoleType}_page.notifications.role_change` = `${roleType}_page.notifications.role_change`;
const role = formState.role.currentValue.toLowerCase();
// @ts-expect-error Typescript will always warn that "admin" isn't in the project roles list, or "manager" isn't in the org roles list. Ignore.
const roleText = $t(`${roleType}_role.${role}`);
const notification = `${roleType}_page.notifications.role_change` as const;
const role = formState.role.currentValue;
notifySuccess(
$t(notification, {
name: member.user?.name ?? '',
role: roleText,
role: role.toLowerCase(),
}),
);
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia
},
},
"org_page": {
"organisation": "Organization",
"notifications": {
"role_change": "Organizational role of {name} set to {role}.",
"user_delete": "{name} has been removed.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</svelte:fragment>
<svelte:fragment slot="title">
<div class="max-w-full flex items-baseline flex-wrap">
<span class="mr-2">{$t('project_page.project')}:</span>
<span class="mr-2">{$t('org_page.organisation')}:</span>
<span class="text-primary max-w-full">
<EditableText
disabled={!canManage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,29 @@
export async function open(member: { userId: UUID; name: string; role: ProjectRole | OrgRole }): Promise<FormModalResult<Schema>> {
name = member.name;
return await formModal.open(tryParse(schema, member), async () => {
const result =
roleType === 'project'
? await _changeProjectMemberRole({
projectId: projectOrOrgId,
userId: member.userId,
role: $form.role as ProjectRole,
})
: await _changeOrgMemberRole(
projectOrOrgId as UUID,
member.userId,
$form.role as OrgRole
);
// @ts-expect-error Errors could be from either the Project or Org GQL mutations
if (result.error?.byType('ProjectMembersMustBeVerified')) {
return { role: [$t('project_page.add_user.user_must_be_verified')] };
if (roleType === 'project') {
const result = await _changeProjectMemberRole({
projectId: projectOrOrgId,
userId: member.userId,
role: $form.role as ProjectRole,
});
if (result.error?.byType('ProjectMembersMustBeVerified')) {
return { role: [$t('project_page.add_user.user_must_be_verified')] };
}
if (result.error?.byType('ProjectMembersMustBeVerifiedForRole')) {
return { role: [$t('project_page.add_user.manager_must_be_verified')] };
}
return result.error?.message;
} else if (roleType === 'org') {
const result = await _changeOrgMemberRole(
projectOrOrgId as UUID,
member.userId,
$form.role as OrgRole
);
return result.error?.message;
}
// @ts-expect-error Errors could be from either the Project or Org GQL mutations
if (result.error?.byType('ProjectMembersMustBeVerifiedForRole')) {
return { role: [$t('project_page.add_user.manager_must_be_verified')] };
}
return result.error?.message;
throw new Error(`Invalid role type: ${roleType as string}.`);
});
}
</script>
Expand Down

0 comments on commit 3d93f26

Please sign in to comment.