-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK-308 Evaluate working time issues on frontend (#233)
* Adds worker info on new month * Moves errors from backend to frontend Co-authored-by: Paweł Renc <[email protected]>
- Loading branch information
Showing
8 changed files
with
153 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { ThunkFunction } from "../api/persistance-store.model"; | ||
import { | ||
AlgorithmErrorCode, | ||
WorkerOvertime, | ||
WorkerUnderTime, | ||
} from "../common-models/schedule-error.model"; | ||
import { ActionModel } from "./models/action.model"; | ||
import { ScheduleErrorActionType } from "./reducers/month-state/schedule-errors.reducer"; | ||
|
||
export type ScheduleErrorUpdateOvertimOrUndertimePayload = WorkerUnderTime | WorkerOvertime; | ||
|
||
export interface RemoveWorkerErrorUpdateOvertimOrUndertimePayload { | ||
workerName: string; | ||
} | ||
|
||
export class ScheduleErrorActionCreator { | ||
public static addUndertimeOrOvertimeError( | ||
timeDiff: number, | ||
worker: string | ||
): ThunkFunction<unknown> { | ||
return (dispatch): void => { | ||
const type = | ||
timeDiff > 0 ? AlgorithmErrorCode.WorkerOvertime : AlgorithmErrorCode.WorkerUnderTime; | ||
|
||
const removeAction = this.clearWorkerOverTime(worker); | ||
const addAction = { | ||
type: ScheduleErrorActionType.ADD_OVERTIME_OR_UNDERTIME, | ||
payload: { | ||
kind: type, | ||
hours: timeDiff, | ||
worker, | ||
}, | ||
}; | ||
dispatch(removeAction); | ||
dispatch(addAction); | ||
}; | ||
} | ||
|
||
public static clearWorkerOverTime( | ||
worker: string | ||
): ActionModel<RemoveWorkerErrorUpdateOvertimOrUndertimePayload> { | ||
return { | ||
type: ScheduleErrorActionType.REMOVE_WORKER_OVERTIME_ERROR, | ||
payload: { | ||
workerName: worker, | ||
}, | ||
}; | ||
} | ||
} |