diff --git a/src/components/UniversiHeader/components/WelcomeUser/WelcomeUser.tsx b/src/components/UniversiHeader/components/WelcomeUser/WelcomeUser.tsx
index b4290116..49f7c145 100644
--- a/src/components/UniversiHeader/components/WelcomeUser/WelcomeUser.tsx
+++ b/src/components/UniversiHeader/components/WelcomeUser/WelcomeUser.tsx
@@ -1,5 +1,5 @@
import { useContext, useMemo, useState } from "react";
-import { Link, redirect } from "react-router-dom";
+import { Link, redirect, useNavigate } from "react-router-dom";
import { ProfileImage } from "@/components/ProfileImage/ProfileImage";
import { AuthContext } from "@/contexts/Auth";
import "./WelcomeUser.less"
@@ -8,6 +8,7 @@ import * as DropdownMenu from "@radix-ui/react-dropdown-menu"
export function WelcomeUser() {
const auth = useContext(AuthContext);
+ const navigate = useNavigate();
const [profileClicked, setProfileClicked] = useState(false)
@@ -24,10 +25,13 @@ export function WelcomeUser() {
profileClicked
?
-
{location.href="/profile/"+auth.profile?.user.name}}>
+
{navigate("/profile/"+auth.profile?.user.name); setProfileClicked(false)}}>
Perfil
-
{auth.signout()}}>
+ { auth.user?.accessLevel === "ROLE_ADMIN" &&
{navigate("/settings"); setProfileClicked(false)}}>
+ Configurações
+
}
+
{auth.signout(); setProfileClicked(false)}}>
Sair
diff --git a/src/contexts/Auth/AuthProvider.tsx b/src/contexts/Auth/AuthProvider.tsx
index f2442bf4..21983da5 100644
--- a/src/contexts/Auth/AuthProvider.tsx
+++ b/src/contexts/Auth/AuthProvider.tsx
@@ -71,7 +71,8 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
if (profile)
updateOrganization();
else
- setOrganization(null);
+ updateOrganization();
+ //setOrganization(null);
setFinishedLogin(true);
return profile;
diff --git a/src/pages/Group/GroupTabs/GroupContents/GroupContentMaterials/GroupContentMaterials.tsx b/src/pages/Group/GroupTabs/GroupContents/GroupContentMaterials/GroupContentMaterials.tsx
index 800aa9c6..89382d84 100644
--- a/src/pages/Group/GroupTabs/GroupContents/GroupContentMaterials/GroupContentMaterials.tsx
+++ b/src/pages/Group/GroupTabs/GroupContents/GroupContentMaterials/GroupContentMaterials.tsx
@@ -38,7 +38,7 @@ export function GroupContentMaterials() {
groupContext.setEditMaterial(data);
},
hidden() {
- return groupContext?.group.admin.id !== groupContext?.loggedData.profile.id;
+ return !groupContext?.group.canEdit;
},
},
{
@@ -47,7 +47,7 @@ export function GroupContentMaterials() {
className: "delete",
onSelect: handleDeleteMaterial,
hidden() {
- return groupContext?.group.admin.id !== groupContext?.loggedData.profile.id;
+ return !groupContext?.group.canEdit;
},
}
];
@@ -59,10 +59,8 @@ export function GroupContentMaterials() {
{
- groupContext.loggedData.profile.id == groupContext.group.admin.id || groupContext.loggedData.profile?.id == groupContext.group.organization?.admin.id ?
+ groupContext.group.canEdit &&
- :
- <>>
}
diff --git a/src/pages/Group/GroupTabs/GroupContents/GroupContents/GroupContents.tsx b/src/pages/Group/GroupTabs/GroupContents/GroupContents/GroupContents.tsx
index 3004b185..9cf32a6e 100644
--- a/src/pages/Group/GroupTabs/GroupContents/GroupContents/GroupContents.tsx
+++ b/src/pages/Group/GroupTabs/GroupContents/GroupContents/GroupContents.tsx
@@ -33,7 +33,7 @@ export function GroupContents() {
groupContext.setEditContent(data);
},
hidden() {
- return groupContext?.group.admin.id !== groupContext?.loggedData.profile.id;
+ return !groupContext?.group.canEdit;
},
},
{
@@ -42,7 +42,7 @@ export function GroupContents() {
className: "delete",
onSelect: handleDeleteContent,
hidden() {
- return groupContext?.group.admin.id !== groupContext?.loggedData.profile.id;
+ return !groupContext?.group.canEdit;
},
}
]
@@ -53,12 +53,10 @@ export function GroupContents() {
{
- authContext.profile?.id == groupContext.group.admin.id || authContext.profile?.id == groupContext.group.organization?.admin.id ?
+ groupContext.group.canEdit &&
- :
- <>>
}
diff --git a/src/pages/ManageProfile/ManageProfile.tsx b/src/pages/ManageProfile/ManageProfile.tsx
index 2d5c6ab8..b059d938 100644
--- a/src/pages/ManageProfile/ManageProfile.tsx
+++ b/src/pages/ManageProfile/ManageProfile.tsx
@@ -110,6 +110,24 @@ export function ManageProfilePage() {
}
}
+ const { value: password, isConfirmed } = await SwalUtils.fireModal({
+ title: "Edição de perfil",
+ input: "password",
+ inputLabel: "Inserir senha para salvar as alterações",
+ inputPlaceholder: "Insira sua senha",
+ confirmButtonText: "Confirmar Alterações",
+ showCancelButton: true,
+ cancelButtonText: "Cancelar",
+ allowOutsideClick: true,
+ showCloseButton: true,
+ inputAttributes: {
+ autocapitalize: "off",
+ autocorrect: "off"
+ }
+ });
+ if (!isConfirmed)
+ return;
+
UniversimeApi.Profile.edit({
profileId: profile.id,
name: firstname,
@@ -117,19 +135,14 @@ export function ManageProfilePage() {
bio,
gender: gender || undefined,
imageUrl: newImageUrl,
+ rawPassword: password,
}).then(async res => {
if (!res.success)
throw new Error(res.message);
const p = await authContext.updateLoggedUser();
navigate(`/profile/${p!.user.name}`);
- }).catch((reason: Error) => {
- SwalUtils.fireModal({
- title: "Erro ao salvar alterações de perfil",
- text: reason.message,
- icon: 'error',
- });
- })
+ })
}
function submitLinkChanges(e: MouseEvent