|
|
|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
//import {useMutation, useQuery } from "@apollo/client";
|
|
|
|
|
import { Button, Form, Layout, Result, Typography } from "antd";
|
|
|
|
|
import axios from "axios";
|
|
|
|
|
import React, { useCallback, useEffect, useState } from "react";
|
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
|
@@ -16,7 +16,8 @@ import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
|
|
|
currentUser: selectCurrentUser
|
|
|
|
|
});
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({});
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = () => ({});
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(CsiContainerPage);
|
|
|
|
|
|
|
|
|
|
@@ -28,7 +29,6 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
loading: false,
|
|
|
|
|
submitted: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
const getAxiosData = useCallback(async () => {
|
|
|
|
|
@@ -39,7 +39,6 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
console.log("Unable to attach to crisp instance. ");
|
|
|
|
|
}
|
|
|
|
|
setSubmitting((prevSubmitting) => ({ ...prevSubmitting, loading: true }));
|
|
|
|
|
|
|
|
|
|
const response = await axios.post("/csi/lookup", {
|
|
|
|
|
surveyId
|
|
|
|
|
});
|
|
|
|
|
@@ -91,7 +90,7 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
setSubmitting({ ...submitting, loading: true, submitting: true });
|
|
|
|
|
const result = await axios.post("/csi/submit", { surveyId, values });
|
|
|
|
|
console.log("result", result);
|
|
|
|
|
if (!!!result.errors && result.data.update_csi.affected_rows > 0) {
|
|
|
|
|
if (!result.errors && result.data.update_csi.affected_rows > 0) {
|
|
|
|
|
setSubmitting({ ...submitting, loading: false, submitted: true });
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
@@ -110,7 +109,7 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
<Layout style={{ display: "flex", flexDirection: "column" }}>
|
|
|
|
|
<Layout.Content
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: "#fff",
|
|
|
|
|
backgroundColor: "var(--content-bg)",
|
|
|
|
|
margin: "2em 4em",
|
|
|
|
|
padding: "2em",
|
|
|
|
|
overflowY: "auto",
|
|
|
|
|
@@ -139,7 +138,6 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
relateddata: { bodyshop, job },
|
|
|
|
|
csiquestion: { config: csiquestions }
|
|
|
|
|
} = axiosResponse.csi_by_pk;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Layout style={{ display: "flex", flexDirection: "column" }}>
|
|
|
|
|
<div
|
|
|
|
|
@@ -184,13 +182,11 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
})}
|
|
|
|
|
</Typography.Paragraph>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{submitting.error ? <AlertComponent message={submitting.error} type="error" /> : null}
|
|
|
|
|
|
|
|
|
|
{submitting.submitted ? (
|
|
|
|
|
<Layout.Content
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: "#fff",
|
|
|
|
|
backgroundColor: "var(--content-bg)",
|
|
|
|
|
margin: "2em 4em",
|
|
|
|
|
padding: "2em",
|
|
|
|
|
overflowY: "auto"
|
|
|
|
|
@@ -201,7 +197,7 @@ export function CsiContainerPage({ currentUser }) {
|
|
|
|
|
) : (
|
|
|
|
|
<Layout.Content
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: "#fff",
|
|
|
|
|
backgroundColor: "var(--content-bg)",
|
|
|
|
|
margin: "2em 4em",
|
|
|
|
|
padding: "2em",
|
|
|
|
|
overflowY: "auto"
|
|
|
|
|
|