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

OD-19252 feat: remove validation of oncostRate as money, because it i… #1276

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const SidebarWithSearch = (props: Props) => {
>
<Drawer>
<div className="pl-2">
<HamburgerMenu variant={VARIANTS.temporary}/>
<HamburgerMenu variant={VARIANTS.temporary} liteBackground />
</div>
{!noSearch && <SidebarSearch setParentSearch={setSearch} smallIcons/>}
{Boolean(filters.length) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/

import { PreferenceEnum, SearchQuery } from "@api/model";
import { Backdrop, Divider } from "@mui/material";
import Collapse from "@mui/material/Collapse";
import { Backdrop, Collapse, Divider } from "@mui/material";
import { darken } from "@mui/material/styles";
import SwipeableDrawer from "@mui/material/SwipeableDrawer";
import Typography from "@mui/material/Typography";
Expand Down Expand Up @@ -115,7 +114,6 @@ const styles = (theme: AppTheme) =>
});

interface Props {
form: string;
resetEditView: any;
classes: any;
opened: boolean;
Expand Down Expand Up @@ -150,7 +148,6 @@ const sortItems = (a, b) => {

const SwipeableSidebar: React.FC<Props> = props => {
const {
form,
dispatch,
classes,
opened,
Expand Down Expand Up @@ -427,7 +424,7 @@ const SwipeableSidebar: React.FC<Props> = props => {
>
<div className={classes.drawerWidth}>
<div className={clsx("pl-2", classes.toolbar)}>
<HamburgerMenu variant={variant} form={form}/>
<HamburgerMenu variant={variant} liteBackground />
</div>
<UserSearch
getSearchResults={getSearchResults}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import { toggleSwipeableDrawer } from "../actions";
interface Props {
opened?: boolean;
variant?: string;
liteBackground?: boolean;
toggleSwipeableDrawer?: () => void;
}

const HamburgerMenu = React.memo<Props>(props => {
const { opened, toggleSwipeableDrawer } = props;
const { opened, liteBackground, toggleSwipeableDrawer } = props;

return (
<div className="centeredFlex mr-3">
Expand All @@ -36,13 +37,7 @@ const HamburgerMenu = React.memo<Props>(props => {
{opened ? <CloseIcon/> : <MenuIcon/>}
</IconButton>
<Divider orientation="vertical" variant="middle" flexItem/>
{/* <img*/}
{/* src={theme.palette.mode === "dark" ? onCourseLogoLight : onCourseLogoDark}*/}
{/* alt="Logo"*/}
{/* height={36}*/}
{/* />*/}

<Logo className="ml-2" whiteBackgound={opened} />
<Logo className="ml-2" whiteBackgound={opened || liteBackground} />
</div>
);
});
Expand All @@ -55,4 +50,4 @@ const mapStateToDispatch = (dispatch: Dispatch, props: Props) => ({
toggleSwipeableDrawer: () => dispatch(toggleSwipeableDrawer(props.variant))
});

export default connect<any, any, any>(mapStateToProps, mapStateToDispatch)(HamburgerMenu);
export default connect(mapStateToProps, mapStateToDispatch)(HamburgerMenu);
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import { ClassCostRepetitionType } from "@api/model";
import DeleteIcon from "@mui/icons-material/Delete";
import { Card, Grid, IconButton } from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import {
formatFieldPercent,
mapSelectItems,
parseFieldPercent,
preventNegativeOrLogEnter,
YYYY_MM_DD_MINUSED
} from "ish-ui";
import { Decimal } from "decimal.js-light";
import { decimalMul, mapSelectItems, YYYY_MM_DD_MINUSED } from "ish-ui";
import React from "react";
import FormField from "../../../../../common/components/form/formFields/FormField";
import { valiadateSelectItemAvailable } from "../../../../../common/utils/validation";
Expand All @@ -27,8 +22,12 @@ const validateRepetition = val => valiadateSelectItemAvailable(val, repetitionTy

const validatePercentage = value => (!value && value !== 0 ? "Field is mandatory" : undefined);

const parseFieldPercent = val => val && val > 0 ? new Decimal(val).div(100).toDecimalPlaces(4).toNumber() : 0;

const formatFieldPercent = val => decimalMul(val, 100);

const PayRateItem = props => {
const {fields, onDelete} = props;
const { fields, onDelete } = props;

return fields.map((item, index) => (
<Card key={index} className="card flex-fill mb-4">
Expand Down Expand Up @@ -68,9 +67,7 @@ const PayRateItem = props => {
step="0.01"
format={formatFieldPercent}
parse={parseFieldPercent}
onKeyPress={preventNegativeOrLogEnter}
validate={validatePercentage}
debounced={false}
/>
<Tooltip title="Remove pay rate">
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ class TutorRoleApiService extends EntityApiService<DefinedTutorRoleDTO, DefinedT
(rate.type == payRate.type.getDbType() &&
rate.validFrom?.toInstant()?.atZone(ZoneOffset.UTC)?.toLocalDate() == payRate.validFrom) &&
rate.description == trimToNull(payRate.notes) &&
rate.rate == toMoneyValue(payRate.rate) &&
rate.oncostRate == toMoneyValue(payRate.oncostRate)) {
rate.rate == payRate.rate &&
rate.oncostRate == payRate.oncostRate) {
rate.editedByUser = context.localObject(systemUserService.currentUser)
}
rate.type = payRate.type.getDbType()
rate.validFrom = payRate.validFrom?.atStartOfDay(ZoneOffset.UTC)?.toDate()
rate.rate = toMoneyValue(payRate.rate)
rate.oncostRate = toMoneyValue(payRate.oncostRate)
rate.oncostRate = payRate.oncostRate
rate.description = trimToNull(payRate.notes)
}
}
Expand Down
Loading