Deleted variables page
This commit is contained in:
parent
6dc4599a9b
commit
41cbd918b7
4 changed files with 10 additions and 77 deletions
|
|
@ -24,7 +24,7 @@ import {
|
|||
OUTPUT_HANDLER_HOVER,
|
||||
TOOLTIP_EMPTY,
|
||||
} from "../../../../constants/constants";
|
||||
import AddNewVariableButton from "../../../../pages/globalVariablesPage/components/addNewVariableButton";
|
||||
import AddNewVariableButton from "../../../../components/addNewVariableButtonComponent/addNewVariableButton";
|
||||
import useAlertStore from "../../../../stores/alertStore";
|
||||
import useFlowStore from "../../../../stores/flowStore";
|
||||
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { useState } from "react";
|
||||
import ForwardedIconComponent from "../../../components/genericIconComponent";
|
||||
import InputComponent from "../../../components/inputComponent";
|
||||
import { Button } from "../../../components/ui/button";
|
||||
import { Input } from "../../../components/ui/input";
|
||||
import { Label } from "../../../components/ui/label";
|
||||
import { Textarea } from "../../../components/ui/textarea";
|
||||
import { registerGlobalVariable } from "../../../controllers/API";
|
||||
import BaseModal from "../../../modals/baseModal";
|
||||
import { useGlobalVariablesStore } from "../../../stores/globalVariables";
|
||||
import ForwardedIconComponent from "../genericIconComponent";
|
||||
import InputComponent from "../inputComponent";
|
||||
import { Button } from "../ui/button";
|
||||
import { Input } from "../ui/input";
|
||||
import { Label } from "../ui/label";
|
||||
import { Textarea } from "../ui/textarea";
|
||||
import { registerGlobalVariable } from "../../controllers/API";
|
||||
import BaseModal from "../../modals/baseModal";
|
||||
import { useGlobalVariablesStore } from "../../stores/globalVariables";
|
||||
|
||||
//TODO IMPLEMENT FORM LOGIC
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
import ShadTooltip from "../../components/ShadTooltipComponent";
|
||||
import IconComponent from "../../components/genericIconComponent";
|
||||
import PageLayout from "../../components/pageLayout";
|
||||
import { deleteGlobalVariable } from "../../controllers/API";
|
||||
import { useGlobalVariablesStore } from "../../stores/globalVariables";
|
||||
import AddNewVariableButton from "./components/addNewVariableButton";
|
||||
|
||||
//TODO: improve UI
|
||||
|
||||
export default function GlobalVariablesPage() {
|
||||
const globalVariablesEntries = useGlobalVariablesStore(
|
||||
(state) => state.globalVariablesEntries
|
||||
);
|
||||
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
|
||||
const removeGlobalVariable = useGlobalVariablesStore(
|
||||
(state) => state.removeGlobalVariable
|
||||
);
|
||||
|
||||
function handleDelete(key: string) {
|
||||
const id = getVariableId(key);
|
||||
if(id!==undefined)
|
||||
{
|
||||
deleteGlobalVariable(id).then((_) => removeGlobalVariable(key));
|
||||
|
||||
}else{
|
||||
console.error("id is undefined");
|
||||
}
|
||||
}
|
||||
return (
|
||||
<PageLayout
|
||||
title="Variables"
|
||||
description="set your own personal varaibles and use it on your flow"
|
||||
>
|
||||
{globalVariablesEntries.length > 0 ? (
|
||||
<div className="flex h-full w-full flex-col justify-around">
|
||||
{globalVariablesEntries.map((key, index) => (
|
||||
<div className="flex w-full items-start" key={index}>
|
||||
<span>{key}</span>
|
||||
<ShadTooltip content="Delete">
|
||||
<button onClick={(_) => handleDelete(key)} className="ml-auto">
|
||||
<IconComponent name="Trash2" />
|
||||
</button>
|
||||
</ShadTooltip>
|
||||
</div>
|
||||
))}
|
||||
<AddNewVariableButton />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex h-full w-full flex-col items-center justify-center align-middle">
|
||||
<div>
|
||||
<p> create your first variable</p>
|
||||
<AddNewVariableButton />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ import ProfileSettingsPage from "./pages/ProfileSettingsPage";
|
|||
import StorePage from "./pages/StorePage";
|
||||
import ViewPage from "./pages/ViewPage";
|
||||
import DeleteAccountPage from "./pages/deleteAccountPage";
|
||||
import GlobalVariablesPage from "./pages/globalVariablesPage";
|
||||
import LoginPage from "./pages/loginPage";
|
||||
import SignUp from "./pages/signUpPage";
|
||||
|
||||
|
|
@ -154,14 +153,6 @@ const Router = () => {
|
|||
}
|
||||
></Route>
|
||||
</Route>
|
||||
<Route
|
||||
path="variables"
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<GlobalVariablesPage />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
></Route>
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue