coronasafe/care_fe

View on GitHub
src/pages/Organization/components/LinkUserSheet.tsx

Summary

Maintainability
D
2 days
Test Coverage

Showing 11 of 11 total issues

Function LinkUserSheet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function LinkUserSheet({
organizationId,
open,
setOpen,
preSelectedUsername,
Severity: Minor
Found in src/pages/Organization/components/LinkUserSheet.tsx - About 25 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<div className="grid grid-cols-2 gap-4 pt-2 border-t border-gray-200">
<div>
<span className="text-sm text-gray-500">
{t("username")}
</span>
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 1 day to fix
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 156..183

Identical blocks of code found in 8 locations. Consider refactoring.
Open

onError: (error) => {
const errorData = error.cause as { errors: { msg: string }[] };
errorData.errors.forEach((er) => {
toast.error(er.msg);
});
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 7 other locations - About 2 hrs to fix
src/components/Patient/LinkDepartmentsSheet.tsx on lines 154..159
src/components/Patient/LinkDepartmentsSheet.tsx on lines 211..216
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 87..92
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 257..262
src/components/Questionnaire/CloneQuestionnaireSheet.tsx on lines 78..83
src/pages/Facility/settings/organizations/components/FacilityOrganizationFormSheet.tsx on lines 115..120
src/pages/Facility/settings/organizations/components/LinkFacilityUserSheet.tsx on lines 92..97

Identical blocks of code found in 2 locations. Consider refactoring.
Open

<div className="w-3/4">
<p className="font-medium text-lg truncate">
{formatName(selectedUser)}
</p>
<span className="text-sm text-gray-500">
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 1 hr to fix
src/pages/Facility/settings/organizations/components/LinkFacilityUserSheet.tsx on lines 149..156

Similar blocks of code found in 4 locations. Consider refactoring.
Open

const { data: preSelectedUser } = useQuery({
queryKey: ["user", preSelectedUsername],
queryFn: query(UserApi.get, {
pathParams: { username: preSelectedUsername || "" },
}),
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 3 other locations - About 1 hr to fix
src/components/Facility/FacilityForm.tsx on lines 141..147
src/pages/Encounters/EncounterShow.tsx on lines 66..72
src/pages/Facility/settings/organizations/components/LinkFacilityUserSheet.tsx on lines 57..63

Similar blocks of code found in 2 locations. Consider refactoring.
Open

onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["organizationUsers", organizationId],
});
toast.success("User added to organization successfully");
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 1 hr to fix
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 78..86

Similar blocks of code found in 3 locations. Consider refactoring.
Open

const handleAddUser = () => {
if (!selectedUser || !selectedRole) {
toast.error("Please select both user and role");
return;
}
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 2 other locations - About 1 hr to fix
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 95..105
src/pages/Facility/settings/organizations/components/LinkFacilityUserSheet.tsx on lines 100..110

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<SheetTrigger asChild>
<Button variant="primary_gradient">
<CareIcon icon="l-plus" className="mr-2 size-4" />
{t("link_user")}
</Button>
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 1 hr to fix
src/components/Users/UserSoftwareUpdate.tsx on lines 48..56

Similar blocks of code found in 14 locations. Consider refactoring.
Open

<SheetHeader>
<SheetTitle>{t("link_user_to_organization")}</SheetTitle>
<SheetDescription>
{t("link_user_to_organization_description")}
</SheetDescription>
Severity: Major
Found in src/pages/Organization/components/LinkUserSheet.tsx and 13 other locations - About 50 mins to fix
src/components/Common/Drawings/ExcalidrawEditor.tsx on lines 133..138
src/components/Encounter/EncounterActions.tsx on lines 116..121
src/components/Encounter/EncounterActions.tsx on lines 183..188
src/components/Location/LocationSheet.tsx on lines 823..828
src/components/Location/LocationSheet.tsx on lines 850..855
src/components/Patient/PatientIndex.tsx on lines 250..255
src/components/Questionnaire/CloneQuestionnaireSheet.tsx on lines 117..122
src/pages/Encounters/AssociateDeviceSheet.tsx on lines 63..68
src/pages/Facility/settings/devices/components/ManageLocationSheet.tsx on lines 93..98
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 138..143
src/pages/Facility/settings/organizations/components/LinkFacilityUserSheet.tsx on lines 126..131
src/pages/Organization/components/EditUserRoleSheet.tsx on lines 142..147
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 186..191

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<Avatar
name={`${selectedUser.first_name} ${selectedUser.last_name}`}
imageUrl={selectedUser.profile_picture_url}
className="size-12"
/>
Severity: Minor
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 50 mins to fix
src/components/Users/UserListAndCard.tsx on lines 80..84

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<UserSelector
selected={selectedUser}
onChange={handleUserChange}
placeholder={t("search_for_a_user")}
noOptionsMessage={t("no_users_found")}
Severity: Minor
Found in src/pages/Organization/components/LinkUserSheet.tsx and 1 other location - About 40 mins to fix
src/components/Resource/ResourceForm.tsx on lines 406..412

There are no issues that match your filters.

Category
Status