import NodeConfigurationContainer from '@/components/admin/nodes/NodeConfigurationContainer'; import React, { useEffect, useState } from 'react'; import { useLocation } from 'react-router'; import tw from 'twin.macro'; import { Route, Switch, useRouteMatch } from 'react-router-dom'; import { action, Action, Actions, createContextStore, useStoreActions } from 'easy-peasy'; import { Node } from '@/api/admin/nodes/getNodes'; import getNode from '@/api/admin/nodes/getNode'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; import Spinner from '@/components/elements/Spinner'; import FlashMessageRender from '@/components/FlashMessageRender'; import { ApplicationStore } from '@/state'; import { SubNavigation, SubNavigationLink } from '@/components/admin/SubNavigation'; import AdminBox from '@/components/admin/AdminBox'; import NodeLimitContainer from '@/components/admin/nodes/NodeLimitContainer'; import NodeSettingsContainer from '@/components/admin/nodes/NodeSettingsContainer'; interface ctx { node: Node | undefined; setNode: Action; } export const Context = createContextStore({ node: undefined, setNode: action((state, payload) => { state.node = payload; }), }); const Code = ({ children }: { children: React.ReactNode }) => { return ( {children} ); }; const NodeEditContainer = () => { const location = useLocation(); const match = useRouteMatch<{ id?: string }>(); const { clearFlashes, clearAndAddHttpError } = useStoreActions((actions: Actions) => actions.flashes); const [ loading, setLoading ] = useState(true); const node = Context.useStoreState(state => state.node); const setNode = Context.useStoreActions(actions => actions.setNode); useEffect(() => { clearFlashes('node'); getNode(Number(match.params?.id), [ 'database_host', 'location' ]) .then(node => setNode(node)) .catch(error => { console.error(error); clearAndAddHttpError({ key: 'node', error }); }) .then(() => setLoading(false)); }, []); if (loading || node === undefined) { return (
); } return (

{node.name}

{node.uuid}

Version 1.2.2

Allocations

Servers

); }; export default () => { return ( ); };