temporary server action for group and inside

This commit is contained in:
2024-05-17 15:33:15 +07:00
parent c1a019a461
commit 3c37fbf59b
6 changed files with 60 additions and 22 deletions

View File

@@ -7,14 +7,15 @@ type Props = {
export default function IdComponent({ updateIdList }: Props) {
const [idSet, setIdSet] = useState<Set<string>>(new Set());
const onValidId = (id: string) => {
setIdSet((prev) => new Set(prev.add(id)));
const newSet = new Set(idSet.add(id));
setIdSet(newSet);
updateIdList([...newSet]);
};
const removeCid = (id: string) => {
setIdSet((prev) => new Set([...prev].filter((x) => x !== id)));
const newSet = new Set([...idSet].filter((x) => x !== id));
setIdSet(newSet);
updateIdList([...newSet]);
};
useEffect(() => {
updateIdList([...idSet]);
}, [idSet, updateIdList]);
return (
<div className="flex justify-center">
<div className="flex flex-col gap-2">