Added enter again on invoice modal.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project be_version="2.6.1" version="1.2">
|
||||
<babeledit_project version="1.2" be_version="2.6.1">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
@@ -4085,6 +4085,27 @@
|
||||
<folder_node>
|
||||
<name>actions</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>cancel</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>create</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -4190,6 +4211,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>saveandnew</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useLazyQuery, useMutation, useQuery } from "@apollo/react-hooks";
|
||||
import { Form, Modal, notification } from "antd";
|
||||
import React from "react";
|
||||
import { Form, Modal, notification, Button } from "antd";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -12,6 +12,7 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import InvoiceEnterModalComponent from "./invoice-enter-modal.component";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
invoiceEnterModal: selectInvoiceEnterModal,
|
||||
@@ -19,16 +20,19 @@ const mapStateToProps = createStructuredSelector({
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("invoiceEnter")),
|
||||
setInvoiceEnterContext: (context) =>
|
||||
dispatch(setModalContext({ context: context, modal: "invoiceEnter" })),
|
||||
});
|
||||
|
||||
function InvoiceEnterModalContainer({
|
||||
invoiceEnterModal,
|
||||
toggleModalVisible,
|
||||
bodyshop,
|
||||
setInvoiceEnterContext,
|
||||
}) {
|
||||
const [form] = Form.useForm();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [enterAgain, setEnterAgain] = useState(false);
|
||||
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
||||
|
||||
const { data: RoAutoCompleteData } = useQuery(ACTIVE_JOBS_FOR_AUTOCOMPLETE, {
|
||||
@@ -69,9 +73,15 @@ function InvoiceEnterModalContainer({
|
||||
if (invoiceEnterModal.actions.refetch)
|
||||
invoiceEnterModal.actions.refetch();
|
||||
|
||||
toggleModalVisible();
|
||||
if (enterAgain) {
|
||||
form.resetFields();
|
||||
} else {
|
||||
toggleModalVisible();
|
||||
}
|
||||
setEnterAgain(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
setEnterAgain(false);
|
||||
notification["error"]({
|
||||
message: t("invoices.errors.creating", {
|
||||
message: JSON.stringify(error),
|
||||
@@ -84,6 +94,10 @@ function InvoiceEnterModalContainer({
|
||||
toggleModalVisible();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (enterAgain) form.submit();
|
||||
}, [enterAgain, form]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
@@ -96,12 +110,35 @@ function InvoiceEnterModalContainer({
|
||||
okText={t("general.actions.save")}
|
||||
onOk={() => form.submit()}
|
||||
onCancel={handleCancel}
|
||||
afterClose={() => form.resetFields()}
|
||||
footer={
|
||||
<span>
|
||||
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
|
||||
<Button onClick={() => form.submit()}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
{invoiceEnterModal.context && invoiceEnterModal.context.id ? null : (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setEnterAgain(true);
|
||||
}}
|
||||
>
|
||||
{t("general.actions.saveandnew")}
|
||||
</Button>
|
||||
)}
|
||||
</span>
|
||||
}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form
|
||||
onFinish={handleFinish}
|
||||
autoComplete={"off"}
|
||||
form={form}
|
||||
onFinishFailed={() => {
|
||||
setEnterAgain(false);
|
||||
console.log("Finish failed");
|
||||
}}
|
||||
initialValues={{
|
||||
jobid:
|
||||
(invoiceEnterModal.context.job &&
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form.List name="invoicelines">
|
||||
<Form.List name="invoicelines" >
|
||||
{(fields, { add, remove }) => {
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LockOutlined, UserOutlined } from "@ant-design/icons";
|
||||
import { Button, Form, Input } from "antd";
|
||||
import { LockFilled } from "@ant-design/icons";
|
||||
import React from "react";
|
||||
import { useApolloClient } from "react-apollo";
|
||||
import { connect } from "react-redux";
|
||||
@@ -10,17 +10,17 @@ import { UPSERT_USER } from "../../graphql/user.queries";
|
||||
import { emailSignInStart } from "../../redux/user/user.actions";
|
||||
import {
|
||||
selectCurrentUser,
|
||||
selectSignInError
|
||||
selectSignInError,
|
||||
} from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
signInError: selectSignInError
|
||||
signInError: selectSignInError,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
emailSignInStart: (email, password) =>
|
||||
dispatch(emailSignInStart({ email, password }))
|
||||
dispatch(emailSignInStart({ email, password })),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
@@ -29,12 +29,9 @@ export default connect(
|
||||
)(function SignInComponent({ emailSignInStart, currentUser, signInError }) {
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
const handleFinish = values => {
|
||||
console.log("Login");
|
||||
|
||||
const handleFinish = (values) => {
|
||||
const { email, password } = values;
|
||||
emailSignInStart(email, password);
|
||||
//Try to do the login using a saga here.
|
||||
};
|
||||
|
||||
if (currentUser.authorized === true) {
|
||||
@@ -43,17 +40,17 @@ export default connect(
|
||||
mutation: UPSERT_USER,
|
||||
variables: {
|
||||
authEmail: currentUser.email,
|
||||
authToken: currentUser.uid
|
||||
}
|
||||
authToken: currentUser.uid,
|
||||
},
|
||||
})
|
||||
.then()
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.log("User login upsert error.", error);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ width: "450px" }}>
|
||||
{currentUser.authorized === true ? <Redirect to="/manage?" /> : null}
|
||||
|
||||
<img src={Logo} height="100" width="100" alt="Bodyshop.app" />
|
||||
@@ -61,33 +58,23 @@ export default connect(
|
||||
<Form onFinish={handleFinish}>
|
||||
<Form.Item
|
||||
name="email"
|
||||
label="E-mail"
|
||||
rules={[
|
||||
{
|
||||
//TODO Ensure using translations.
|
||||
type: "email",
|
||||
message: "Please enter a valid email."
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
message: "Please your email."
|
||||
}
|
||||
]}
|
||||
rules={[{ required: true, message: "Please input your email!" }]}
|
||||
>
|
||||
<Input />
|
||||
<Input
|
||||
prefix={<UserOutlined className="site-form-item-icon" />}
|
||||
placeholder="Username"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="password"
|
||||
rules={[{ required: true, message: "Please enter your password." }]}
|
||||
rules={[{ required: true, message: "Please input your Password!" }]}
|
||||
>
|
||||
<Input
|
||||
prefix={<LockFilled style={{ color: "rgba(0,0,0,.25)" }} />}
|
||||
prefix={<LockOutlined className="site-form-item-icon" />}
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<div>Forgot password</div>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Log in
|
||||
</Button>
|
||||
|
||||
@@ -45,12 +45,10 @@ export const QUERY_OWNER_BY_ID = gql`
|
||||
clm_no
|
||||
status
|
||||
clm_total
|
||||
vehicle {
|
||||
id
|
||||
v_model_yr
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
}
|
||||
v_model_yr
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
vehicleid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,16 @@ import React from "react";
|
||||
import SignIn from "../../components/sign-in-form/sign-in-form.component";
|
||||
|
||||
export default () => {
|
||||
return <SignIn />;
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "middle",
|
||||
padding: "4em",
|
||||
}}
|
||||
>
|
||||
<SignIn />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -287,11 +287,13 @@
|
||||
},
|
||||
"general": {
|
||||
"actions": {
|
||||
"cancel": "Cancel",
|
||||
"create": "Create",
|
||||
"delete": "Delete",
|
||||
"edit": "Edit",
|
||||
"reset": "Reset to original.",
|
||||
"save": "Save"
|
||||
"save": "Save",
|
||||
"saveandnew": "Save and New"
|
||||
},
|
||||
"labels": {
|
||||
"actions": "Actions",
|
||||
|
||||
@@ -287,11 +287,13 @@
|
||||
},
|
||||
"general": {
|
||||
"actions": {
|
||||
"cancel": "",
|
||||
"create": "",
|
||||
"delete": "Borrar",
|
||||
"edit": "Editar",
|
||||
"reset": "Restablecer a original.",
|
||||
"save": "Salvar"
|
||||
"save": "Salvar",
|
||||
"saveandnew": ""
|
||||
},
|
||||
"labels": {
|
||||
"actions": "Comportamiento",
|
||||
|
||||
@@ -287,11 +287,13 @@
|
||||
},
|
||||
"general": {
|
||||
"actions": {
|
||||
"cancel": "",
|
||||
"create": "",
|
||||
"delete": "Effacer",
|
||||
"edit": "modifier",
|
||||
"reset": "Rétablir l'original.",
|
||||
"save": "sauvegarder"
|
||||
"save": "sauvegarder",
|
||||
"saveandnew": ""
|
||||
},
|
||||
"labels": {
|
||||
"actions": "actes",
|
||||
|
||||
Reference in New Issue
Block a user