Added shift clock framework + login on tech console BOD-97 BOD-188
This commit is contained in:
@@ -155,6 +155,9 @@ export function ShopEmployeesFormComponent({
|
||||
]}>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("employees.fields.user_email")} name='user_email'>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ import {
|
||||
DELETE_EMPLOYEE,
|
||||
INSERT_EMPLOYEES,
|
||||
QUERY_EMPLOYEES,
|
||||
UPDATE_EMPLOYEE
|
||||
UPDATE_EMPLOYEE,
|
||||
} from "../../graphql/employees.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import ShopEmployeeComponent from "./shop-employees.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
|
||||
function ShopEmployeesContainer({ bodyshop }) {
|
||||
@@ -23,69 +23,75 @@ function ShopEmployeesContainer({ bodyshop }) {
|
||||
const { t } = useTranslation();
|
||||
const employeeState = useState(null);
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_EMPLOYEES, {
|
||||
fetchPolicy: "network-only"
|
||||
fetchPolicy: "network-only",
|
||||
});
|
||||
|
||||
const [updateEmployee] = useMutation(UPDATE_EMPLOYEE);
|
||||
const [insertEmployees] = useMutation(INSERT_EMPLOYEES);
|
||||
const [deleteEmployee] = useMutation(DELETE_EMPLOYEE);
|
||||
const handleDelete = id => {
|
||||
const handleDelete = (id) => {
|
||||
deleteEmployee({ variables: { id: id } })
|
||||
.then(r => {
|
||||
.then((r) => {
|
||||
notification["success"]({
|
||||
message: t("employees.successes.delete")
|
||||
message: t("employees.successes.delete"),
|
||||
});
|
||||
//TODO Better way to reset the field decorators?
|
||||
employeeState[1](null);
|
||||
refetch().then(r => form.resetFields());
|
||||
refetch().then((r) => form.resetFields());
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("employees.errors.delete")
|
||||
message: t("employees.errors.delete", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const handleFinish = values => {
|
||||
const handleFinish = (values) => {
|
||||
console.log("values", values);
|
||||
if (employeeState[0].id) {
|
||||
//Update a record.
|
||||
updateEmployee({
|
||||
variables: { id: employeeState[0].id, employee: values }
|
||||
variables: { id: employeeState[0].id, employee: values },
|
||||
})
|
||||
.then(r => {
|
||||
.then((r) => {
|
||||
notification["success"]({
|
||||
message: t("employees.successes.save")
|
||||
message: t("employees.successes.save"),
|
||||
});
|
||||
//TODO Better way to reset the field decorators?
|
||||
employeeState[1](null);
|
||||
refetch().then(r => form.resetFields());
|
||||
refetch().then((r) => form.resetFields());
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("employees.errors.save")
|
||||
message: t("employees.errors.save", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//New record, insert it.
|
||||
insertEmployees({
|
||||
variables: { employees: [{ ...values, shopid: bodyshop.id }] }
|
||||
}).then(r => {
|
||||
variables: { employees: [{ ...values, shopid: bodyshop.id }] },
|
||||
}).then((r) => {
|
||||
notification["success"]({
|
||||
message: t("employees.successes.save")
|
||||
message: t("employees.successes.save"),
|
||||
});
|
||||
//TODO Better way to reset the field decorators?
|
||||
employeeState[1](null);
|
||||
refetch().catch(error => {
|
||||
refetch().catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("employees.errors.save")
|
||||
message: t("employees.errors.save", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
if (error) return <AlertComponent message={error.message} type='error' />;
|
||||
|
||||
return (
|
||||
<ShopEmployeeComponent
|
||||
|
||||
Reference in New Issue
Block a user