Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-94 Management page sketch #79

Merged
merged 3 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route, Switch } from "react-router-dom";
import React from "react";
import SchedulePage from "./components/schedule-page/schedule-page.component";
import WorkersPage from "./components/workers-page/workers-page.component";
import ManagementPage from "./components/workers-page/management-page.component";
import { CustomGlobalHotKeys } from "./components/common-components/tools/globalhotkeys.component";
import Header from "./components/common-components/header/header";

Expand All @@ -12,7 +12,7 @@ function App(): JSX.Element {
<Header />
<Switch>
<Route path="/" component={SchedulePage} exact />
<Route path="/workers" component={WorkersPage} />
<Route path="/management" component={ManagementPage} />
</Switch>
</React.Fragment>
);
Expand Down
1 change: 1 addition & 0 deletions src/assets/styles/styles-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
@import "styles/custom/header";
@import "styles/custom/month-switch";
@import "styles/custom/autocomplete";
@import "styles/custom/management_page";
11 changes: 11 additions & 0 deletions src/assets/styles/styles/custom/_management_page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.management-page {
overflow: auto;
width: 100%;
padding: 20px;
h1 {
margin: 0 10px 10px 10px;
}
* {
color: $secondary-text-color;
}
}
3 changes: 2 additions & 1 deletion src/assets/styles/styles/custom/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ $header-text-color: #ffffff !default;
// Color system

$primary: #1d3557 !default;
$secondary: #000000 !default;
$primary-text-color: $primary !default;
$secondary-text-color: $secondary !default;
$primary-background: #e5e5e5 !default;
$white: #ffffff !default;
$gray-100: #f6f9fc !default;
Expand Down Expand Up @@ -102,7 +104,6 @@ $default-color-opacity: rgba(182, 182, 182, 0.6) !default;
$orange-color: #f96332 !default;

$default: #344675 !default;
$secondary: #f4f5f7 !default;
$success: #00f2c3 !default;
$info: #1d8cf8 !default;
$warning: #ff8d72 !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function ConstraintTab(): JSX.Element {
return <h2>Ograniczenia</h2>;
}
48 changes: 48 additions & 0 deletions src/components/workers-page/management-page.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from "react";
import { Divider, Tab } from "@material-ui/core";
import TabContext from "@material-ui/lab/TabContext";
import TabList from "@material-ui/lab/TabList";
import TabPanel from "@material-ui/lab/TabPanel";
import ShiftTab from "./shifts-tab/shifts-tab.component";
import ConstraintTab from "./constraints-tab/constraints-tab.component";
import WorkersTab from "./workers-tab/workers-tab.component";
import { ImportButtonsComponent } from "../schedule-page/import-buttons/import-buttons.component";

interface TabData {
label: string;
component: JSX.Element;
}

export default function ManagementPage(): JSX.Element {
const tabs: TabData[] = [
{ label: "Pracownicy", component: <WorkersTab /> },
Qwebeck marked this conversation as resolved.
Show resolved Hide resolved
{ label: "Zmiany", component: <ShiftTab /> },
{ label: "Ograniczenia", component: <ConstraintTab /> },
];

const [tab, setTab] = React.useState(tabs[0].label);

const handleChange = (event: React.ChangeEvent<{}>, newTab: string): void => {
setTab(newTab);
};

return (
<div className="management-page">
{/* TODO: Remove ImportButtonsComponent after development*/}
<ImportButtonsComponent />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A do czego potrzebujesz tego komponentu tutaj?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Żeby wczytać harmonogram do testów i mieć go w stanie, usunę to po akceptacji PR

<h1>Panel zarządzania</h1>
<Divider />
<TabContext value={tab}>
<TabList onChange={handleChange} textColor={"primary"} indicatorColor={"primary"}>
{tabs.map((tab) => (
<Tab label={tab.label} value={tab.label} />
))}
</TabList>
<Divider />
{tabs.map((tab) => (
<TabPanel value={tab.label}>{tab.component}</TabPanel>
))}
</TabContext>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function ShiftTab(): JSX.Element {
return <h2>Zmiany</h2>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zastanawiam się nad tym, czy nie zrobić teraz jakiś ResoruceProvider i do niego dodawać napisy?
Bo jeżeli potem będziemy chcieli wprowadzić potem nowy język (wierzę w to, że dojdziemy do takiej skali :D ), to z ResoruceProviderem będzie to robić zdecydowanie łatwiej.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trzeba ogarnąć jak się robi internacjonalizacje w React'cie, ale jestem na tak :D

}
11 changes: 0 additions & 11 deletions src/components/workers-page/workers-page.component.tsx

This file was deleted.

67 changes: 67 additions & 0 deletions src/components/workers-page/workers-tab/workers-tab.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useEffect, useState } from "react";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableContainer from "@material-ui/core/TableContainer";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
import { WorkerType, WorkerTypeHelper } from "../../../common-models/worker-info.model";
import { Button } from "@material-ui/core";
import { useSelector } from "react-redux";
import { ApplicationStateModel } from "../../../state/models/application-state.model";

interface WorkerData {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zdecydowanie tak, nie chciałem w nim mieszać, ale przydałaby się zmiana

name: string;
type: WorkerType;
time: number;
}

export default function WorkersTab(): JSX.Element {
const { type, time } = useSelector(
(state: ApplicationStateModel) => state.scheduleData.present.employee_info
);
const [workerData, setWorkerData] = useState([] as WorkerData[]);

useEffect(() => {
const newWorkerData = Object.keys(type).map(
(key): WorkerData => {
return { name: key, type: type[key], time: time[key] };
}
);
setWorkerData(newWorkerData);
}, [type, time, setWorkerData]);

return (
<>
<Button>Stanowisko</Button>
<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell>Imię i nazwisko</TableCell>
<TableCell align="left">Stanowisko</TableCell>
<TableCell align="left">Wymiar pracy</TableCell>
</TableRow>
</TableHead>
<TableBody>
{workerData.map((worker) => (
<TableRow key={worker.name}>
<TableCell component="th" scope="row">
{worker.name}
</TableCell>
<TableCell align="left">{WorkerTypeHelper.translate(worker.type)}</TableCell>
<TableCell align="left">{worker.time}</TableCell>
<TableCell align="right">
<Button>Edytuj</Button>
</TableCell>
<TableCell align="right">
<Button>Usuń</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</>
);
}