Added automatic duplication for templates of existing template BOD-253
This commit is contained in:
@@ -7,10 +7,14 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { useHistory, useLocation } from "react-router-dom";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { INSERT_TEMPLATE } from "../../graphql/templates.queries";
|
import {
|
||||||
|
INSERT_TEMPLATE,
|
||||||
|
QUERY_TEMPLATES_BY_NAME_FOR_DUPE,
|
||||||
|
} from "../../graphql/templates.queries";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
|
import { client } from "../../App/App.container";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
@@ -37,18 +41,23 @@ export function ShopTemplateAddComponent({
|
|||||||
const handleAdd = async (item) => {
|
const handleAdd = async (item) => {
|
||||||
logImEXEvent("shop_template_add");
|
logImEXEvent("shop_template_add");
|
||||||
|
|
||||||
|
const defaultTemplateData = await client.query({
|
||||||
|
query: QUERY_TEMPLATES_BY_NAME_FOR_DUPE,
|
||||||
|
variables: { name: item.key },
|
||||||
|
});
|
||||||
|
|
||||||
|
const template = defaultTemplateData.data.templates.filter(
|
||||||
|
(t) => t.bodyshopid === null
|
||||||
|
)[0];
|
||||||
|
|
||||||
const result = await insertTemplate({
|
const result = await insertTemplate({
|
||||||
variables: {
|
variables: {
|
||||||
template: {
|
template: {
|
||||||
name: item.key,
|
name: item.key,
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
html: `<div>Insert your custom template here.</div>`,
|
jsontemplate: template && template.jsontemplate,
|
||||||
query: `query JOBS {
|
html: template && template.html,
|
||||||
jobs{
|
query: template && template.query,
|
||||||
id
|
|
||||||
ro_number
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,18 @@ export const QUERY_TEMPLATES_BY_NAME = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
export const QUERY_TEMPLATES_BY_NAME_FOR_DUPE = gql`
|
||||||
|
query QUERY_TEMPLATES_BY_NAME_FOR_DUPE($name: String!) {
|
||||||
|
templates(where: { name: { _eq: $name } }) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
query
|
||||||
|
html
|
||||||
|
bodyshopid
|
||||||
|
jsontemplate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const QUERY_CUSTOM_TEMPLATES = gql`
|
export const QUERY_CUSTOM_TEMPLATES = gql`
|
||||||
query QUERY_CUSTOM_TEMPLATES {
|
query QUERY_CUSTOM_TEMPLATES {
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ export function* onSignInSuccess() {
|
|||||||
|
|
||||||
export function* signInSuccessSaga({ payload }) {
|
export function* signInSuccessSaga({ payload }) {
|
||||||
LogRocket.identify(payload.email);
|
LogRocket.identify(payload.email);
|
||||||
yield put(setInstanceId(payload.uid));
|
|
||||||
|
if (!payload.email.includes("@imex.")) yield put(setInstanceId(payload.uid));
|
||||||
yield logImEXEvent("redux_sign_in_success");
|
yield logImEXEvent("redux_sign_in_success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user