Refactored card component on components and flows

This commit is contained in:
Lucas Oliveira 2023-11-09 20:52:45 -03:00
commit 0e9cf8e797
8 changed files with 9 additions and 36 deletions

View file

@ -10,9 +10,7 @@ import {
} from "../ui/card";
export const CardComponent = ({
isFlow,
data,
id,
onDelete,
button,
}: cardComponentPropsType): JSX.Element => {
@ -44,11 +42,11 @@ export const CardComponent = ({
</CardDescription>
</CardHeader>
{isFlow && (
{button && (
<CardFooter>
<div className="card-component-footer-arrangement">
<div className="card-component-footer"></div>
{button && button}
{button}
</div>
</CardFooter>
)}

View file

@ -1,9 +1,6 @@
import { useContext } from "react";
import { Link } from "react-router-dom";
import { CardComponent } from "../../../../components/cardComponent";
import CardsWrapComponent from "../../../../components/cardsWrapComponent";
import IconComponent from "../../../../components/genericIconComponent";
import { Button } from "../../../../components/ui/button";
import { alertContext } from "../../../../contexts/alertContext";
import { TabsContext } from "../../../../contexts/tabsContext";
@ -37,22 +34,6 @@ export default function ComponentsComponent() {
<CardComponent
key={idx}
data={flow}
id={flow.id}
button={
<Link to={"/flow/" + flow.id}>
<Button
variant="outline"
size="sm"
className="whitespace-nowrap "
>
<IconComponent
name="ExternalLink"
className="main-page-nav-button"
/>
Edit Flow
</Button>
</Link>
}
onDelete={() => {
removeFlow(flow.id);
}}

View file

@ -35,9 +35,7 @@ export default function FlowsComponent() {
.map((flow, idx) => (
<CardComponent
key={idx}
isFlow
data={flow}
id={flow.id}
button={
<Link to={"/flow/" + flow.id}>
<Button

View file

@ -5,7 +5,7 @@ import { getStoreComponents } from "../../../../controllers/API";
import { storeComponent } from "../../../../types/store";
import { MarketCardComponent } from "../../../StorePage/components/market-card";
export default function AddedComponents(): JSX.Element {
export default function FromStore(): JSX.Element {
const [data, setData] = useState<storeComponent[]>([]);
const [loading, setLoading] = useState(false);
const { setErrorData } = useContext(alertContext);

View file

@ -35,8 +35,8 @@ export default function HomePage(): JSX.Element {
if (hasStore) {
sidebarNavItems.push({
title: "Added Components",
href: "/added-components",
title: "From Store",
href: "/from-store",
});
}

View file

@ -89,9 +89,7 @@ export const MarketCardComponent = ({
setSuccessData({ title: `${name} Installed` });
setLoading(false);
setInstalled(true);
setTimeout(() => {
navigate("/flow/" + id);
}, 500);
if (!data.is_component) navigate("/flow/" + id);
});
});
}

View file

@ -11,9 +11,9 @@ import ApiKeysPage from "./pages/ApiKeysPage";
import CommunityPage from "./pages/CommunityPage";
import FlowPage from "./pages/FlowPage";
import HomePage from "./pages/MainPage";
import AddedComponents from "./pages/MainPage/components/added-components";
import ComponentsComponent from "./pages/MainPage/components/components";
import FlowsComponent from "./pages/MainPage/components/flows";
import FromStore from "./pages/MainPage/components/from-store";
import ProfileSettingsPage from "./pages/ProfileSettingsPage";
import StorePage from "./pages/StorePage";
import ViewPage from "./pages/ViewPage";
@ -42,10 +42,10 @@ const Router = () => {
<Route path="flows" element={<FlowsComponent />} />
<Route path="components" element={<ComponentsComponent />} />
<Route
path="added-components"
path="from-store"
element={
<StoreGuard>
<AddedComponents />
<FromStore />
</StoreGuard>
}
/>

View file

@ -552,9 +552,7 @@ export type groupDataType = {
};
export type cardComponentPropsType = {
isFlow?: boolean;
data: FlowType;
id: string;
onDelete?: () => void;
button?: JSX.Element;
};