Skip to content

Commit

Permalink
add types to table
Browse files Browse the repository at this point in the history
  • Loading branch information
Assem-Hafez committed Apr 7, 2024
1 parent 9247271 commit c825ff3
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client"
import { Input } from "baseui/input";
import { LabelLarge } from 'baseui/typography';
import { Cell, Grid } from "baseui/layout-grid";
import { Select } from "baseui/select";
import { FormControl } from 'baseui/form-control';
Expand All @@ -13,6 +12,7 @@ import { Button } from "baseui/button";
import { useMemo, useState } from "react";
import CLUSTERS_CONFIGS from "@/configs/clusters/clusters-configs";

const clustersOptions = CLUSTERS_CONFIGS.map(({ clusterName }) => ({ label: clusterName, id: clusterName }));
export default function DomainPageHeader() {
const [queryParams, setQueryParams] = usePageQueryParams(domainPageQueryParamsConfig, { pageRerender: false });
const { cls, theme } = useStyletronClasses(cssStyles);
Expand All @@ -23,7 +23,6 @@ export default function DomainPageHeader() {
.reduce((result, { key, defaultValue }) => queryParams[key] === defaultValue ? result : result + 1, 0); */
}, [/* queryParams */]);

const clustersOptions = CLUSTERS_CONFIGS.map(({ clusterName }) => ({ label: clusterName, id: clusterName }));
const clusterValue = clustersOptions.filter(({ id }) => id === queryParams.clusterName)
return (
<section>
Expand Down Expand Up @@ -54,7 +53,7 @@ export default function DomainPageHeader() {
size="compact"
value={clusterValue}
options={clustersOptions}
onChange={(params) => setQueryParams({ clusterName: params.value[0].id })}
onChange={(params) => setQueryParams({ clusterName: params.value[0]?.id })}
/>
</FormControl>
</div>
Expand Down
17 changes: 0 additions & 17 deletions src/containers/domains-page/domains-page.types.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
export type DomainCluster = {
clusterName: string;
};

export type DomainInfo = {
name: string;
uuid: string;
};

export type ReplicationConfiguration = {
activeClusterName: string;
clusters: Array<DomainCluster>;
};

export type DomainData = {
//ClientDashboardHref: string;
clusters: [{ clusterName: string }];
id: string;
name: string;
};


export type SortingOrder = 'ASC' | 'DESC';

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import React from 'react';

import type { DomainData, SortingOrder } from '@/containers/domains-page/domains-page.types';
import type { DomainData } from '@/containers/domains-page/domains-page.types';
import TableLink from '@/containers/domains-page/domains-table-link/domains-table-link';

import useStyletronClasses from '@/hooks/use-styletron-classes';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TableColumn } from "@/layout/table";
import { TableColumn } from "@/layout/table/table";
import { DomainData } from "../domains-page.types";
import DomainsTableClusterCell from "../domains-table-cluster-cell/domains-table-cluster-cell";
import DomainsTableDomainNameCell from "../domains-table-domain-name-cell/domains-table-domain-name-cell";
Expand Down
5 changes: 3 additions & 2 deletions src/containers/domains-page/domains-table/domains-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Cell, Grid } from 'baseui/layout-grid';

import Table from '@/layout/table';
import Table from '@/layout/table/table';
import usePageQueryParams from '@/hooks/use-page-query-params/use-page-query-params';
import sortBy, { SortByReturnValue, toggleSortOrder } from '@/utils/sort-by';
import useStyletronClasses from '@/hooks/use-styletron-classes';
Expand All @@ -11,7 +11,8 @@ import domainPageQueryParamsConfig from '../domains-page-query-params';

import { domainTableColumns } from './domains-table.config';

import type { DomainData, SortingOrder } from '../domains-page.types';
import type { DomainData } from '../domains-page.types';
import { SortingOrder } from '@/layout/table/table.types';
import { Props } from './domains-table.types';
import { cssStyles } from './domains-table.styles';
import { useInView } from 'react-intersection-observer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TableColumn } from "@/layout/table";
import { TableColumn } from "@/layout/table/table";
import { DomainData } from "../domains-page.types";

export type DomainTableColumns = Array<TableColumn<DomainData>>;
Expand Down
2 changes: 1 addition & 1 deletion src/layout/table.tsx → src/layout/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import ChevronUp from 'baseui/icon/chevron-up';
import ChevronDown from 'baseui/icon/chevron-down';

import { SortingOrder } from '@/containers/domains-page/domains-page.types';
import { SortingOrder } from './table.types';

const SortableHeaderContainer = styled('div', ({ $theme }) => ({
display: 'flex',
Expand Down
1 change: 1 addition & 0 deletions src/layout/table/table.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type SortingOrder = 'ASC' | 'DESC';

0 comments on commit c825ff3

Please sign in to comment.