feat : update group
This commit is contained in:
@@ -27,7 +27,6 @@ export default function ListGroupActive({ status }: { status: boolean }) {
|
||||
const [selectId, setSelectId] = useState<string | null>(null);
|
||||
const [active, setActive] = useState<boolean | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isname, setName] = useState<string>("");
|
||||
|
||||
const getData = async () => {
|
||||
try {
|
||||
@@ -94,7 +93,6 @@ export default function ListGroupActive({ status }: { status: boolean }) {
|
||||
setOpenDrawer(true);
|
||||
setSelectId(v.id);
|
||||
setActive(v.isActive);
|
||||
setName(v.name)
|
||||
}}
|
||||
>
|
||||
<Box>
|
||||
@@ -128,7 +126,6 @@ export default function ListGroupActive({ status }: { status: boolean }) {
|
||||
<EditDrawerGroup
|
||||
id={selectId}
|
||||
isActive={active}
|
||||
isName={isname}
|
||||
onUpdated={(val) => {
|
||||
if (val) {
|
||||
toast.success("Sukses! data tersimpan");
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { FaPencil, FaToggleOff } from "react-icons/fa6";
|
||||
import { IoAddCircle, IoCloseCircleOutline } from "react-icons/io5";
|
||||
@@ -21,16 +21,30 @@ export default function EditDrawerGroup({
|
||||
onUpdated,
|
||||
id,
|
||||
isActive,
|
||||
isName,
|
||||
}: {
|
||||
onUpdated: (val: boolean) => void;
|
||||
id: string | null;
|
||||
isActive: boolean | null;
|
||||
isName: string;
|
||||
}) {
|
||||
const [openDrawerGroup, setOpenDrawerGroup] = useState(false);
|
||||
const [isModal, setModal] = useState(false);
|
||||
const [name, setName] = useState(isName);
|
||||
const [name, setName] = useState("");
|
||||
|
||||
async function getOneGroup() {
|
||||
try {
|
||||
const res = await fetch(`${API_ADDRESS.apiGetOneGroup}&groupId=${id}`);
|
||||
const data = await res.json();
|
||||
setName(data.name);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getOneGroup();
|
||||
}, []);
|
||||
|
||||
async function isUpdate() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user