Skip to content
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
12 changes: 4 additions & 8 deletions frontend/src/components/forms/ExpenseForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ButtonUI from '../../ui/Button';
import CustomSplitAmount from './CustomSplitAmount';
import { useFormExpense } from './useForm';
import { useEffect, useState, useCallback, useMemo } from 'react';

Check failure on line 6 in frontend/src/components/forms/ExpenseForm/index.jsx

View workflow job for this annotation

GitHub Actions / Frontend (React)

'useMemo' is defined but never used. Allowed unused vars must match /^[A-Z_]/u
import { customToast } from '../../CustomToast';
import Modal from '../../Modal';
import ListMembers from './ListMembers';
Expand Down Expand Up @@ -41,7 +41,7 @@
const handleExpenseSubmit = useCallback(
async e => {
e.preventDefault();

if (isSubmitting) return;
if (!distributionOK) {
return customToast(
'Erro',
Expand Down Expand Up @@ -92,7 +92,7 @@
setIsSubmitting(false);
}
},
[amount, divisionAmount, distributionOK]
[amount, divisionAmount, distributionOK, isSubmitting]

Check warning on line 95 in frontend/src/components/forms/ExpenseForm/index.jsx

View workflow job for this annotation

GitHub Actions / Frontend (React)

React Hook useCallback has a missing dependency: 'useExpenseMutation'. Either include it or remove the dependency array
);

const removeMember = memberId => {
Expand Down Expand Up @@ -169,16 +169,12 @@
)}

{/* Botão de envio */}
<div className="col-span-2 mt-4">
<div className="col-span-2 mt-4 w-full flex justify-end">
<ButtonUI
type="submit"
disabled={isSubmitting || !distributionOK || amount <= 0}
aria-disabled={isSubmitting || !distributionOK || amount <= 0}
className={`bg-primary hover:bg-secondary text-white py-3 px-6 rounded w-full sm:w-auto font-semibold transition ${
isSubmitting || !distributionOK || amount <= 0
? 'opacity-50 bg-gray-400! cursor-not-allowed!'
: 'cursor-pointer'
}`}
className={`bg-primary hover:bg-secondary text-white cursor-pointer disabled:bg-muted/20 disabled:cursor-not-allowed py-3 px-6 rounded w-full sm:w-auto font-semibold transition`}
>
{isSubmitting ? 'Enviando...' : 'Adicionar Despesa'}
</ButtonUI>
Expand Down
23 changes: 13 additions & 10 deletions frontend/src/components/forms/GroupForm.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useCallback, useState } from 'react';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import InputUI from '../ui/Input';
import ButtonUI from '../ui/Button';
Expand Down Expand Up @@ -46,15 +46,18 @@
const IconComponent = entry.icon;
const iconColor = entry.color;

const handleSubmit = async e => {
e.preventDefault();

mutateAsync({
name: groupName,
description,
icon: selectedIcon,
});
};
const handleSubmit = useCallback(
async e => {
e.preventDefault();
if (isPending || isDisabled) return;
mutateAsync({
name: groupName,
description,
icon: selectedIcon,
});
},
[isPending, isDisabled]

Check warning on line 59 in frontend/src/components/forms/GroupForm.jsx

View workflow job for this annotation

GitHub Actions / Frontend (React)

React Hook useCallback has missing dependencies: 'description', 'groupName', 'mutateAsync', and 'selectedIcon'. Either include them or remove the dependency array
);

return (
<Form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export function useDeleteGroupMemberMutation(groupID, page, search) {
});
customToast('Membro removido', 'Membro removido com sucesso.', 'success');
},
onError: () => {
onError: error => {
customToast(
'Erro ao excluir o membro do grupo',
'Não foi possível excluir o membro do grupo. Tente novamente.',
error.response?.data?.message ||
'Não foi possível excluir o membro do grupo. Tente novamente.',
'error'
);
},
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/pages/Groups/GroupDetails/AddMember.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,16 @@ export default function AddMemberForm({ onSubmit, onCancel }) {
<ButtonUI
type="button"
onClick={onCancel}
className="px-6 py-2 rounded-lg font-semibold shadow-md bg-muted text-white hover:bg-muted/80 transition"
className="px-6 py-2 cursor-pointer rounded-lg font-semibold shadow-md bg-muted text-white hover:bg-muted/80 transition"
>
Cancelar
</ButtonUI>
)}
<ButtonUI
type="submit"
disabled={isSubmitDisabled}
className={`px-6 py-2 rounded-lg font-semibold shadow-md text-white transition ${
isSubmitDisabled
? 'bg-primary/60 cursor-not-allowed opacity-70'
: 'bg-primary hover:bg-primary/90 active:bg-primary-dark'
}`}
className={`px-6 py-2 disabled:bg-muted/20 disabled:cursor-not-allowed cursor-pointer rounded-lg font-semibold shadow-md text-white transition bg-primary hover:bg-primary/90 active:bg-primary-dark
`}
>
{isSubmitting ? 'Adicionando...' : 'Adicionar'}
</ButtonUI>
Expand Down
Loading