반응형
export interface IAccountTableHead {
id: string | number;
name: string;
code_role: string;
username: string;
code_grade: string;
button_farm_manage: {text: string, fn: ({...args}:{[key:string]: any}) => JSX.Element};
FarmMonitoring: string;
}
const TableHead: IAccountTableHead = {
id: "ID",
code_role: "구분",
username: "아이디",
name: "이름",
code_grade: "등급",
button_farm_manage: {text: "시설관리", fn : function ({...args}) { return <Link to={`/facility/${args.id}`}>시설관리</Link> }},
FarmMonitoring: "모니터링"
}
const tableCell = Object.keys(TableHead);
const columnData = tableCell.map((keyD, i) => {
if (keyD === 'FarmMonitoring') {
return <td key={i}><a href={`http://test.com/${key["username"]}`}>이동</a></td>
} else if(keyD.substr(0, 4) === 'code') {
return <td key={i}>{key[keyD].code_name}</td>
} else if(keyD.substr(0, 6) === 'button') {
const {fn} = TableHead[keyD as keyof IAccountTableHead] as {text: string, fn: ({...args}:{[key:string]: any}) => JSX.Element};
return <td key={i}>{fn(key)}</td>
} else {
return <td key={i}>{key[keyD]}</td>
}
});
반응형
'Web > Javascript|TypeScript' 카테고리의 다른 글
[node] node-gyp Error (0) | 2022.02.28 |
---|---|
[JS] ubuntu 18.04 npm install Error (feat. gyp) (0) | 2022.02.18 |
[Javascript][공부하자] Higher-Order Function (HOF) (0) | 2021.10.18 |
[TS] typescript-excess-property-checks (0) | 2021.08.31 |
[classnames] Could not find a declaration file for module (0) | 2021.07.07 |