Skip to content

Commit

Permalink
Added DnD to step and reading layers
Browse files Browse the repository at this point in the history
  • Loading branch information
farisdurrani committed Sep 8, 2023
1 parent 622d132 commit 84585b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
13 changes: 0 additions & 13 deletions frontend/src/features/Train/components/CreateTrainspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import { useAppDispatch } from "@/common/redux/hooks";
import { useRouter } from "next/router";
import {
ALL_TRAINSPACE_SETTINGS,
DATA_SOURCE_ARR,
IMPLEMENTED_DATA_SOURCE_ARR,
} from "../constants/trainConstants";
import { createTrainspaceData } from "../redux/trainspaceSlice";
import TabularDnd from "../features/Tabular/components/TabularDnd";
import { ParameterData } from "../features/Tabular/types/tabularTypes";
const CreateTrainspace = () => {
const {
handleSubmit,
Expand All @@ -34,8 +31,6 @@ const CreateTrainspace = () => {
}
}, [router.isReady]);

const [layers, setLayers] = React.useState<ParameterData["layers"]>([]);

return (
<Grid
container
Expand All @@ -45,14 +40,6 @@ const CreateTrainspace = () => {
justifyContent="center"
style={{ minHeight: "100vh" }}
>
<Button
onClick={() => {
console.log(layers);
}}
>
Get layers
</Button>
<TabularDnd setLayers={setLayers} />
<Grid item>
<Typography variant="h1" fontSize={50}>
Create a Trainspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function TabularDnd(props: TabularDndProps) {
type: "textUpdater",
position: {
x: DEFAULT_X_POSITION,
y: (i + 1) * 125,
y: (i + 1) * 100,
},
data: {
label: STEP_SETTINGS.PARAMETERS.layers[layer.value].label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const TabularParametersStep = ({
formState: { errors, isDirty },
control,
watch,
setValue,
} = useForm<ParameterData>({
defaultValues: {
targetCol:
Expand All @@ -108,9 +109,11 @@ const TabularParametersStep = ({
useEffect(() => {
setIsModified(isDirty);
}, [isDirty]);
if (!trainspace) return <></>;
if (!trainspace) return null;
const targetCol = watch("targetCol");
const features = watch("features");
const [layers, setLayers] = React.useState<ParameterData["layers"]>([]);

return (
<Stack spacing={3}>
{error ? (
Expand Down Expand Up @@ -307,8 +310,9 @@ const TabularParametersStep = ({
/>
</FormControl>
<LayersDnd control={control} errors={errors} />
<TabularDnd />
<TabularDnd setLayers={setLayers} />
{renderStepperButtons((trainspaceData) => {
setValue("layers", layers);
handleSubmit((data) => {
dispatch(
updateTabularTrainspaceData({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ const TrainspaceStepInner = ({
});
}
}, [trainspace]);
if (!Component) return <></>;

if (!Component) return null;
return (
<Component
renderStepperButtons={(submitTrainspace) => (
Expand Down

0 comments on commit 84585b0

Please sign in to comment.