refactor: add explicit any
types and improve readability in group state handling
- Updated `setProject` function in `page.tsx` to include explicit `(prev: any)` and `(group: any)` type annotations for better readability. - Added `"use client";` directive to `notifications.tsx` for React server-client compatibility. - Improved structural consistency and clarity in group and person state updates.
This commit is contained in:
parent
2851fb3dfa
commit
6cc6506e6f
@ -156,7 +156,7 @@ export default function ProjectGroupsPage() {
|
||||
|
||||
if (data.action === "created" && data.group) {
|
||||
// Add the new group to the list
|
||||
setProject(prev => ({
|
||||
setProject((prev: any) => ({
|
||||
...prev,
|
||||
groups: [...prev.groups, data.group]
|
||||
}));
|
||||
@ -179,9 +179,9 @@ export default function ProjectGroupsPage() {
|
||||
|
||||
if (data.action === "updated" && data.group) {
|
||||
// Update the group in the list
|
||||
setProject(prev => ({
|
||||
setProject((prev: any) => ({
|
||||
...prev,
|
||||
groups: prev.groups.map(group =>
|
||||
groups: prev.groups.map((group: any) =>
|
||||
group.id === data.group.id ? data.group : group
|
||||
)
|
||||
}));
|
||||
@ -189,9 +189,9 @@ export default function ProjectGroupsPage() {
|
||||
toast.info(`Groupe mis à jour: ${data.group.name}`);
|
||||
} else if (data.action === "deleted" && data.group) {
|
||||
// Remove the group from the list
|
||||
setProject(prev => ({
|
||||
setProject((prev: any) => ({
|
||||
...prev,
|
||||
groups: prev.groups.filter(group => group.id !== data.group.id)
|
||||
groups: prev.groups.filter((group: any) => group.id !== data.group.id)
|
||||
}));
|
||||
|
||||
toast.info(`Groupe supprimé: ${data.group.name}`);
|
||||
@ -212,9 +212,9 @@ export default function ProjectGroupsPage() {
|
||||
|
||||
if (data.group && data.person) {
|
||||
// Update the group with the new person
|
||||
setProject(prev => ({
|
||||
setProject((prev: any) => ({
|
||||
...prev,
|
||||
groups: prev.groups.map(group => {
|
||||
groups: prev.groups.map((group: any) => {
|
||||
if (group.id === data.group.id) {
|
||||
return {
|
||||
...group,
|
||||
@ -243,13 +243,13 @@ export default function ProjectGroupsPage() {
|
||||
|
||||
if (data.group && data.person) {
|
||||
// Update the group by removing the person
|
||||
setProject(prev => ({
|
||||
setProject((prev: any) => ({
|
||||
...prev,
|
||||
groups: prev.groups.map(group => {
|
||||
groups: prev.groups.map((group: any) => {
|
||||
if (group.id === data.group.id) {
|
||||
return {
|
||||
...group,
|
||||
persons: group.persons.filter(person => person.id !== data.person.id)
|
||||
persons: group.persons.filter((person: any) => person.id !== data.person.id)
|
||||
};
|
||||
}
|
||||
return group;
|
||||
|
@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSocket } from "@/lib/socket-context";
|
||||
import { toast } from "sonner";
|
||||
@ -60,4 +62,4 @@ export function NotificationsListener() {
|
||||
|
||||
// This component doesn't render anything visible
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user