Skip to content

Commit

Permalink
[refactoring] #30
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Jul 9, 2021
1 parent edf21a3 commit c3d9fbc
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 129 deletions.
46 changes: 32 additions & 14 deletions src/components/Dashboard/Connection/Connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function Connection(props: {
return (
<TableContainer component={Paper}>
<Toolbar variant="dense">
<Typography className={classes.heading} id="tableTitle" component="div">
<Typography className={classes.heading} id="connection" component="div">
Connection
</Typography>
</Toolbar>
Expand All @@ -44,8 +44,12 @@ export default function Connection(props: {
}
{
data !== undefined && template !== undefined &&
<StatusTable key={"connection_status_table"} setReload={setReload} template={template}
connection={data.sort((a, b) => b.ID - a.ID)}/>
<StatusTable
key={"connection_status_table"}
setReload={setReload}
template={template}
connection={data.sort((a, b) => b.ID - a.ID)}
/>
}
</TableContainer>
)
Expand Down Expand Up @@ -147,14 +151,20 @@ export function StatusTable(props: {
setPage(0);
};

const getServiceCode = (groupID: number | undefined, serviceType: string | undefined, serviceNum: number | undefined, connectionType: string, connectionNum: number) => {
const getServiceCode = (
groupID: number | undefined,
serviceType: string | undefined,
serviceNum: number | undefined,
connectionType: string,
connectionNum: number
) => {
return groupID + "-" + serviceType + ('000' + serviceNum).slice(-3) + "-" + connectionType + ('000' + connectionNum).slice(-3);
}


return (
<TableContainer component={Paper}>
<Table className={classes.table} size="small" aria-label="custom pagination table">
<Table className={classes.table} size="small" aria-label="connection">
<TableHead>
<TableRow>
<TableCell>ServiceCode</TableCell>
Expand Down Expand Up @@ -200,18 +210,26 @@ export function StatusTable(props: {
<Box display="flex" justifyContent="flex-end">
{
row.service !== undefined &&
<ConnectionGetDialogs key={"connection_get_dialog_" + row.ID}
connection={row} service={row.service}
template={template} reload={setReload}/>
<ConnectionGetDialogs
key={"connection_get_dialog_" + row.ID}
connection={row}
service={row.service}
template={template}
reload={setReload}
/>
}
&nbsp;
<DeleteDialog key={"connection_delete_alert_dialog_" + row.ID}
id={row.ID}
reload={setReload}/>
<DeleteDialog
key={"connection_delete_alert_dialog_" + row.ID}
id={row.ID}
reload={setReload}
/>
&nbsp;
<EnableDialog key={"connection_enable_alert_dialog_" + row.ID}
connection={row}
reload={setReload}/>
<EnableDialog
key={"connection_enable_alert_dialog_" + row.ID}
connection={row}
reload={setReload}
/>
</Box>
</TableCell>
</TableRow>
Expand Down
53 changes: 18 additions & 35 deletions src/components/Dashboard/Group/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ export function Group(props: {
const classes = useStyles();
const nowDate = new Date()

console.log(data)

return (
<TableContainer component={Paper}>
<Toolbar variant="dense">
<Typography className={classes.heading} id="tableTitle" component="div">
<Typography className={classes.heading} id="groups" component="div">
Groups
</Typography>
</Toolbar>
Expand All @@ -41,18 +39,20 @@ export function Group(props: {
}
{
data !== undefined &&
<StatusTable key={"request_status_table"} setReload={setReload}
group={data.filter(item => {
console.log(item.member_expired)
if (item.member_expired === "" || item.member_expired == null) {
return true
} else {
const tmp = item.member_expired.split('T');
const tmpDate = new Date(tmp[0]);

return nowDate < tmpDate
}
})}/>
<StatusTable
key={"group_status_table"}
setReload={setReload}
group={data.filter(item => {
if (item.member_expired === "" || item.member_expired == null) {
return true
} else {
const tmp = item.member_expired.split('T');
const tmpDate = new Date(tmp[0]);

return nowDate < tmpDate
}
})}
/>
}
</TableContainer>
)
Expand Down Expand Up @@ -158,7 +158,7 @@ export function StatusTable(props: {

return (
<TableContainer component={Paper}>
<Table className={classes.table} size="small" aria-label="custom pagination table">
<Table className={classes.table} size="small" aria-label="group_table">
<TableHead>
<TableRow>
<TableCell>申請内容</TableCell>
Expand All @@ -173,8 +173,8 @@ export function StatusTable(props: {
rowsPerPage > 0
? group.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
: group
).map((row) => (
<TableRow key={"group_detail_" + row.ID}>
).map((row, index) => (
<TableRow key={"group_detail_" + index}>
<TableCell style={{width: 300}} component="th" scope="row">
{row.ID}: {row.org}({row.org_en})
</TableCell>
Expand All @@ -194,23 +194,6 @@ export function StatusTable(props: {
}
</TableCell>
<TableCell style={{width: 300}} align="right">
{/*{*/}
{/* (row.request_reject || row.solved) &&*/}
{/* <Button size="small" color="primary" variant="outlined"*/}
{/* onClick={() => clickChangeStatus(row.ID, false, false)}>申請中</Button>*/}
{/*}*/}
{/*{*/}
{/* !row.request_reject && !row.solved &&*/}
{/* <Button size="small" color="primary" variant="outlined"*/}
{/* onClick={() => clickChangeStatus(row.ID, true, false)}>変更/承諾済み</Button>*/}
{/*}*/}
{/*&nbsp;*/}
{/*{*/}
{/* !row.request_reject && !row.solved &&*/}
{/* <Button size="small" color="secondary" variant="outlined"*/}
{/* onClick={() => clickChangeStatus(row.ID, false, true)}>却下</Button>*/}
{/*}*/}
&nbsp;
<Button size="small" variant="outlined"
onClick={() => GroupPage(row.ID)}>Detail</Button>
</TableCell>
Expand Down
87 changes: 42 additions & 45 deletions src/components/Dashboard/Group/Memo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function MemoGroup(props: {
return (
<TableContainer component={Paper}>
<Toolbar variant="dense">
<Typography className={classes.heading} id="tableTitle" component="div">
<Typography className={classes.heading} id="groups_memo" component="div">
Groups(Memo)
</Typography>
</Toolbar>
Expand All @@ -42,19 +42,17 @@ export function MemoGroup(props: {
{
data !== undefined &&
<StatusTable
key={"request_status_table"}
key={"group_memo_status_table"}
setReload={setReload}
group={
data.filter(grp => {
const tmp = grp.memos?.filter(memo => memo.type === 1);
if (tmp === undefined) {
return false;
} else {
return tmp.length !== 0;
}
group={data.filter(grp => {
const tmp = grp.memos?.filter(memo => memo.type === 1);
if (tmp === undefined) {
return false;
} else {
return tmp.length !== 0;
}
)
}
}
)}
/>
}
</TableContainer>
Expand Down Expand Up @@ -196,39 +194,38 @@ export function StatusTable(props: {
<TableBody>
{
(
rowsPerPage > 0
? group.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
: group
).map((row) => (
<TableRow key={"group_memo_detail_" + row.ID}>
<TableCell style={{width: 700}} component="th" scope="row">
{
row.memos?.filter(memo => memo.type === 1).map(memo => (
<Chip
label={memo.title}
className={classes.right}
clickable
color={"secondary"}
onClick={() => handleClickDetail(memo)}
onDelete={() => handleDelete(memo.ID)}
/>
))
}
</TableCell>
<TableCell style={{width: 300}} align="left">
{row.ID}: {row.org}({row.org_en})
</TableCell>
<TableCell style={{width: 300}} align="right">
&nbsp;
<Button
size="small"
variant="outlined"
onClick={() => GroupPage(row.ID)}>
Detail
</Button>
</TableCell>
</TableRow>
))
rowsPerPage > 0 ? group.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : group
).map((row,index) => (
<TableRow key={"group_memo_detail_" + index}>
<TableCell style={{width: 700}} component="th" scope="row">
{
row.memos?.filter(memo => memo.type === 1).map(memo => (
<Chip
label={memo.title}
className={classes.right}
clickable
color={"secondary"}
onClick={() => handleClickDetail(memo)}
onDelete={() => handleDelete(memo.ID)}
/>
))
}
</TableCell>
<TableCell style={{width: 300}} align="left">
{row.ID}: {row.org}({row.org_en})
</TableCell>
<TableCell style={{width: 300}} align="right">
&nbsp;
<Button
size="small"
variant="outlined"
onClick={() => GroupPage(row.ID)}>
Detail
</Button>
</TableCell>
</TableRow>
)
)
}
{
emptyRows > 0 && (
Expand Down
Loading

0 comments on commit c3d9fbc

Please sign in to comment.