Skip to content

Commit

Permalink
Merge branch 'main' into new/registration
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnypaulino authored Jul 2, 2024
2 parents 72f3f2e + d0b58fa commit 63ce222
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Components/Layout/TopBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TopBar = ({
</Column>
<Column style={{ width: "auto" }} id="center">
<Row>
<Column className="w-12rem md:w-16rem">
<Column className="w-12rem md:w-20rem">
{props.project ? (
<DropdownComponent
placerholder="Projetos"
Expand Down
13 changes: 4 additions & 9 deletions src/Pages/Users/CreateUser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ const CreateUserPage = () => {
const props = useContext(UsersContext) as UsersTypes;

const CreateUserSchema = Yup.object().shape({
name: Yup.string()
.required("Campo Obrigatório")
.min(16, "Nome deve ter pelo menos 16 caracteres"),
username: Yup.string()
.required("Campo Obrigatório")
.min(8, "Nome do usuário deve ter pelo menos 8 caracteres"),
password: Yup.string()
.required("Campo Obrigatório")
.min(8, "Senha deve ter pelo menos 8 caracteres"),

name: Yup.string().required("Campo Obrigatório").min(8, "Nome deve ter pelo menos 8 caracteres"),
username: Yup.string().required("Campo Obrigatório").min(8, "Nome do usuário deve ter pelo menos 8 caracteres"),
password: Yup.string().required("Campo Obrigatório").min(8, "Senha deve ter pelo menos 8 caracteres"),
role: Yup.object().required("Campo Obrigatório"),
project: Yup.array().required("Campo Obrigatório"),
initial_date: Yup.string().required("Campo Obrigatório"),
Expand Down
29 changes: 26 additions & 3 deletions src/Pages/Users/ListUsers.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Button } from "primereact/button";
import { Column } from "primereact/column";
import { ConfirmDialog } from "primereact/confirmdialog";
import { DataTable } from "primereact/datatable";
import { useContext } from "react";
import { useContext, useState } from "react";
import { useNavigate } from "react-router-dom";
import ContentPage from "../../Components/ContentPage";

import Loading from "../../Components/Loading";
import UsersProvider, { UsersContext } from "../../Context/Users/context";
import { UsersTypes } from "../../Context/Users/type";
import { ROLE } from "../../Controller/controllerGlobal";
import { Padding } from "../../Styles/styles";
import { Container, Padding } from "../../Styles/styles";

const ListUsers = () => {
return (
Expand All @@ -21,6 +23,8 @@ const ListUsers = () => {
const ListUsersPage = () => {
const props = useContext(UsersContext) as UsersTypes;
const history = useNavigate();

const [visible, setVisible] = useState<any>(false)
// const actionBodyTemplate = (rowData: any) => {

// return (
Expand Down Expand Up @@ -53,21 +57,40 @@ const ListUsersPage = () => {
);
};

const ActionsUserBody = (rowData: any) => {
return (
<Button severity="danger" rounded icon={"pi pi-trash"} onClick={() => {setVisible(rowData)}} />
);
};

if (props.isLoading) return <Loading />;


return (
<Container>
<ContentPage title="Usuários" description="Lista usuários do MeuBen.">
<Padding padding="16px" />
<Button label="Criar usuário" onClick={() => history("/users/criar")} />
<Padding padding="16px" />
<DataTable value={props.users} tableStyle={{ minWidth: "50rem" }}>
<DataTable value={props.users} paginator rows={10} rowsPerPageOptions={[5, 10, 25, 50]} tableStyle={{ minWidth: "50rem" }}>
<Column field="name" header="Nome"></Column>
<Column field="username" header="Usuário"></Column>
<Column field="role" body={typeUserBody} header="Tipo"></Column>
<Column field="active" body={ActiveUserBody} header="Ativo"></Column>
<Column field="actions" body={ActionsUserBody} header="Ações"></Column>

</DataTable>
</ContentPage>
<ConfirmDialog
visible={visible}
onHide={() => setVisible(false)}
message="Tem certeza de que deseja prosseguir?"
header="Confirmation"
icon="pi pi-exclamation-triangle"
accept={() => props.DeleteUser(visible?.id)}
reject={() => setVisible(false)}
/>
</Container>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Users/controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ControllerUser = () => {
onSuccess: (data) => {
Swal.fire({
icon: "success",
title: "Registro feito com sucesso!",
title: "Usuário excluido com sucesso!",
confirmButtonColor: styles.colors.colorsBaseProductNormal,
}).then((result) => {
queryClient.refetchQueries("useRequestsUsers")
Expand Down

0 comments on commit 63ce222

Please sign in to comment.