From af234e4383dd7796281e7aed556091ddec1e49fb Mon Sep 17 00:00:00 2001 From: kokodev Date: Wed, 30 Oct 2024 09:02:39 -0700 Subject: [PATCH] Update ServerLimitationBar.tsx --- .../elements/server/ServerLimitationBar.tsx | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/resources/scripts/components/elements/server/ServerLimitationBar.tsx b/resources/scripts/components/elements/server/ServerLimitationBar.tsx index 08c34123a..48a033460 100644 --- a/resources/scripts/components/elements/server/ServerLimitationBar.tsx +++ b/resources/scripts/components/elements/server/ServerLimitationBar.tsx @@ -8,7 +8,7 @@ import Spinner from '@/components/elements/Spinner'; import ContentBox from '@/components/elements/ContentBox'; import Tooltip from '@/components/elements/tooltip/Tooltip'; import StoreContainer from '@/components/elements/StoreContainer'; -import { useServerContext } from '@/state/server'; // Import the custom hook +import { ServerContext } from '@/state/server'; const Wrapper = styled.div` ${tw`text-2xl flex flex-row justify-center items-center`}; @@ -29,14 +29,10 @@ interface BoxProps { } export default ({ className, titles }: RowProps) => { - const serverData = useServerContext(); // Access server data through context + const limits = ServerContext.useStoreState((state) => state.server.data!.limits); + const featureLimits = ServerContext.useStoreState((state) => state.server.data!.featureLimits); const [limits, setLimits] = useState(null); - useEffect(() => { - if (serverData) { - setLimits(serverData.limits); - } - }, [serverData]); if (!limits) return ; @@ -56,56 +52,44 @@ export default ({ className, titles }: RowProps) => { return ( - } - amount={limits.credits || 0} - /> } amount={limits.cpu || 0} suffix={'%'} /> } amount={limits.memory || 0} toHuman /> } amount={limits.disk || 0} toHuman /> - } - amount={limits.slots || 0} - /> } - amount={limits.ports || 0} + amount={featureLimits.allocations || 0} /> } - amount={limits.backups || 0} + amount={featureLimits.backups || 0} /> } - amount={limits.databases || 0} + amount={featureLimits.databases || 0} /> );