Skip to content

Commit

Permalink
wip form
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-coulon committed Sep 23, 2023
1 parent bd1a39d commit 3c33510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions apps/web/src/sidebar/graph-configuration/GraphConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { createFormContext } from "@mantine/form";
import { callUseCase } from "@/store/store";
import { updateConfiguration } from "@/core/network/update-configuration";
import { useStoreSelect } from "@/store/react-bindings";

const availableLayouts = ["cluster", "hierarchical"] as const;
type AvailableLayouts = (typeof availableLayouts)[number];
Expand Down Expand Up @@ -94,13 +95,18 @@ function GraphOptions({ layout }: { layout: AvailableLayouts }) {
}

export function GraphConfiguration() {
const network = useStoreSelect("ui", "network");
const [selectedLayout, setSelectedLayout] =
React.useState<AvailableLayouts>("cluster");

React.useEffect(() => {
console.log("mount");
}, []);

const form = useForm({
initialValues: {
layout: {
selected: "cluster",
selected: network?.layout.type,
cluster: {
spacing_algorithm: "repulsion",
node_spacing: 40,
Expand Down Expand Up @@ -141,8 +147,8 @@ export function GraphConfiguration() {

<SegmentedControl
mt="md"
defaultValue={selectedLayout}
{...form.getInputProps("layout.selected")}
defaultValue={network?.layout.type ?? selectedLayout}
onChange={(value) => {
setSelectedLayout(value as AvailableLayouts);
form.getInputProps("layout.selected").onChange(value);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/store/react-bindings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { map } from "rxjs";
import { map, tap } from "rxjs";

import { AppEffects, AppStore, AppStoreInstance } from "./store";
import { AppState } from "./state";
Expand Down

0 comments on commit 3c33510

Please sign in to comment.