- Merge client update into test-beta
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import React from "react";
|
||||
import { SliderPicker } from "react-color";
|
||||
import {SliderPicker} from "react-color";
|
||||
//To be used as a form element only.
|
||||
|
||||
const ColorPickerFormItem = ({ value, onChange, style, ...restProps }) => {
|
||||
const handleChangeComplete = (color) => {
|
||||
if (onChange) onChange(color);
|
||||
};
|
||||
const ColorPickerFormItem = ({value, onChange, style, ...restProps}) => {
|
||||
const handleChangeComplete = (color) => {
|
||||
if (onChange) onChange(color);
|
||||
};
|
||||
|
||||
return (
|
||||
<SliderPicker
|
||||
{...restProps}
|
||||
style={{ width: "100%", ...style }}
|
||||
color={value}
|
||||
triangle="hide"
|
||||
onChangeComplete={handleChangeComplete}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<SliderPicker
|
||||
{...restProps}
|
||||
style={{width: "100%", ...style}}
|
||||
color={value}
|
||||
triangle="hide"
|
||||
onChangeComplete={handleChangeComplete}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default ColorPickerFormItem;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { InputNumber } from "antd";
|
||||
import React, { forwardRef } from "react";
|
||||
import {InputNumber} from "antd";
|
||||
import React, {forwardRef} from "react";
|
||||
|
||||
// const locale = "en-us";
|
||||
// const currencyFormatter = (value) => {
|
||||
@@ -42,16 +42,16 @@ import React, { forwardRef } from "react";
|
||||
// };
|
||||
|
||||
function FormItemCurrency(props, ref) {
|
||||
return (
|
||||
<InputNumber
|
||||
{...props}
|
||||
ref={ref}
|
||||
style={{ width: "initial" }}
|
||||
// formatter={(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
|
||||
// parser={(value) => value.replace(/\$\s?|(,*)/g, "")}
|
||||
precision={2}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<InputNumber
|
||||
{...props}
|
||||
ref={ref}
|
||||
style={{width: "initial"}}
|
||||
// formatter={(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
|
||||
// parser={(value) => value.replace(/\$\s?|(,*)/g, "")}
|
||||
precision={2}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default forwardRef(FormItemCurrency);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import { MailFilled } from "@ant-design/icons";
|
||||
import { Input } from "antd";
|
||||
import React, { forwardRef } from "react";
|
||||
import {MailFilled} from "@ant-design/icons";
|
||||
import {Input} from "antd";
|
||||
import React, {forwardRef} from "react";
|
||||
|
||||
function FormItemEmail(props, ref) {
|
||||
return (
|
||||
<Input
|
||||
{...props}
|
||||
ref={ref}
|
||||
addonAfter={
|
||||
props.defaultValue || props.value ? (
|
||||
<a href={`mailto:${props.defaultValue || props.value}`}>
|
||||
<MailFilled />
|
||||
</a>
|
||||
) : (
|
||||
<MailFilled />
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<Input
|
||||
{...props}
|
||||
ref={ref}
|
||||
addonAfter={
|
||||
props.defaultValue || props.value ? (
|
||||
<a href={`mailto:${props.defaultValue || props.value}`}>
|
||||
<MailFilled/>
|
||||
</a>
|
||||
) : (
|
||||
<MailFilled/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default forwardRef(FormItemEmail);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React, { forwardRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import React, {forwardRef} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
|
||||
const LaborTypeFormItem = ({ value, onChange }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const LaborTypeFormItem = ({value, onChange}, ref) => {
|
||||
const {t} = useTranslation();
|
||||
|
||||
if (!value) return null;
|
||||
if (!value) return null;
|
||||
|
||||
return <div>{t(`joblines.fields.lbr_types.${value}`)}</div>;
|
||||
return <div>{t(`joblines.fields.lbr_types.${value}`)}</div>;
|
||||
};
|
||||
export default forwardRef(LaborTypeFormItem);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React, { forwardRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import React, {forwardRef} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
|
||||
const PartTypeFormItem = ({ value, onChange }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const PartTypeFormItem = ({value, onChange}, ref) => {
|
||||
const {t} = useTranslation();
|
||||
|
||||
if (!value) return null;
|
||||
if (!value) return null;
|
||||
|
||||
return <div>{t(`joblines.fields.part_types.${value}`)}</div>;
|
||||
return <div>{t(`joblines.fields.part_types.${value}`)}</div>;
|
||||
};
|
||||
export default forwardRef(PartTypeFormItem);
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import { Input } from "antd";
|
||||
import {Input} from "antd";
|
||||
import i18n from "i18next";
|
||||
import parsePhoneNumber from "libphonenumber-js";
|
||||
import React, { forwardRef } from "react";
|
||||
import React, {forwardRef} from "react";
|
||||
import "./phone-form-item.styles.scss";
|
||||
|
||||
function FormItemPhone(props, ref) {
|
||||
return (
|
||||
<Input
|
||||
// country="ca" ref={ref} className="ant-input"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<Input
|
||||
// country="ca" ref={ref} className="ant-input"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default forwardRef(FormItemPhone);
|
||||
|
||||
export const PhoneItemFormatterValidation = (getFieldValue, name) => ({
|
||||
async validator(rule, value) {
|
||||
if (!value) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const p = parsePhoneNumber(value, "CA");
|
||||
if (p && p.isValid()) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(i18n.t("general.validation.invalidphone"));
|
||||
}
|
||||
}
|
||||
},
|
||||
async validator(rule, value) {
|
||||
if (!value) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const p = parsePhoneNumber(value, "CA");
|
||||
if (p && p.isValid()) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(i18n.t("general.validation.invalidphone"));
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
import Dinero from "dinero.js";
|
||||
import React, { forwardRef } from "react";
|
||||
import React, {forwardRef} from "react";
|
||||
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
const ReadOnlyFormItem = (
|
||||
{ bodyshop, value, type = "text", onChange },
|
||||
ref
|
||||
{bodyshop, value, type = "text", onChange},
|
||||
ref
|
||||
) => {
|
||||
if (!value) return null;
|
||||
switch (type) {
|
||||
case "employee":
|
||||
const emp = bodyshop.employees.find((e) => e.id === value);
|
||||
return `${emp?.first_name} ${emp?.last_name}`;
|
||||
if (!value) return null;
|
||||
switch (type) {
|
||||
case "employee":
|
||||
const emp = bodyshop.employees.find((e) => e.id === value);
|
||||
return `${emp?.first_name} ${emp?.last_name}`;
|
||||
|
||||
case "text":
|
||||
return <div>{value}</div>;
|
||||
case "currency":
|
||||
return (
|
||||
<div>{Dinero({ amount: Math.round(value * 100) }).toFormat()}</div>
|
||||
);
|
||||
default:
|
||||
return <div>{value}</div>;
|
||||
}
|
||||
case "text":
|
||||
return <div>{value}</div>;
|
||||
case "currency":
|
||||
return (
|
||||
<div>{Dinero({amount: Math.round(value * 100)}).toFormat()}</div>
|
||||
);
|
||||
default:
|
||||
return <div>{value}</div>;
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(forwardRef(ReadOnlyFormItem));
|
||||
|
||||
Reference in New Issue
Block a user