2020-05-14 00:55:00 +03:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2020-05-14 13:45:35 +03:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2020-05-14 00:55:00 +03:00
|
|
|
import Table from "@material-ui/core/Table";
|
|
|
|
import TableBody from "@material-ui/core/TableBody";
|
|
|
|
import TableContainer from "@material-ui/core/TableContainer";
|
|
|
|
import TableHead from "@material-ui/core/TableHead";
|
|
|
|
import TableRow from "@material-ui/core/TableRow";
|
|
|
|
import Paper from "@material-ui/core/Paper";
|
2020-05-14 02:06:14 +03:00
|
|
|
import Spinner from "../../../components/common/Spinner";
|
2020-05-14 03:01:01 +03:00
|
|
|
import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded";
|
|
|
|
import IconButton from "@material-ui/core/IconButton";
|
|
|
|
import Tooltip from "@material-ui/core/Tooltip";
|
2020-05-14 10:29:53 +03:00
|
|
|
import SessionForwardsHeaderComponent from "./SessionForwardsHeaderComponent";
|
2020-05-14 22:30:31 +03:00
|
|
|
import Typography from "@material-ui/core/Typography";
|
2020-05-14 03:01:01 +03:00
|
|
|
import { Grid } from "@material-ui/core";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2020-05-14 15:29:32 +03:00
|
|
|
import styles from "../../../components/common/styles/tableStyles";
|
2020-05-14 13:45:35 +03:00
|
|
|
import {
|
|
|
|
StyledTableCell,
|
|
|
|
StyledTableRow
|
|
|
|
} from "../../../components/common/MaterialTable";
|
2020-05-14 00:55:00 +03:00
|
|
|
|
2020-05-14 13:45:35 +03:00
|
|
|
const useStyles = makeStyles(styles);
|
2020-05-14 00:55:00 +03:00
|
|
|
|
2020-05-19 01:33:52 +03:00
|
|
|
const SessionForwardsComponent = ({
|
|
|
|
session,
|
|
|
|
forwards,
|
|
|
|
openOptionsDialog,
|
|
|
|
showSessionInfo
|
|
|
|
}) => {
|
2020-05-14 00:55:00 +03:00
|
|
|
const classes = useStyles();
|
2020-05-14 03:01:01 +03:00
|
|
|
const { t } = useTranslation();
|
2020-05-14 00:55:00 +03:00
|
|
|
|
2020-05-14 03:01:01 +03:00
|
|
|
return (
|
|
|
|
<Grid container>
|
2020-05-14 22:30:31 +03:00
|
|
|
<Grid item xs={12} sm={12} md={12}>
|
|
|
|
<Typography variant="h6">{t("Session.Forwards.Title")}</Typography>
|
|
|
|
</Grid>
|
2020-05-14 03:01:01 +03:00
|
|
|
<Grid item xs={12} sm={12} md={12}>
|
|
|
|
{!forwards || forwards.loading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
forwards.loaded && (
|
|
|
|
<TableContainer component={Paper}>
|
|
|
|
<Table
|
|
|
|
className={classes.table}
|
|
|
|
size="small"
|
|
|
|
aria-label="customized table"
|
|
|
|
>
|
|
|
|
<TableHead>
|
|
|
|
<TableRow>
|
|
|
|
<StyledTableCell />
|
|
|
|
<StyledTableCell>
|
2020-05-14 13:45:35 +03:00
|
|
|
{t("Session.Forwards.From")}
|
|
|
|
</StyledTableCell>
|
|
|
|
<StyledTableCell>
|
|
|
|
{t("Session.Forwards.To")}
|
2020-05-14 03:01:01 +03:00
|
|
|
</StyledTableCell>
|
|
|
|
<StyledTableCell align="right">
|
2020-05-14 13:45:35 +03:00
|
|
|
{t("Session.Forwards.Options.Title")}
|
2020-05-14 03:01:01 +03:00
|
|
|
</StyledTableCell>
|
|
|
|
</TableRow>
|
|
|
|
</TableHead>
|
|
|
|
<TableBody>
|
|
|
|
{forwards.map((row) => (
|
|
|
|
<StyledTableRow key={row.forwardId}>
|
|
|
|
<StyledTableCell component="th" scope="row">
|
|
|
|
{forwards.indexOf(row) + 1}
|
|
|
|
</StyledTableCell>
|
|
|
|
<StyledTableCell>{row.from}</StyledTableCell>
|
|
|
|
<StyledTableCell>{row.to}</StyledTableCell>
|
|
|
|
<StyledTableCell align="right">
|
|
|
|
{row.options ? (
|
2020-05-14 13:45:35 +03:00
|
|
|
<Tooltip title={t("Session.Forwards.Options.Title")}>
|
|
|
|
<IconButton
|
|
|
|
aria-label="options"
|
|
|
|
size="small"
|
|
|
|
onClick={openOptionsDialog({
|
|
|
|
...row.options,
|
|
|
|
title: `${row.from} >>> ${row.to}`
|
|
|
|
})}
|
|
|
|
>
|
2020-05-14 03:01:01 +03:00
|
|
|
<DonutLargeRoundedIcon color="primary" />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
) : (
|
|
|
|
""
|
|
|
|
)}
|
|
|
|
</StyledTableCell>
|
|
|
|
</StyledTableRow>
|
|
|
|
))}
|
|
|
|
</TableBody>
|
|
|
|
</Table>
|
|
|
|
</TableContainer>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</Grid>
|
2020-05-19 01:33:52 +03:00
|
|
|
{showSessionInfo && (
|
|
|
|
<>
|
|
|
|
<Grid item xs={12} sm={12} md={12}>
|
|
|
|
<br />
|
|
|
|
</Grid>
|
|
|
|
<Grid item xs={12} sm={12} md={12}>
|
|
|
|
<SessionForwardsHeaderComponent session={session} />
|
|
|
|
</Grid>
|
|
|
|
</>
|
|
|
|
)}
|
2020-05-14 03:01:01 +03:00
|
|
|
</Grid>
|
2020-05-14 00:55:00 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-05-14 10:29:53 +03:00
|
|
|
SessionForwardsComponent.propTypes = {
|
2020-05-14 03:01:01 +03:00
|
|
|
session: PropTypes.object.isRequired,
|
2020-05-14 13:45:35 +03:00
|
|
|
forwards: PropTypes.array,
|
2020-05-19 01:33:52 +03:00
|
|
|
openOptionsDialog: PropTypes.func.isRequired,
|
|
|
|
showSessionInfo: PropTypes.bool.isRequired
|
2020-05-14 02:06:14 +03:00
|
|
|
};
|
2020-05-14 00:55:00 +03:00
|
|
|
|
2020-05-14 10:29:53 +03:00
|
|
|
export default SessionForwardsComponent;
|