Skip to content

Commit

Permalink
Update Earn section
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Oct 2, 2024
1 parent 671cc1a commit 89a380f
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/web/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export { default as MenuIcon } from "./menu.svg";
export { default as MoonIcon } from "./moon.svg";
export { default as MultisigIcon } from "./multisig.svg";
export { default as OutgoingArrowIcon } from "./outgoing-arrow.svg";
export { default as PercentIcon } from "./percent.svg";
export { default as PencilIcon } from "./pencil.svg";
export { default as PlusIcon } from "./plus.svg";
export { default as PyramidIcon } from "./pyramid.svg";
Expand Down
13 changes: 13 additions & 0 deletions apps/web/src/assets/icons/percent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 15 additions & 10 deletions apps/web/src/components/ViewOverlay/ViewOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import { Box, Icon } from "@chakra-ui/react";

import { CoinIcon, LockIcon, PyramidIcon, WalletIcon } from "../../assets/icons";
import { CoinIcon, LockIcon, PercentIcon, PyramidIcon, WalletIcon } from "../../assets/icons";
import { useColor } from "../../styles/useColor";
import { useIsAccountVerified } from "../Onboarding/VerificationFlow";

type ViewOverlayProps = {
iconType: "activity" | "earn" | "nfts" | "tokens";
};

const iconMap = {
activity: WalletIcon,
earn: PercentIcon,
nfts: PyramidIcon,
tokens: CoinIcon,
};

export const ViewOverlay = ({ iconType }: ViewOverlayProps) => {
const color = useColor();
const isVerified = useIsAccountVerified();

const getIcon = () => {
if (!isVerified) {
return LockIcon;
} else if (iconType === "activity") {
return WalletIcon;
} else if (iconType === "nfts") {
return PyramidIcon;
} else if (iconType === "tokens") {
return CoinIcon;
} else {
return iconMap[iconType];
}
};

const currentColor = color("50");

return (
<Box
position="absolute"
Expand All @@ -41,7 +46,7 @@ export const ViewOverlay = ({ iconType }: ViewOverlayProps) => {
left="-20%"
width="50%"
height="auto"
color={color("50")}
color={currentColor}
/>
<Icon
as={getIcon()}
Expand All @@ -50,7 +55,7 @@ export const ViewOverlay = ({ iconType }: ViewOverlayProps) => {
left="50%"
width="20%"
height="auto"
color={color("50")}
color={currentColor}
/>
<Icon
as={getIcon()}
Expand All @@ -59,7 +64,7 @@ export const ViewOverlay = ({ iconType }: ViewOverlayProps) => {
right="5%"
width="30%"
height="auto"
color={color("50")}
color={currentColor}
/>
</Box>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/styles/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const light = {
green: "#38A169",
greenDark: "#25855A",
bg: "#E0E0FF",
bgGradient: "linear-gradient(67deg, rgba(226, 232, 240, 0.7) 0%, #E2E8F0 100%);",
bgGradient:
"linear-gradient(67deg, rgba(248, 248, 255, 0.70) 0%, rgba(248, 248, 255, 0.96) 29.5%, #F8F8FF 100%);",
bgMaskColor: "#F8F8FF",
grey: {
black: "#121224",
Expand Down
42 changes: 42 additions & 0 deletions apps/web/src/views/Earn/Earn.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { mockImplicitAccount } from "@umami/core";
import { type UmamiStore, accountsActions, addTestAccount, makeStore } from "@umami/state";

import { Earn } from "./Earn";
import { render, screen } from "../../testUtils";

let store: UmamiStore;

const account = mockImplicitAccount(0);

beforeEach(() => {
store = makeStore();
addTestAccount(store, account);
store.dispatch(accountsActions.setCurrent(account.address.pkh));
});

describe("<Earn />", () => {
it("renders correctly if user is verified", () => {
render(<Earn />, { store });

const link = screen.getByRole("link", { name: "Start Earning" });

expect(screen.getByText("Boost your rewards")).toBeInTheDocument();
expect(
screen.getByText("Maximize your tez with staking.com. Secure, efficient, and simple.")
).toBeInTheDocument();
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute("href", "https://stake.tezos.com/");
});

it("renders empty message if user is not verified", () => {
store.dispatch(
accountsActions.setIsVerified({
isVerified: false,
pkh: account.address.pkh,
})
);
render(<Earn />, { store });

expect(screen.getByTestId("empty-state-message")).toBeInTheDocument();
});
});
31 changes: 30 additions & 1 deletion apps/web/src/views/Earn/Earn.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
export const Earn = () => <div>"earn"</div>;
import { Flex } from "@chakra-ui/react";

import { EmptyMessage } from "../../components/EmptyMessage";
import { useIsAccountVerified } from "../../components/Onboarding/VerificationFlow";
import { VerifyMessage } from "../../components/Onboarding/VerificationFlow/VerifyMessage";
import { ViewOverlay } from "../../components/ViewOverlay/ViewOverlay";

export const Earn = () => {
const isVerified = useIsAccountVerified();

const buyTezUrl = "https://stake.tezos.com/";

return (
<>
<Flex zIndex={1} flexGrow={1} width="full">
{isVerified ? (
<EmptyMessage
cta="Start Earning"
ctaUrl={buyTezUrl}
subtitle={"Maximize your tez with staking.com.\nSecure, efficient, and simple."}
title="Boost your rewards"
/>
) : (
<VerifyMessage />
)}
</Flex>
<ViewOverlay iconType="earn" />
</>
);
};

0 comments on commit 89a380f

Please sign in to comment.