Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #21

Merged
merged 2 commits into from
Mar 12, 2024
Merged

Dev #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ui/app/account_details/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.wrapper {
display: flex;
min-height: 100%;
padding-right: 20px;
}

23 changes: 23 additions & 0 deletions ui/app/account_details/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { AccountDetails } from "@/components/organisms/accountDetails";
import { Navigation } from "@/components/organisms/navigation";

import style from "./index.module.css";
import { useRouter } from "next/router";
import { useEffect } from "react";

export default function AccountDetailsPage() {
const router = useRouter();

useEffect(() => {
router.push("/");
}, []);

return (
<div className={style.wrapper}>
<Navigation />
<AccountDetails />
</div>
);
}
13 changes: 13 additions & 0 deletions ui/app/actions/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use server";

import { ORDER_BY, SORT_BY } from "@/comman/types";
import { AccountDomainDetailsResponse } from "./types";

export async function saveName({
name,
Expand Down Expand Up @@ -91,3 +92,15 @@ export async function getDomainsMetadata(id: string) {
);
return await res.json();
}

export async function getAccountDomainDetails(
id: string
): Promise<AccountDomainDetailsResponse> {
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/domains/${id}`, {
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_X_API_KEY,
},
});
return await res.json();
}
16 changes: 16 additions & 0 deletions ui/app/actions/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DOMAINS_STATUS } from "@/comman/types"

export type AccountDomainDetailsResponse = {
id: string,
ownerAddress: string,
transaction: string,
domainName: string,
domainImg: string,
amount: number,
reservationTimestamp: number,
expirationTime: number,
startTimestamp: number,
domainStatus: DOMAINS_STATUS,
isSendToCloudWorker: boolean,
isDefault: boolean
}
1 change: 1 addition & 0 deletions ui/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ body {
font-size: 14px;
line-height: 133%;
color: var(--col--dark);
min-height: 100vh;
}

* {
Expand Down
27 changes: 27 additions & 0 deletions ui/app/names/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use client";

import { getAccountDomainDetails } from "@/app/actions/actions";
import { useEffect, useState } from "react";

import DetailsNameHeader from "@/components/organisms/detailsNameHeader/detailsNameHeader";

export default function Page({ params }: { params: { id: string } }) {
const [accountDomainDetails, setAccountDomainDetails] = useState(null);
const getAccountDomainDetailsById = async () => {
const response = await getAccountDomainDetails(params.id);
setAccountDomainDetails(response);
};
useEffect(() => {
if (params.id) {
getAccountDomainDetailsById();
}
}, [params]);

if (!accountDomainDetails) return null;

return (
<div>
<DetailsNameHeader accountDomainDetails={accountDomainDetails} />
</div>
);
}
8 changes: 8 additions & 0 deletions ui/app/names/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
min-height: 100%;
padding-right: 20px;
}

.content {
display: flex;
flex-direction: column;
width: 100%;
padding: 0 40px;
margin-left: 265px;
}
32 changes: 32 additions & 0 deletions ui/app/names/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Navigation } from "@/components/organisms/navigation";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import style from "./index.module.css";

const inter = Inter({
weight: ["400"],
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "Mina Names",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<body className={inter.className}>
<div className={style.wrapper}>
<Navigation />
<div className={style.content}>{children}</div>
</div>
</body>
</html>
);
}
1 change: 0 additions & 1 deletion ui/app/names/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function Page() {

return (
<div className={classNames(style.wrapper)}>
<Navigation />
<AccountContent />
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions ui/comman/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const fees = {

export const accountAddress =
"B62qk1sJumHSS1hPKS2fSAbxkkwGcCiieb1PcM4PB182pa1MKE9H9AV";

export const defaultDomainNameId = "39c828aa-be66-4e15-b779-3a2e6ed109b1";
5 changes: 5 additions & 0 deletions ui/comman/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ export enum DATA_STATUS {
SUCCESS = "success",
ERROR = "error",
}

export enum DOMAINS_STATUS {
PENDING = "PENDING",
ACTIVE = "ACTIVE",
}
8 changes: 8 additions & 0 deletions ui/components/atoms/name/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.name {
font-size: 32px;
line-height: 32px
}

.name span {
color: #c4c4c4;
}
1 change: 1 addition & 0 deletions ui/components/atoms/name/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Name } from "./name";
15 changes: 15 additions & 0 deletions ui/components/atoms/name/name.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { interMedium } from "@/app/fonts";
import classNames from "classnames";

import style from "./index.module.css";

const Name = ({ name, className }: {name: string; className?: string}): JSX.Element => {
return (
<div className={classNames(interMedium.className, style.name, className)}>
{name}
<span>.mina</span>
</div>
);
};

export default Name;
33 changes: 33 additions & 0 deletions ui/components/atoms/switcher/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.switcherComponent {
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
}

.leftText {
margin-right: 8px;
}

.switcherComponent__plate {
position: relative;
background-color: rgba(221, 224, 235, 1);
width: 26px;
height: 16px;
border-radius: 8px;
padding: 2px;
transition: all ease 250ms;
}

.switcherComponent__btn {
display: inline-block;
position: absolute;
background-color: #fff;
box-shadow: 0px 1px 1px #ced1db;
border-radius: 50%;
transition: all ease 250ms;
}

.switcherComponent__rightText {
margin: 0 0 0 8px;
}
1 change: 1 addition & 0 deletions ui/components/atoms/switcher/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Switcher } from "./switcher";
127 changes: 127 additions & 0 deletions ui/components/atoms/switcher/switcher.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import classNames from "classnames";
import React, { useEffect, useState } from "react";
import style from "./index.module.css";
import { interSemiBold } from "@/app/fonts";

const Switcher = ({
text,
onClick,
initialState,
disabled,
size = 20,
padding = 2,
className,
}: {
text?: string;
onClick?: (value: boolean) => void;
initialState?: boolean;
disabled?: boolean;
size?: number;
padding?: number;
className?: string;
}): JSX.Element => {
const [state, setState] = useState(initialState);

const clickHandler = () => {
if (disabled) return;
const newState = !state;
setState(newState);
onClick?.(newState);
};

const getPlateStyles = () => ({
set: {
width: size * 2 + padding * 2 + "px",
height: size + padding * 2 + "px",
borderRadius: (size + padding * 2) / 2 + "px",
backgroundColor: "rgba(123, 152, 252, 1)",
},
disabled: {
width: size * 2 + padding * 2 + "px",
height: size + padding * 2 + "px",
borderRadius: (size + padding * 2) / 2 + "px",
backgroundColor: "rgba(238, 239, 245, 1)",
},
setDisabled: {
width: size * 2 + padding * 2 + "px",
height: size + padding * 2 + "px",
borderRadius: (size + padding * 2) / 2 + "px",
backgroundColor: "rgba(178, 199, 247, 1)",
},
unset: {
width: size * 2 + padding * 2 + "px",
height: size + padding * 2 + "px",
borderRadius: (size + padding * 2) / 2 + "px",
},
});

const getBtnStyles = () => ({
set: {
width: size + "px",
height: size + "px",
left: `calc(100% - ${size}px - ${padding}px)`,
top: padding,
boxShadow: "0px 1px 1px rgba(87, 123, 204, 1)",
},
disabled: {
width: size + "px",
height: size + "px",
top: padding,
left: padding,
boxShadow: "0px 1px 1px rgba(204, 204, 204, 0.3)",
backgroundColor: "rgba(247, 247, 250, 1)",
},
setDisabled: {
width: size + "px",
height: size + "px",
left: `calc(100% - ${size}px - ${padding}px)`,
top: padding,
boxShadow: "0px 1px 1px rgba(87, 123, 204, 0.3)",
backgroundColor: "rgba(216, 227, 251, 1)",
},
unset: {
top: padding,
left: padding,
width: size + "px",
height: size + "px",
},
});

return (
<div
className={classNames(style.switcherComponent, className, interSemiBold.className)}
onClick={clickHandler}
>
{text && <p className={style.leftText}>{text}</p>}
<div
className={style.switcherComponent__plate}
style={
state
? disabled
? getPlateStyles().setDisabled
: getPlateStyles().set
: disabled
? getPlateStyles().disabled
: getPlateStyles().unset
}
>
<div
className={classNames(style.switcherComponent__btn, {
[style.switcherComponent__btn_active]: state,
})}
style={
state
? disabled
? getBtnStyles().setDisabled
: getBtnStyles().set
: disabled
? getBtnStyles().disabled
: getBtnStyles().unset
}
></div>
</div>
</div>
);
};

export default Switcher;
6 changes: 5 additions & 1 deletion ui/components/molecules/modals/modalInfo/modalInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { StaticEllipse } from "../../staticEllipse";
import { monthDayYearTimeFormat } from "@/helpers/timeHelper";

import style from "./index.module.css";
import Link from "next/link";
import { defaultDomainNameId } from "@/comman/constants";

type ModalInfoProps = {
open: boolean;
Expand Down Expand Up @@ -81,7 +83,9 @@ const ModalInfo = ({ open, onClose, data }: ModalInfoProps): JSX.Element => {
/>
</div>
</div>
<Button text="View Details" variant={Variant.blue} />
<Link href={`/names/${defaultDomainNameId}`}>
<Button text="View Details" variant={Variant.blue} />
</Link>
</div>
</PopupOverlay>
);
Expand Down
1 change: 1 addition & 0 deletions ui/components/molecules/staticEllipse/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

.active {
color: var(--link-active-color);
cursor: pointer;
}

.active:hover {
Expand Down
Loading
Loading