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 { useHistory, useLocation } from "react-router-dom";
|
||||
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 { TemplateList } from "../../utils/TemplateConstants";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { client } from "../../App/App.container";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
@@ -37,18 +41,23 @@ export function ShopTemplateAddComponent({
|
||||
const handleAdd = async (item) => {
|
||||
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({
|
||||
variables: {
|
||||
template: {
|
||||
name: item.key,
|
||||
bodyshopid: bodyshop.id,
|
||||
html: `<div>Insert your custom template here.</div>`,
|
||||
query: `query JOBS {
|
||||
jobs{
|
||||
id
|
||||
ro_number
|
||||
}
|
||||
}`,
|
||||
jsontemplate: template && template.jsontemplate,
|
||||
html: template && template.html,
|
||||
query: template && template.query,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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`
|
||||
query QUERY_CUSTOM_TEMPLATES {
|
||||
|
||||
@@ -164,7 +164,8 @@ export function* onSignInSuccess() {
|
||||
|
||||
export function* signInSuccessSaga({ payload }) {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user