Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#516 [FEAT]: Checagem de permissão em conformidade com novo protocolo de controle de acesso da API #519

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Addbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function AddBar(props) {
id="item-target-page"
value={pageIndex}
className="form-select rounded-4 text-center text-white bg-steel-blue fs-6 fw-medium border-0"
onChange={(e) => setItemTarget((prev) => ({ group: '', page: e.target.value }))}
onChange={(e) => setItemTarget(() => ({ group: '', page: e.target.value }))}
>
<option value={''}>Página...</option>
{protocol.pages.map((page, index) => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateProcotolProperties.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function CreateProtocolProperties(props) {
setSearchedOptions((prev) => ({ ...prev, appliers: newUsers }));
}
})
.catch((error) => showAlert({ headerText: 'Erro ao buscar usuários.', bodyText: error.response?.data.message }));
.catch((error) => showAlert({ headerText: 'Erro ao buscar usuários', bodyText: error.response?.data.message }));
};

const searchClassrooms = (term, target) => {
Expand Down Expand Up @@ -118,7 +118,7 @@ function CreateProtocolProperties(props) {
setSearchedOptions((prev) => ({ ...prev, answersViewersClassroom: concatenedClassrooms }));
}
})
.catch((error) => showAlert({ headerText: 'Erro ao buscar grupos.', bodyText: error.response?.data.message }));
.catch((error) => showAlert({ headerText: 'Erro ao buscar grupos', bodyText: error.response?.data.message }));
};

const unselectUser = (id, target) => {
Expand Down
26 changes: 8 additions & 18 deletions src/pages/ApplicationAnswersPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,21 @@ function AnswerPage(props) {
if (isLoading && user.status !== 'loading') {
axios
.get(`${process.env.REACT_APP_API_URL}api/application/getApplicationWithAnswers/${applicationId}`, {
headers: {
Authorization: `Bearer ${user.token}`,
},
headers: { Authorization: `Bearer ${user.token}` },
})
.then((response) => {
setAnswer(response.data.data);
setIsLoading(false);
})
.catch((error) => {
setError({ text: 'Erro ao carregar respostas de aplicação', description: error.response?.data.message || '' });
});
.catch((error) =>
setError({ text: 'Erro ao obter respostas da aplicação', description: error.response?.data.message || '' })
);
}
}, [applicationId, isLoading, user.status, user.token]);

if (error) {
return <ErrorPage text={error.text} description={error.description} />;
}
if (error) return <ErrorPage text={error.text} description={error.description} />;

if (isLoading) {
return <SplashPage text="Carregando respostas de aplicação..." />;
}
if (isLoading) return <SplashPage text="Carregando respostas da aplicação..." />;

// Função de exportar csv
const createFile = (modalRef) => {
Expand Down Expand Up @@ -321,11 +315,7 @@ function AnswerPage(props) {
.put(
`${process.env.REACT_APP_API_URL}api/applicationAnswer/approveApplicationAnswer/${applicationAnswerId}`,
{},
{
headers: {
Authorization: `Bearer ${user.token}`,
},
}
{ headers: { Authorization: `Bearer ${user.token}` } }
)
.then((response) => {
showAlert({ headerText: 'Resposta aprovada com sucesso', message: response.data.message });
Expand Down Expand Up @@ -399,7 +389,7 @@ function AnswerPage(props) {
{value.user.username + ' - ' + new Date(value.date).toLocaleDateString()}
</a>
</div>
{value.approved !== true && (
{value.approved !== true && answer.actions.toApproveAnswers === true && (
<div className="col-auto">
<RoundedButton
hsl={[97, 43, 70]}
Expand Down
Loading