- the great reformat

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-02-06 18:20:58 -05:00
parent 30c530bcc4
commit e83badb454
912 changed files with 108516 additions and 107493 deletions

View File

@@ -1,83 +1,83 @@
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
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>
);
}