coronasafe/care_fe

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

Summary

Maintainability
F
4 days
Test Coverage

Showing 13 of 13 total issues

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

<div className="space-y-2">
<Label className="text-sm font-medium">
{t("select_new_role")}
</Label>
<Select value={selectedRole} onValueChange={setSelectedRole}>
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 2 other locations - About 1 day to fix
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 186..209
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 185..208

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

<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive" className="w-full">
{t("remove_user")}
</Button>
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 1 day to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 219..247

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

<div className="flex items-start gap-4">
<Avatar
name={`${userRole.user.first_name} ${userRole.user.last_name}`}
className="size-12"
imageUrl={userRole.user.profile_picture_url}
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 6 hrs to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 146..160

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

onError: (error) => {
const errorData = error.cause as { errors: { msg: string[] } };
errorData.errors.msg.forEach((er) => {
toast.error(er);
});
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 4 other locations - About 2 hrs to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 88..93
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 112..117
src/pages/Organization/components/EditUserRoleSheet.tsx on lines 108..113
src/pages/Patients/VerifyPatient.tsx on lines 63..68

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

onError: (error) => {
const errorData = error.cause as { errors: { msg: string[] } };
errorData.errors.msg.forEach((er) => {
toast.error(er);
});
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 4 other locations - About 2 hrs to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 88..93
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 112..117
src/pages/Organization/components/EditUserRoleSheet.tsx on lines 88..93
src/pages/Patients/VerifyPatient.tsx on lines 63..68

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

const handleUpdateRole = () => {
if (selectedRole === userRole.role.id) {
toast.error(t("select_diff_role"));
return;
}
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 1 hr to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 120..130

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

<div>
<span className="text-sm text-gray-500">
{t("current_role")}
</span>
<p className="text-sm font-medium">{userRole.role.name}</p>
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 1 hr to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 170..175

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

<SheetHeader>
<SheetTitle>{t("edit_user_role")}</SheetTitle>
<SheetDescription>
{t("update_user_role_organization")}
</SheetDescription>
Severity: Major
Found in src/pages/Organization/components/EditUserRoleSheet.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/LinkUserSheet.tsx on lines 125..130
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 186..191

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

onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["organizationUsers", organizationId],
});
toast.success(t("user_role_update_success"));
Severity: Minor
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 50 mins to fix
src/pages/Organization/components/EditUserRoleSheet.tsx on lines 101..107

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

onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["organizationUsers", organizationId],
});
toast.success(t("user_removed_success"));
Severity: Minor
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 50 mins to fix
src/pages/Organization/components/EditUserRoleSheet.tsx on lines 81..87

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

<Button
className="w-full"
onClick={handleUpdateRole}
disabled={selectedRole === userRole.role.id}
>
Severity: Minor
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 50 mins to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 211..217

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

<div className="col-span-2">
<span className="text-sm text-gray-500">
{t("last_login")}{" "}
</span>
<UserStatusIndicator user={userRole.user} />
Severity: Minor
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 45 mins to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 177..182

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

<SheetTrigger asChild>
{trigger || <Button variant="outline">{t("edit_role")}</Button>}
</SheetTrigger>
Severity: Minor
Found in src/pages/Organization/components/EditUserRoleSheet.tsx and 1 other location - About 30 mins to fix
src/pages/Facility/settings/organizations/components/EditFacilityUserRoleSheet.tsx on lines 134..136
Category
Status