Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -1,83 +1,80 @@
|
||||
import {Button, notification} from "antd";
|
||||
import React, {useState} from "react";
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {useMutation} from "@apollo/client";
|
||||
import {INSERT_NEW_PHONEBOOK} from "../../graphql/phonebook.queries";
|
||||
import { Button, notification } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { INSERT_NEW_PHONEBOOK } from "../../graphql/phonebook.queries";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(VendorsPhonebookAdd);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(VendorsPhonebookAdd);
|
||||
|
||||
export function VendorsPhonebookAdd({form, bodyshop, disabled}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [insertPhonebook] = useMutation(INSERT_NEW_PHONEBOOK);
|
||||
const {t} = useTranslation();
|
||||
export function VendorsPhonebookAdd({ form, bodyshop, disabled }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [insertPhonebook] = useMutation(INSERT_NEW_PHONEBOOK);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleAdd = async () => {
|
||||
setLoading(true);
|
||||
const handleAdd = async () => {
|
||||
setLoading(true);
|
||||
|
||||
const VendorValues = form.getFieldsValue([
|
||||
"name",
|
||||
"email",
|
||||
"phone",
|
||||
"street1",
|
||||
"street2",
|
||||
"city",
|
||||
"state",
|
||||
"zip",
|
||||
"country",
|
||||
]);
|
||||
const VendorValues = form.getFieldsValue([
|
||||
"name",
|
||||
"email",
|
||||
"phone",
|
||||
"street1",
|
||||
"street2",
|
||||
"city",
|
||||
"state",
|
||||
"zip",
|
||||
"country"
|
||||
]);
|
||||
|
||||
const result = await insertPhonebook({
|
||||
variables: {
|
||||
phonebook_entry: [
|
||||
{
|
||||
//The phonebook obj,
|
||||
bodyshopid: bodyshop.id,
|
||||
company: VendorValues.name,
|
||||
category: t("phonebook.labels.vendorcategory"),
|
||||
address1: VendorValues.street1,
|
||||
address2: VendorValues.street2,
|
||||
city: VendorValues.city,
|
||||
state: VendorValues.state,
|
||||
zip: VendorValues.zip,
|
||||
country: VendorValues.country,
|
||||
phone1: VendorValues.phone,
|
||||
email: VendorValues.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const result = await insertPhonebook({
|
||||
variables: {
|
||||
phonebook_entry: [
|
||||
{
|
||||
//The phonebook obj,
|
||||
bodyshopid: bodyshop.id,
|
||||
company: VendorValues.name,
|
||||
category: t("phonebook.labels.vendorcategory"),
|
||||
address1: VendorValues.street1,
|
||||
address2: VendorValues.street2,
|
||||
city: VendorValues.city,
|
||||
state: VendorValues.state,
|
||||
zip: VendorValues.zip,
|
||||
country: VendorValues.country,
|
||||
phone1: VendorValues.phone,
|
||||
email: VendorValues.email
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
if (result.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("phonebook.errors.adding", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("phonebook.successes.added"),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
if (result.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("phonebook.errors.adding", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
} else {
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("phonebook.successes.added")
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleAdd} loading={loading} disabled={disabled}>
|
||||
{t("vendors.actions.addtophonebook")}
|
||||
</Button>
|
||||
);
|
||||
return (
|
||||
<Button onClick={handleAdd} loading={loading} disabled={disabled}>
|
||||
{t("vendors.actions.addtophonebook")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user