Skip to content

Commit

Permalink
network name
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Aug 6, 2023
1 parent 5059557 commit f3d4b94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/components/modules/networkName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const updateCache = ({
}: {
client: QueryClient;
input: RouterInputs["network"]["getNetworkById"];
data: NetworkEntity | Partial<CentralNetwork>;
data: Partial<NetworkEntity> | Partial<CentralNetwork>;
}) => {
client.setQueryData(
[
Expand Down
14 changes: 1 addition & 13 deletions src/pages/network/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRouter } from "next/router";
import { useEffect, useState, type ReactElement } from "react";
import { useState, type ReactElement } from "react";
import { LayoutAuthenticated } from "~/components/layouts/layout";
import { NettworkRoutes } from "~/components/modules/networkRoutes";
import { NetworkMembersTable } from "~/components/modules/table/networkMembersTable";
Expand Down Expand Up @@ -27,10 +27,6 @@ const NetworkById = () => {
const t = useTranslations("networkById");
const [state, setState] = useState({
viewZombieTable: false,
editNetworkName: false,
toggleDescriptionInput: false,
description: "",
networkName: "",
});
const { callModal } = useModalStore((state) => state);
const { query, push: router } = useRouter();
Expand All @@ -46,14 +42,6 @@ const NetworkById = () => {
{ enabled: !!query.id, refetchInterval: 10000 }
);

useEffect(() => {
setState((prev) => ({
...prev,
description: networkById?.network?.description,
networkName: networkById?.network?.name,
}));
}, [networkById?.network?.description, networkById?.network?.name]);

const { network, members = [] } = networkById || {};
if (loadingNetwork) {
// add loading progress bar to center of page, vertially and horizontally
Expand Down
12 changes: 10 additions & 2 deletions src/server/api/routers/networkRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export const networkRouter = createTRPCRouter({
}),
})
)
.mutation(async ({ input }) => {
.mutation(async ({ ctx, input }) => {
const updateParams = input.central
? { config: { ...input.updateParams } }
: { ...input.updateParams };
Expand All @@ -444,7 +444,15 @@ export const networkRouter = createTRPCRouter({
const { id: nwid, config, ...otherProps } = updated as CentralNetwork;
return { nwid, ...config, ...otherProps } as Partial<CentralNetwork>;
} else {
return updated as NetworkEntity;
// Update network in prisma as description is not part of the local controller network object.
await ctx.prisma.network.update({
where: { nwid: input.nwid },
data: {
...input.updateParams,
},
});

return updated;
}
}),
networkDescription: protectedProcedure
Expand Down

0 comments on commit f3d4b94

Please sign in to comment.