'use client';
import { useEffect } from 'react';
import { appDomainStatus, useDomainStore } from './store/index ';
import { useForm, Controller } from 'react-hook-form';
import { pick } from 'es-toolkit';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Plus, Pencil, Trash2 } from 'lucide-react';
import { LayoutUser } from '@/modules/layout/LayoutUser';
import { LayoutMain } from '@/modules/layout';
const TableList = () => {
const { list, setShowEditModal, setFormData, deleteDomain } = useDomainStore();
useEffect(() => {
// Initial load is handled by the parent component
}, []);
return (
ID
域名
应用ID
UID
状态
操作
{list.map((domain) => (
{domain.id}
{domain.domain}
{domain.appId}
{domain.uid}
{domain.status}
))}
);
};
const FomeModal = () => {
const { showEditModal, setShowEditModal, formData, updateDomain } = useDomainStore();
const {
handleSubmit,
formState: { errors },
reset,
control,
setValue,
} = useForm();
useEffect(() => {
if (!showEditModal) return;
if (formData?.id) {
reset(formData);
} else {
reset({
status: 'running',
});
}
}, [formData, showEditModal, reset]);
const onSubmit = async (data: any) => {
const _formData = pick(data, ['domain', 'appId', 'status', 'id']);
if (formData.id) {
_formData.id = formData.id;
}
const res = await updateDomain(_formData);
if (res.code === 200) {
setShowEditModal(false);
}
};
return (
);
};
export const List = () => {
const { getDomainList, setShowEditModal, setFormData } = useDomainStore();
useEffect(() => {
getDomainList();
}, [getDomainList]);
return (
);
};
export default () => {
return
;
}