Skip to content

Commit

Permalink
[#541] move dashboard components into features folder
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Mar 26, 2024
1 parent 71c2d18 commit 3b0f501
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 52 deletions.
2 changes: 1 addition & 1 deletion govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Modal, ScrollToTop } from "@atoms";
import { PATHS } from "@consts";
import { useCardano, useModal } from "@context";
import {
DashboardCards,
DashboardGovernanceActions,
DashboardGovernanceActionDetails,
} from "@organisms";
Expand All @@ -29,6 +28,7 @@ import {
WALLET_LS_KEY,
removeItemFromLocalStorage,
} from "@utils";
import { DashboardCards } from "@features";
import { SetupInterceptors } from "./services";
import { useWalletConnectionListener } from "./hooks";
import { RegisterAsSoleVoter } from "./pages/RegisterAsSoleVoter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {
useGetVoterInfo,
useTranslation
} from "@hooks";
import { DelegateDashboardCard } from "./DashboardCards/DelegateDashboardCard";
import { DRepDashboardCard } from "./DashboardCards/DRepDashboardCard";
import { SoleVoterDashboardCard } from "./DashboardCards/SoleVoterDashboardCard";
import { ListGovActionsDashboardCards } from "./DashboardCards/ListGovActionsDashboardCard";
import { ProposeGovActionDashboardCard } from "./DashboardCards/ProposeGovActionDashboardCard";
import {
DelegateDashboardCard,
DRepDashboardCard,
SoleVoterDashboardCard,
ListGovActionsDashboardCards,
ProposeGovActionDashboardCard
} from "./cards";

export const DashboardCards = () => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { CONNECTED_NAV_ITEMS, ICONS } from "@consts";
import { DRepInfoCard, WalletInfoCard } from "@molecules";
import { useGetVoterInfo, useScreenDimension } from "@hooks";
import { openInNewTab } from "@utils";

import { DashboardDrawerMobileProps } from "./types";
import { DrawerMobileProps } from "@/components/organisms/types";

const DRAWER_PADDING = 2;
// 8 is number of multiple in Material UI 2 is left and right side
const CALCULATED_DRAWER_PADDING = DRAWER_PADDING * 8 * 2;

export type DashboardDrawerMobileProps = Omit<DrawerMobileProps, "isConnectButton">;

export const DashboardDrawerMobile = ({
isDrawerOpen,
setIsDrawerOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, IconButton } from "@mui/material";
import { VotingPowerChips, Typography } from "@atoms";
import { ICONS } from "@consts";
import { useScreenDimension } from "@hooks";
import { DashboardDrawerMobile } from "@organisms";
import { DashboardDrawerMobile } from "./DashboardDrawerMobile";

type DashboardTopNavProps = {
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { useNavigate } from "react-router-dom";

import { IMAGES, PATHS } from "@consts";
import { useTranslation } from "@hooks";
import {
CopyableInfo,
DashboardActionCard,
DashboardActionCardProps,
} from "@molecules";
import { CopyableInfo } from "@molecules";
import { openInNewTab } from "@utils";
import { PendingTransaction } from "@/context/pendingTransaction";
import { VoterInfo } from "@/models";
import { DashboardActionCard, DashboardActionCardProps } from "./DashboardActionCard";

type DRepDashboardCardProps = {
dRepIDBech32: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, ReactNode } from "react";

import { LoadingButton, LoadingButtonProps, Typography } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";
import { Card } from "./Card";
import { Card } from "@molecules";

export type DashboardActionCardProps = {
buttons?: LoadingButtonProps[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { Trans } from "react-i18next";

import { IMAGES, PATHS } from "@consts";
import { useTranslation } from "@hooks";
import {
CopyableInfo,
DashboardActionCard,
DashboardActionCardProps,
} from "@molecules";
import { CopyableInfo } from "@molecules";
import { correctAdaFormat, formHexToBech32, openInNewTab } from "@utils";
import { PendingTransaction } from "@/context/pendingTransaction";
import { DashboardActionCard, DashboardActionCardProps } from "./DashboardActionCard";

type DelegateDashboardCardProps = {
currentDelegation: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useNavigate } from "react-router-dom";

import { IMAGES, PATHS } from "@consts";
import { useTranslation } from "@hooks";
import { DashboardActionCard } from "@molecules";
import { VoterInfo } from "@/models";
import { DashboardActionCard } from "./DashboardActionCard";

type ListGovActionsDashboardCardsProps = {
voter: VoterInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useNavigate } from "react-router-dom";

import { IMAGES, PATHS } from "@consts";
import { useTranslation } from "@hooks";
import { DashboardActionCard } from "@molecules";
import { openInNewTab } from "@utils";
import { PendingTransaction } from "@/context/pendingTransaction";
import { DashboardActionCard } from "./DashboardActionCard";

type ProposeGovActionDashboardCardProps = {
createGovActionTx: PendingTransaction["createGovAction"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Trans } from "react-i18next";

import { IMAGES, PATHS } from "@consts";
import { useTranslation } from "@hooks";
import { DashboardActionCard, DashboardActionCardProps } from "@molecules";
import { correctAdaFormat, openInNewTab } from "@utils";
import { LoadingButtonProps } from "@atoms";
import { PendingTransaction } from "@/context/pendingTransaction";
import { VoterInfo } from "@/models";
import { DashboardActionCard, DashboardActionCardProps } from "./DashboardActionCard";

type SoleVoterDashboardCardProps = {
pendingTransaction: PendingTransaction;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from "./DRepDashboardCard";
export * from "./DashboardActionCard";
export * from "./DelegateDashboardCard";
export * from "./ListGovActionsDashboardCard";
export * from "./ProposeGovActionDashboardCard";
export * from "./SoleVoterDashboardCard";
5 changes: 5 additions & 0 deletions govtool/frontend/src/components/features/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./DashboardCards";
export * from "./DashboardDrawerMobile";
export * from "./DashboardTopNav";

export * from "./cards";
1 change: 1 addition & 0 deletions govtool/frontend/src/components/features/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dashboard";
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Box, Link } from "@mui/material";

import { Background, Typography } from "@atoms";
import { ICONS } from "@consts";
import { DashboardTopNav } from "@organisms";
import { DashboardTopNav } from "@features";
import { useScreenDimension } from "@hooks";
import { useNavigate } from "react-router-dom";
import { theme } from "@/theme";
Expand Down
1 change: 0 additions & 1 deletion govtool/frontend/src/components/molecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from "./Card";
export * from "./CenteredBoxBottomButtons";
export * from "./CenteredBoxPageWrapper";
export * from "./CopyableInfo";
export * from "./DashboardActionCard";
export * from "./DataActionsBar";
export * from "./DataMissingInfoBox";
export * from "./DRepInfoCard";
Expand Down
4 changes: 0 additions & 4 deletions govtool/frontend/src/components/organisms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ export * from "./ChooseStakeKeyPanel";
export * from "./ChooseWalletModal";
export * from "./ControlledField";
export * from "./CreateGovernanceActionSteps";
export * from "./DashboardCards";
export * from "./DashboardCards";
export * from "./DashboardDrawerMobile";
export * from "./DashboardGovernanceActionDetails";
export * from "./DashboardGovernanceActions";
export * from "./DashboardGovernanceActionsVotedOn";
export * from "./DashboardTopNav";
export * from "./DelegateTodRepStepOne";
export * from "./DelegateTodRepStepTwo";
export * from "./Drawer";
Expand Down
7 changes: 2 additions & 5 deletions govtool/frontend/src/components/organisms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ export type BgCardProps = {
sx?: SxProps;
};

export type DashboardDrawerMobileProps = {
export type DrawerMobileProps = {
isConnectButton: boolean;
isDrawerOpen: boolean;
setIsDrawerOpen: Dispatch<SetStateAction<boolean>>;
};

export type DrawerMobileProps = DashboardDrawerMobileProps & {
isConnectButton: boolean;
};
2 changes: 1 addition & 1 deletion govtool/frontend/src/pages/CreateGovernanceAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { LinkWithIcon } from "@molecules";
import {
ChooseGovernanceActionType,
CreateGovernanceActionForm,
DashboardTopNav,
Footer,
ReviewCreatedGovernanceAction,
StorageInformation,
StoreDataInfo,
WhatGovernanceActionIsAbout,
} from "@organisms";
import { DashboardTopNav } from "@features";
import { checkIsWalletConnected } from "@utils";

export const CreateGovernanceAction = () => {
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { Background, ScrollToManage } from "@atoms";
import { PATHS } from "@consts";
import { useCardano } from "@context";
import { useScreenDimension, useTranslation } from "@hooks";
import { DashboardTopNav, Drawer, Footer } from "@organisms";
import { Drawer, Footer } from "@organisms";
import { checkIsWalletConnected } from "@utils";
import { DashboardTopNav } from "@features";

export const Dashboard = () => {
const { isEnabled, stakeKey } = useCardano();
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/pages/DelegateTodRep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Background } from "@atoms";
import { PATHS } from "@consts";
import { useScreenDimension, useTranslation } from "@hooks";
import {
DashboardTopNav,
DelegateTodRepStepOne,
DelegateTodRepStepTwo,
Footer,
} from "@organisms";
import { DashboardTopNav } from "@features";
import { checkIsWalletConnected } from "@utils";

export const DelegateTodRep = () => {
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/pages/RegisterAsdRep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {
} from "@hooks";
import { LinkWithIcon } from "@molecules";
import {
DashboardTopNav,
DRepStorageInformation,
DRepStoreDataInfo,
Footer,
RegisterAsDRepForm,
RolesAndResponsibilities,
} from "@organisms";
import { DashboardTopNav } from "@features";
import { checkIsWalletConnected } from "@utils";

export const RegisterAsdRep = () => {
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/src/pages/UpdatedRepMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
useUpdatedRepMetadataForm,
useTranslation,
} from "@hooks";
import { ControlledField, DashboardTopNav, Footer } from "@organisms";
import { ControlledField, Footer } from "@organisms";
import { DashboardTopNav } from "@features";
import { checkIsWalletConnected, openInNewTab } from "@utils";
import { theme } from "@/theme";

Expand Down
32 changes: 20 additions & 12 deletions govtool/frontend/src/stories/DashboardCard.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";

import { DashboardActionCard } from "@molecules";
import { DashboardActionCard } from "@features";
import { within } from "@storybook/testing-library";
import { expect } from "@storybook/jest";
import { IMAGES } from "@/consts";
Expand All @@ -19,10 +19,12 @@ type Story = StoryObj<typeof meta>;

export const DashboardCardComponent: Story = {
args: {
buttons: [
{ children: "first button" },
{ children: "second button" },
],
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageURL: IMAGES.govActionDelegateImage,
secondButtonLabel: "second button",
title: "Action card",
},
play: async ({ canvasElement }) => {
Expand All @@ -36,23 +38,27 @@ export const DashboardCardComponent: Story = {
},
};

export const WithDRepIdDashboardCardComponent: Story = {
export const WithChildrenDashboardCardComponent: Story = {
args: {
buttons: [
{ children: "first button" },
{ children: "second button" },
],
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageURL: IMAGES.govActionDelegateImage,
secondButtonLabel: "second button",
title: "Action card",
cardId: "drep1gwsw9ckkhuwscj9savt5f7u9xsrudw209hne7pggcktzuw5sv32",
children: "You can insert any children you want",
},
};

export const LoadingDashboardCard: Story = {
args: {
buttons: [
{ children: "first button" },
{ children: "second button" },
],
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageURL: IMAGES.govActionDelegateImage,
secondButtonLabel: "second button",
title: "Action card",
isLoading: true,
},
Expand All @@ -67,12 +73,14 @@ export const LoadingDashboardCard: Story = {

export const InProgressDashboardCard: Story = {
args: {
buttons: [
{ children: "first button" },
{ children: "second button" },
],
description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
firstButtonLabel: "first button",
imageURL: IMAGES.govActionDelegateImage,
secondButtonLabel: "second button",
title: "Action card",
inProgress: true,
state: "inProgress",
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/stories/DashboardTopNav.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";

import { DashboardTopNav } from "@organisms";
import { DashboardTopNav } from "@features";
import { within, userEvent, waitFor, screen } from "@storybook/testing-library";
import { expect } from "@storybook/jest";

Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@services": ["./src/services/index.ts"],
"@molecules": ["./src/components/molecules/index.ts"],
"@organisms": ["./src/components/organisms/index.ts"],
"@features": ["./src/components/features/index.ts"],
"@context": ["./src/context/index.ts"],
"@models": ["./src/models/index.ts"],
"@utils": ["./src/utils/index.ts"]
Expand Down
4 changes: 4 additions & 0 deletions govtool/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const viteConfig = defineViteConfig({
find: "@organisms",
replacement: path.resolve(__dirname, "./src/components/organisms"),
},
{
find: "@features",
replacement: path.resolve(__dirname, "./src/components/features"),
},
{
find: "@context",
replacement: path.resolve(__dirname, "./src/context"),
Expand Down

0 comments on commit 3b0f501

Please sign in to comment.