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

add domain records component #23

Merged
merged 1 commit into from
Mar 13, 2024
Merged
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
10 changes: 5 additions & 5 deletions ui/app/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function saveName({
body: JSON.stringify(payload),
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_X_API_KEY,
"x-api-key": process.env.NEXT_PUBLIC_API_KEY,
},
});
return await res.json();
Expand All @@ -50,7 +50,7 @@ export async function getAccountDomains({
{
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_X_API_KEY,
"x-api-key": process.env.NEXT_PUBLIC_API_KEY,
},
}
);
Expand All @@ -73,7 +73,7 @@ export async function getDomains({
{
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_X_API_KEY,
"x-api-key": process.env.NEXT_PUBLIC_API_KEY,
},
}
);
Expand All @@ -86,7 +86,7 @@ export async function getDomainsMetadata(id: string) {
{
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_X_API_KEY,
"x-api-key": process.env.NEXT_PUBLIC_API_KEY,
},
}
);
Expand All @@ -99,7 +99,7 @@ export async function getAccountDomainDetails(
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,
"x-api-key": process.env.NEXT_PUBLIC_API_KEY,
},
});
return await res.json();
Expand Down
2 changes: 2 additions & 0 deletions ui/app/names/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getAccountDomainDetails } from "@/app/actions/actions";
import { useEffect, useState } from "react";

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

export default function Page({ params }: { params: { id: string } }) {
const [accountDomainDetails, setAccountDomainDetails] = useState(null);
Expand All @@ -22,6 +23,7 @@ export default function Page({ params }: { params: { id: string } }) {
return (
<div>
<DetailsNameHeader accountDomainDetails={accountDomainDetails} />
<DetailsNameTable />
</div>
);
}
24 changes: 23 additions & 1 deletion ui/comman/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TableTemplates } from "@/components/organisms/table/templates";

export type View = {
sm: number;
md: number;
Expand All @@ -6,7 +8,7 @@ export type View = {
export type LimitOptions = { text: string; value: number }[];
export type TabSwitcherOptions = string[];

export type DataTable = {
export interface DataTable {
data?: any[];
content?: any[];
size: number;
Expand Down Expand Up @@ -34,6 +36,26 @@ export type DataTable = {
first: boolean;
numberOfElements: number;
empty: boolean;
}

export type TableConfig = {
colName: string;
headerText: string;
columnTemplate: TableTemplates;
fields: {
value?: string;
url?: string;
tooltipFromData?: string;
tooltipText?: string;
func?: (value: string) => void;
prefix?: string;
postfix?: string;
additionValue?: string;
};
sortBy?: SORT_BY;
style?: {
color?: string;
}
};

export enum SORT_BY {
Expand Down
3 changes: 3 additions & 0 deletions ui/components/atoms/subHeader/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.subHeader {
font-size: 20px;
}
1 change: 1 addition & 0 deletions ui/components/atoms/subHeader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default as SubHeader} from './subHeader'
20 changes: 20 additions & 0 deletions ui/components/atoms/subHeader/subHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { interSemiBold } from "@/app/fonts";
import classNames from "classnames";

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

const SubHeader = ({
header,
className,
}: {
header: string;
className?: string;
}): JSX.Element => {
return (
<div className={classNames(interSemiBold.className, style.subHeader,className)}>
{header}
</div>
);
};

export default SubHeader;
7 changes: 4 additions & 3 deletions ui/components/organisms/accountConent/accountContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Table } from "../table";
import { ScoringConfig, mockData } from "./constants";
import style from "./index.module.css";
import { interSemiBold } from "@/app/fonts";
import { ORDER_BY, SORT_BY } from "@/comman/types";

const AccountContent = () => {
const [typeView, setTypeView] = useState<TypeView>(TypeView.CARD);
Expand All @@ -15,7 +16,7 @@ const AccountContent = () => {
};

return (
<div>
<div className={style.wrapper}>
<div className={style.header}>
<div className={interSemiBold.className}>My Names</div>
<ConnectWalletButton />
Expand All @@ -35,8 +36,8 @@ const AccountContent = () => {
{ text: "50", value: 50 },
{ text: "100", value: 100 },
]}
sortBy={"sortBy"}
orderBy={"orderBy"}
sortBy={SORT_BY.RESERVATION_TIMESTAMP}
orderBy={ORDER_BY.DESC}
onChangePage={(data) => {
console.log(data);
}}
Expand Down
4 changes: 2 additions & 2 deletions ui/components/organisms/accountConent/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SORT_BY } from "../../../comman/types";
import { SORT_BY, TableConfig } from "../../../comman/types";
import { TableTemplates } from "../table/templates";
import iconMock from "./img/iconMock.svg";

export const ScoringConfig = [
export const ScoringConfig: TableConfig[] = [
{
colName: "names",
headerText: "Registered Names",
Expand Down
2 changes: 0 additions & 2 deletions ui/components/organisms/accountConent/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
display: flex;
flex-direction: column;
width: 100%;
padding: 0 40px;
margin-left: 265px;
}

.header {
Expand Down
38 changes: 38 additions & 0 deletions ui/components/organisms/detailsNameTable/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { SORT_BY, TableConfig } from "@/comman/types";
import { TableTemplates } from "../table/templates";


export const mockData = {
data: [
{ record: "Email", value: 'Set' },
{ record: "Discord",value: 'Set' },
{ record: "Github", value: 'Set' },
{ record: "Reddit", value: 'Set' },
{ record: "X (Twitter)", value: 'Set' },
{ record: "Telegram", value: 'Set'},
],

};


export const tableConfig: TableConfig[] = [
{
colName: "record",
headerText: "Record",
columnTemplate: TableTemplates.STRING,
fields: {
value: "record",
},
},
{
colName: "value",
columnTemplate: TableTemplates.STRING,
headerText: "Value",
fields: {
value: "value",
},
style: {
color: '#7191FC'
}
},
];
23 changes: 23 additions & 0 deletions ui/components/organisms/detailsNameTable/detailsNameTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TypeView } from "@/components/atoms/switchView/switchView";
import { Table } from "../table";
import { mockData, tableConfig } from "./constants";
import { SubHeader } from "@/components/atoms/subHeader";

import style from './index.module.css'

const DetailsNameTable = () => {
return (
<div className={style.wrapper}>
<SubHeader header='Records' className={style.subHeader}/>
<Table
data={mockData}
config={tableConfig}
isLoading={false}
typeView={TypeView.LIST}
isHiddenPagination
/>
</div>
);
};

export default DetailsNameTable;
3 changes: 3 additions & 0 deletions ui/components/organisms/detailsNameTable/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.subHeader {
margin-bottom: 13px;
}
13 changes: 8 additions & 5 deletions ui/components/organisms/table/table.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import style from "./index.module.css";
import { ORDER_BY } from "../../../comman/types";
import { ORDER_BY, SORT_BY } from "../../../comman/types";
import { TableErrorMessage } from "../../atoms/tableErrorMessage";
import { Loader, LoaderVariant } from "../../atoms/loader";
import { TypeView } from "../../atoms/switchView/switchView";
import NameCards from "./view/nameCards";
import ListTableContent from "./view/listTableContent";
import Pagination from "../pagination/pagination";
import { TableProps } from "./types";

const Table = ({
data,
config: configs,
config,
isLoading,
currentPage,
pageLimit,
Expand All @@ -23,8 +24,9 @@ const Table = ({
onChangeSort,
onChangeOrder,
typeView,
}) => {
const handleSort = (sort?: string): void => {
isHiddenPagination,
}: TableProps): JSX.Element => {
const handleSort = (sort?: SORT_BY): void => {
if (!sort) return;
if (sort === sortBy) {
return onChangeOrder(
Expand All @@ -37,6 +39,7 @@ const Table = ({
const showErrorMessage = !isLoading && (!data || data?.data?.length < 1);

const renderPagination = () => {
if (isHiddenPagination) return null;
return (
<Pagination
currentPage={currentPage}
Expand All @@ -58,7 +61,7 @@ const Table = ({
{typeView === TypeView.LIST ? (
<ListTableContent
data={data?.data}
configs={configs}
configs={config}
isLoading={isLoading}
showErrorMessage={showErrorMessage}
sortBy={sortBy}
Expand Down
15 changes: 3 additions & 12 deletions ui/components/organisms/table/templates/stringTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import classNames from "classnames";

import styles from "../index.module.css";
import { interMedium } from "@/app/fonts";
import { TableConfig } from "@/comman/types";

type StringTemplateProps = {
data: any;
config: {
fields: {
value: string;
tooltipFromData?: string;
tooltipText?: string;
func: (value: string) => void;
prefix?: string;
postfix?: string;
additionValue?: string;
};
};
config: TableConfig;
};

const StringTemplate = ({ data, config }: StringTemplateProps) => {
Expand All @@ -34,7 +25,7 @@ const StringTemplate = ({ data, config }: StringTemplateProps) => {
value === null;

return (
<div className={classNames(interMedium.className, styles.stringTemplate)}>
<div className={classNames(interMedium.className, styles.stringTemplate)} style={config.style}>
{isShowDash ? (
"-"
) : (
Expand Down
21 changes: 21 additions & 0 deletions ui/components/organisms/table/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LimitOptions, ORDER_BY, SORT_BY, TableConfig } from "@/comman/types";
import { TypeView } from "@/components/atoms/switchView/switchView";

export interface TableProps {
data: { data: any[] };
config: TableConfig[];
isLoading: boolean;
currentPage?: number;
pageLimit?: number;
totalElements?: number;
pagesCount?: number;
sortBy?: SORT_BY;
orderBy?: ORDER_BY;
onChangePage?: (value: string) => void;
limitOptions?: LimitOptions;
onChangeLimit?: (value: number) => void;
onChangeSort?: (value: SORT_BY) => void;
onChangeOrder?: (value: ORDER_BY) => void;
typeView: TypeView;
isHiddenPagination?: boolean;
}
4 changes: 2 additions & 2 deletions ui/components/organisms/table/view/listTableContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ListTableContent = ({
showErrorMessage,
sortBy,
orderBy,
}: ListTableContent): JSX.Element => {
}: ListTableContent): JSX.Element => {
return (
<table className={style.table}>
<thead>
Expand All @@ -39,7 +39,7 @@ const ListTableContent = ({
})}
>
{headerText}
{sortBy === configSortBy && (
{configSortBy && sortBy === configSortBy && (
<Image
src={sortIcon}
alt="sort"
Expand Down
Loading