Skip to content

Commit

Permalink
🚚 devide helper function in table pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jindonyy committed Dec 1, 2022
1 parent 025fea6 commit 66d6c78
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 39 deletions.
11 changes: 11 additions & 0 deletions packages/playground-react/helpers/table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const getDateForm = (date: number) => {
const dateArray = [
new Date(date).getFullYear(),
new Date(date).getMonth() + 1,
new Date(date).getDate(),
];

return dateArray
.map((number) => (number < 10 ? `0${number}` : number))
.join('.');
};
13 changes: 1 addition & 12 deletions packages/playground-react/pages/table/basic-table.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { BasicTable, Text } from '@cos-ui/react';

import { noticeList } from '@constants/mock';

const getDateForm = (date: number) => {
const dateArray = [
new Date(date).getFullYear(),
new Date(date).getMonth() + 1,
new Date(date).getDate(),
];

return dateArray
.map((number) => (number < 10 ? `0${number}` : number))
.join('.');
};
import { getDateForm } from '@helpers/table';

const BasicTablePage = () => (
<BasicTable caption="test" columnsWidth={['10rem', '*', '12rem', '10rem']}>
Expand Down
15 changes: 2 additions & 13 deletions packages/playground-react/pages/table/column-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ import { ColumnTable, Text, FlexBox } from '@cos-ui/react';

import { SortingIcon } from '@constants/icons';
import { noticeList } from '@constants/mock';
import { getDateForm } from '@helpers/table';

const sortingValues = {
writer: noticeList.map(({ writer }) => writer),
date: noticeList.map(({ date }) => date),
view: noticeList.map(({ view }) => Number(view)),
};

const getDateForm = (date: number) => {
const dateArray = [
new Date(date).getFullYear(),
new Date(date).getMonth() + 1,
new Date(date).getDate(),
];

return dateArray
.map((number) => (number < 10 ? `0${number}` : number))
.join('.');
view: noticeList.map(({ view }) => view),
};

const ColumnTablePage = () => (
Expand Down
15 changes: 2 additions & 13 deletions packages/playground-react/pages/table/row-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ import { RowTable, Text, FlexBox } from '@cos-ui/react';

import { SortingIcon } from '@constants/icons';
import { noticeList } from '@constants/mock';
import { getDateForm } from '@helpers/table';

const sortingValues = {
writer: noticeList.map(({ writer }) => writer),
date: noticeList.map(({ date }) => date),
view: noticeList.map(({ view }) => Number(view)),
};

const getDateForm = (date: number) => {
const dateArray = [
new Date(date).getFullYear(),
new Date(date).getMonth() + 1,
new Date(date).getDate(),
];

return dateArray
.map((number) => (number < 10 ? `0${number}` : number))
.join('.');
view: noticeList.map(({ view }) => view),
};

const RowTablePage = () => (
Expand Down
3 changes: 2 additions & 1 deletion packages/playground-react/tsconfig.path.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"@pages/*": ["pages/*"],
"@styles/*": ["styles/*"],
"@utils/*": ["utils/*"],
"@constants/*": ["constants/*"]
"@constants/*": ["constants/*"],
"@helpers/*": ["helpers/*"]
}
}
}

0 comments on commit 66d6c78

Please sign in to comment.