mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
types.ts
This commit is contained in:
parent
7c47a93bd9
commit
5dd17f9f1b
14
app/types.ts
Normal file
14
app/types.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export interface Site {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
networks: Network[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Network {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
ipv4Subnet?: string;
|
||||||
|
ipv6Subnet?: string;
|
||||||
|
gateway?: string;
|
||||||
|
}
|
||||||
@ -1,22 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Site } from "@/app/types";
|
||||||
|
|
||||||
interface SitesProps {
|
export default function Sites({ id, name, description, networks }: Site) {
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
networks: Network[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Network {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
ipv4Subnet?: string;
|
|
||||||
ipv6Subnet?: string;
|
|
||||||
gateway?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Sites({ id, name, description, networks }: SitesProps) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
<div className="card bg-base-200 shadow-xl">
|
<div className="card bg-base-200 shadow-xl">
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
import { useState, useEffect, useCallback } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { Network } from "@/app/types";
|
||||||
interface AddNetwork {
|
|
||||||
siteId: number;
|
|
||||||
name: string;
|
|
||||||
ipv4Subnet: string;
|
|
||||||
ipv6Subnet: string;
|
|
||||||
gateway: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const useNetworks = () => {
|
const useNetworks = () => {
|
||||||
|
|
||||||
const addNetwork = (network: AddNetwork) => {
|
const addNetwork = (network: Network) => {
|
||||||
axios.post('/api/sites/networks/add', network);
|
axios.post('/api/sites/networks/add', network);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteNetwork = (networkId: number) => {
|
const deleteNetwork = (networkId: string) => {
|
||||||
axios.delete('/api/sites/networks/delete', {
|
axios.delete('/api/sites/networks/delete', {
|
||||||
params: { networkId }
|
params: { networkId }
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,24 +1,10 @@
|
|||||||
import { useState, useEffect, useCallback } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { Site } from "@/app/types";
|
||||||
interface Network {
|
|
||||||
id?: number;
|
|
||||||
name: string;
|
|
||||||
ipv4Subnet?: string;
|
|
||||||
ipv6Subnet?: string;
|
|
||||||
gateway?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Site {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
networks: Network[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const useSite = () => {
|
const useSite = () => {
|
||||||
const [site, setSite] = useState<Site>({
|
const [site, setSite] = useState<Site>({
|
||||||
id: 0,
|
id: "",
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
networks: []
|
networks: []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user