diff --git a/.eslintrc.json b/.eslintrc.json index 35b72d8..c9ed8da 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,6 +22,11 @@ }, "sourceType": "module" }, + "settings": { + "react": { + "version": "detect" + } + }, "rules": { "strict": 0, "semi": ["error", "never"], diff --git a/src/js/api/Client.js b/src/js/api/Client.js index 7545a5b..c35e59f 100644 --- a/src/js/api/Client.js +++ b/src/js/api/Client.js @@ -3,19 +3,15 @@ import { formatDate } from "utils" const baseURL = subdomain => { if (process.env.NODE_ENV === "production") { - return `https://${encodeURIComponent( - subdomain - )}.mocoapp.com/api/browser_extensions` + return `https://${encodeURIComponent(subdomain)}.mocoapp.com/api/browser_extensions` } else { - return `http://${encodeURIComponent( - subdomain - )}.mocoapp.localhost:3001/api/browser_extensions` + return `http://${encodeURIComponent(subdomain)}.mocoapp.localhost:3001/api/browser_extensions` } } export default class Client { - #client; - #apiKey; + #client + #apiKey constructor({ subdomain, apiKey, version }) { this.#apiKey = apiKey @@ -25,9 +21,9 @@ export default class Client { headers: { common: { "x-api-key": apiKey, - "x-extension-version": version - } - } + "x-extension-version": version, + }, + }, }) } @@ -35,29 +31,29 @@ export default class Client { this.#client.post("session", { api_key: this.#apiKey, remote_service: service?.name, - remote_id: service?.id - }); + remote_id: service?.id, + }) - projects = () => this.#client.get("projects"); + projects = () => this.#client.get("projects") schedules = (fromDate, toDate) => this.#client.get("schedules", { - params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` } - }); + params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` }, + }) activities = (fromDate, toDate) => this.#client.get("activities", { - params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` } - }); + params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` }, + }) bookedHours = service => { if (!service) { return Promise.resolve({ data: { hours: 0 } }) } return this.#client.get("activities/tags", { - params: { selection: [service.id], remote_service: service.name } + params: { selection: [service.id], remote_service: service.name }, }) - }; + } - createActivity = activity => this.#client.post("activities", { activity }); + createActivity = activity => this.#client.post("activities", { activity }) } diff --git a/src/js/components/Calendar/Day.js b/src/js/components/Calendar/Day.js index 1e9afa7..ac62a7f 100644 --- a/src/js/components/Calendar/Day.js +++ b/src/js/components/Calendar/Day.js @@ -10,15 +10,11 @@ const Day = ({ date, hours, absence, active, onClick }) => { return (
0, - "moco-bx-calendar__day--absence": absence - } - )} + className={cn("moco-bx-calendar__day", `moco-bx-calendar__day--week-day-${getDay(date)}`, { + "moco-bx-calendar__day--active": active, + "moco-bx-calendar__day--filled": hours > 0, + "moco-bx-calendar__day--absence": absence, + })} onClick={handleClick} > @@ -34,7 +30,7 @@ Day.propTypes = { hours: PropTypes.number.isRequired, absence: PropTypes.object, active: PropTypes.bool.isRequired, - onClick: PropTypes.func.isRequired + onClick: PropTypes.func.isRequired, } export default Day diff --git a/src/js/components/Calendar/Hours.js b/src/js/components/Calendar/Hours.js index 04ca61e..d5b7ba8 100644 --- a/src/js/components/Calendar/Hours.js +++ b/src/js/components/Calendar/Hours.js @@ -35,9 +35,9 @@ Hours.propTypes = { hours: PropTypes.number.isRequired, absence: PropTypes.shape({ assignment_code: PropTypes.string, - assignment_color: PropTypes.string + assignment_color: PropTypes.string, }), - active: PropTypes.bool.isRequired + active: PropTypes.bool.isRequired, } export default Hours diff --git a/src/js/components/Calendar/index.js b/src/js/components/Calendar/index.js index a29613f..959db0a 100644 --- a/src/js/components/Calendar/index.js +++ b/src/js/components/Calendar/index.js @@ -5,22 +5,14 @@ import { formatDate } from "utils" import { eachDay } from "date-fns" import { pathEq } from "lodash/fp" -const findAbsence = (date, schedules) => - schedules.find(pathEq("date", formatDate(date))) +const findAbsence = (date, schedules) => schedules.find(pathEq("date", formatDate(date))) const hoursAtDate = (date, activities) => activities .filter(pathEq("date", formatDate(date))) .reduce((acc, activity) => acc + activity.hours, 0) -const Calendar = ({ - fromDate, - toDate, - selectedDate, - activities, - schedules, - onChange -}) => ( +const Calendar = ({ fromDate, toDate, selectedDate, activities, schedules, onChange }) => (
{eachDay(fromDate, toDate).map(date => ( ( ) UnknownError.propTypes = { - message: PropTypes.string + message: PropTypes.string, } export default UnknownError diff --git a/src/js/components/Errors/UpgradeRequiredError.js b/src/js/components/Errors/UpgradeRequiredError.js index a5e416f..874b8b4 100644 --- a/src/js/components/Errors/UpgradeRequiredError.js +++ b/src/js/components/Errors/UpgradeRequiredError.js @@ -7,10 +7,7 @@ const UpgradeRequiredError = () => (
MOCO logo

Upgrade erforderlich

-

- Die installierte MOCO Browser-Erweiterung ist veraltet — bitte - aktualisieren. -

+

Die installierte MOCO Browser-Erweiterung ist veraltet — bitte aktualisieren.

{isChrome() ? (
diff --git a/src/js/components/Form.js b/src/js/components/Form.js index f429c51..ff79b49 100644 --- a/src/js/components/Form.js +++ b/src/js/components/Form.js @@ -8,24 +8,24 @@ class Form extends Component { changeset: PropTypes.shape({ project: PropTypes.object, task: PropTypes.object, - hours: PropTypes.string + hours: PropTypes.string, }).isRequired, errors: PropTypes.object, projects: PropTypes.array.isRequired, onChange: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired - }; + onSubmit: PropTypes.func.isRequired, + } static defaultProps = { - inline: true - }; + inline: true, + } isValid = () => { const { changeset } = this.props return ["assignment_id", "task_id", "hours", "description"] .map(prop => changeset[prop]) .every(Boolean) - }; + } handleTextareaKeyDown = event => { const { onSubmit } = this.props @@ -34,7 +34,7 @@ class Form extends Component { event.preventDefault() this.isValid() && onSubmit(event) } - }; + } render() { const { projects, changeset, errors, onChange, onSubmit } = this.props @@ -44,7 +44,7 @@ class Form extends Component {
- {errors.hours ? ( -
{errors.hours.join("; ")}
- ) : null} + {errors.hours ?
{errors.hours.join("; ")}
: null}