forked from fga-eps-mds/2024.1-CALCULUS-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fga-eps-mds/2024.2-ARANDU-DOC#66): testes de funcoes
- Loading branch information
1 parent
a0a5ce3
commit 6b33da2
Showing
4 changed files
with
133 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// subjectFunctions.ts | ||
import { Subject } from '@/lib/interfaces/subjetc.interface'; | ||
|
||
export const updateSubject = (subject: Subject, listSubjects: Subject[], setListSubjects: React.Dispatch<React.SetStateAction<Subject[]>>) => { | ||
// Verificar se listSubjects não é undefined ou null | ||
if (listSubjects && Array.isArray(listSubjects)) { | ||
setListSubjects( | ||
listSubjects.map((s) => (s._id === subject._id ? subject : s)), | ||
); | ||
} | ||
}; | ||
|
||
export const addSubject = ( | ||
subject: Subject, | ||
listSubjects: Subject[], | ||
setListSubjects: React.Dispatch<React.SetStateAction<Subject[]>> | ||
) => { | ||
// Verificar se listSubjects não é undefined ou null | ||
if (listSubjects && Array.isArray(listSubjects)) { | ||
setListSubjects( | ||
[...listSubjects, subject].sort((a, b) => a.order - b.order), | ||
); | ||
} | ||
}; | ||
|
||
export const handleSubjectAction = ( | ||
action: string, | ||
setEditionDialogOpen: React.Dispatch<React.SetStateAction<boolean>>, | ||
setExclusionDialogOpen: React.Dispatch<React.SetStateAction<boolean>> | ||
) => { | ||
if (action === 'editar') { | ||
setEditionDialogOpen(true); | ||
} | ||
if (action === 'excluir') { | ||
setExclusionDialogOpen(true); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters