Reformat all project files to use the prettier config file.

This commit is contained in:
Patrick Fic
2024-03-27 15:35:07 -07:00
parent b161530381
commit e1df64d592
873 changed files with 111387 additions and 125473 deletions

View File

@@ -1,120 +1,108 @@
import {useMutation} from "@apollo/client";
import {Form, Modal, notification} from "antd";
import React, {useEffect} from "react";
import {useTranslation} from "react-i18next";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {logImEXEvent} from "../../firebase/firebase.utils";
import {INSERT_INVENTORY_LINE, UPDATE_INVENTORY_LINE,} from "../../graphql/inventory.queries";
import {toggleModalVisible} from "../../redux/modals/modals.actions";
import {selectInventoryUpsert} from "../../redux/modals/modals.selectors";
import {selectBodyshop, selectCurrentUser,} from "../../redux/user/user.selectors";
import { useMutation } from "@apollo/client";
import { Form, Modal, notification } from "antd";
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { INSERT_INVENTORY_LINE, UPDATE_INVENTORY_LINE } from "../../graphql/inventory.queries";
import { toggleModalVisible } from "../../redux/modals/modals.actions";
import { selectInventoryUpsert } from "../../redux/modals/modals.selectors";
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
import InventoryUpsertModal from "./inventory-upsert-modal.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
currentUser: selectCurrentUser,
inventoryUpsertModal: selectInventoryUpsert,
bodyshop: selectBodyshop,
currentUser: selectCurrentUser,
inventoryUpsertModal: selectInventoryUpsert
});
const mapDispatchToProps = (dispatch) => ({
toggleModalVisible: () => dispatch(toggleModalVisible("inventoryUpsert")),
toggleModalVisible: () => dispatch(toggleModalVisible("inventoryUpsert"))
});
export function InventoryUpsertModalContainer({
currentUser,
bodyshop,
inventoryUpsertModal,
toggleModalVisible,
}) {
const {t} = useTranslation();
const [insertInventory] = useMutation(INSERT_INVENTORY_LINE);
const [updateInventoryLine] = useMutation(UPDATE_INVENTORY_LINE);
export function InventoryUpsertModalContainer({ currentUser, bodyshop, inventoryUpsertModal, toggleModalVisible }) {
const { t } = useTranslation();
const [insertInventory] = useMutation(INSERT_INVENTORY_LINE);
const [updateInventoryLine] = useMutation(UPDATE_INVENTORY_LINE);
const {open, context, actions} = inventoryUpsertModal;
const {existingInventory} = context;
const {refetch} = actions;
const { open, context, actions } = inventoryUpsertModal;
const { existingInventory } = context;
const { refetch } = actions;
const [form] = Form.useForm();
const [form] = Form.useForm();
useEffect(() => {
//Required to prevent infinite looping.
if (existingInventory && open) {
form.setFieldsValue(existingInventory);
} else if (!existingInventory && open) {
form.resetFields();
useEffect(() => {
//Required to prevent infinite looping.
if (existingInventory && open) {
form.setFieldsValue(existingInventory);
} else if (!existingInventory && open) {
form.resetFields();
}
}, [existingInventory, form, open]);
const handleFinish = async (formValues) => {
const values = formValues;
if (existingInventory) {
logImEXEvent("inventory_update");
updateInventoryLine({
variables: {
inventoryId: existingInventory.id,
inventoryItem: values
}
}, [existingInventory, form, open]);
}).then((r) => {
notification["success"]({
message: t("inventory.successes.updated")
});
});
// if (refetch) refetch();
toggleModalVisible();
} else {
logImEXEvent("inventory_insert");
const handleFinish = async (formValues) => {
const values = formValues;
if (existingInventory) {
logImEXEvent("inventory_update");
updateInventoryLine({
variables: {
inventoryId: existingInventory.id,
inventoryItem: values,
},
}).then((r) => {
notification["success"]({
message: t("inventory.successes.updated"),
});
});
// if (refetch) refetch();
toggleModalVisible();
} else {
logImEXEvent("inventory_insert");
await insertInventory({
variables: {
inventoryItem: {shopid: bodyshop.id, ...values},
},
update(cache, {data}) {
cache.modify({
fields: {
inventory(existingInv) {
return [...existingInv, data.insert_inventory_one];
},
},
});
},
});
if (refetch) refetch();
form.resetFields();
toggleModalVisible();
notification["success"]({
message: t("inventory.successes.inserted"),
});
}
};
return (
<Modal
title={
existingInventory
? t("inventory.actions.edit")
: t("inventory.actions.new")
await insertInventory({
variables: {
inventoryItem: { shopid: bodyshop.id, ...values }
},
update(cache, { data }) {
cache.modify({
fields: {
inventory(existingInv) {
return [...existingInv, data.insert_inventory_one];
}
}
open={open}
okText={t("general.actions.save")}
onOk={() => {
form.submit();
}}
onCancel={() => {
toggleModalVisible();
}}
destroyOnClose
>
<Form form={form} onFinish={handleFinish} layout="vertical">
<InventoryUpsertModal form={form}/>
</Form>
</Modal>
);
});
}
});
if (refetch) refetch();
form.resetFields();
toggleModalVisible();
notification["success"]({
message: t("inventory.successes.inserted")
});
}
};
return (
<Modal
title={existingInventory ? t("inventory.actions.edit") : t("inventory.actions.new")}
open={open}
okText={t("general.actions.save")}
onOk={() => {
form.submit();
}}
onCancel={() => {
toggleModalVisible();
}}
destroyOnClose
>
<Form form={form} onFinish={handleFinish} layout="vertical">
<InventoryUpsertModal form={form} />
</Form>
</Modal>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(InventoryUpsertModalContainer);
export default connect(mapStateToProps, mapDispatchToProps)(InventoryUpsertModalContainer);