Skip to content

Commit

Permalink
Merge pull request #8 from Gimnath-Perera/feat/inter-mock-connection
Browse files Browse the repository at this point in the history
feat: refactored row numbers
  • Loading branch information
gimnathperera committed Sep 3, 2023
2 parents f94a184 + d20ecc3 commit aaea1c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ interface Person {

const Home: FC = () => {
const [code, setCode] = useState<string>(DEFAULT_INTERFACE);
const [selectedKeys, setSelectedKeys] = useState(new Set(['10']));
const [numberOfRows, setNumberOfRows] = useState(new Set(['10']));

const handleOnGenerate = (): void => {
console.log('*********', code);
};

const handleOnRowCountChange = (newRowCount: any): void => {
setSelectedKeys(newRowCount);
setNumberOfRows(newRowCount);
};
const handleOnCodeChange = (newCode: string): void => {
setCode(newCode);
Expand All @@ -34,7 +34,7 @@ const Home: FC = () => {
<section className='h-full'>
<Header
onGenerate={handleOnGenerate}
selectedKeys={selectedKeys}
numberOfRows={numberOfRows}
onRowCountChange={handleOnRowCountChange}
/>
<div className='flex justify-center gap-6 h-[calc(100vh-12rem)]'>
Expand Down
10 changes: 5 additions & 5 deletions components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
type Props = {
onGenerate: () => void;
onRowCountChange: (rowCount: Selection) => void;
selectedKeys: any;
numberOfRows: any;
};

const Header: FC<Props> = ({ onGenerate, onRowCountChange, selectedKeys }) => {
const Header: FC<Props> = ({ onGenerate, onRowCountChange, numberOfRows }) => {
const selectedValue = React.useMemo(
() => Array.from(selectedKeys).join(', ').replaceAll('_', ' '),
[selectedKeys],
() => Array.from(numberOfRows).join(', ').replaceAll('_', ' '),
[numberOfRows],
);

return (
Expand All @@ -37,7 +37,7 @@ const Header: FC<Props> = ({ onGenerate, onRowCountChange, selectedKeys }) => {
variant='flat'
disallowEmptySelection
selectionMode='single'
selectedKeys={selectedKeys}
selectedKeys={numberOfRows}
onSelectionChange={onRowCountChange}
>
<DropdownItem key='10'>10</DropdownItem>
Expand Down

0 comments on commit aaea1c6

Please sign in to comment.