Add trial request functionality for audit.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { PrinterFilled } from "@ant-design/icons";
|
||||
import { Alert, Button, Card, Col, DatePicker, Form, Input, Row, Space } from "antd";
|
||||
import { Alert, Button, Card, Col, DatePicker, Form, Input, Result, Row, Space } from "antd";
|
||||
import React, { useRef } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { useReactToPrint } from "react-to-print";
|
||||
@@ -11,11 +11,13 @@ import dayjs from "../../../util/day";
|
||||
import AuditResultsOrganism from "../../organisms/audit-results/audit-results.organism";
|
||||
import FeatureWrapper from "../../templates/feature-wrapper";
|
||||
import "./audit.page.styles.scss";
|
||||
import { selectBodyshop } from "../../../redux/user/user.selectors";
|
||||
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
auditError: selectAuditError
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
@@ -23,7 +25,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(AuditPage);
|
||||
|
||||
export function AuditPage({ auditError, queryReportingData }) {
|
||||
export function AuditPage({ auditError, queryReportingData, bodyshop }) {
|
||||
const handleBrowseForFile = async ({ sheetName, dateRange }) => {
|
||||
queryReportingData({
|
||||
startDate: dateRange[0] || dayjs("2024-03-01"),
|
||||
@@ -40,8 +42,14 @@ export function AuditPage({ auditError, queryReportingData }) {
|
||||
window.ref = componentRef.current;
|
||||
if (auditError) console.log("Error when opening audit file.", auditError);
|
||||
return (
|
||||
<FeatureWrapper featureName="audit">
|
||||
<FeatureWrapper featureName="audit" noauth={<NoAuditAccess features={bodyshop.features} />}>
|
||||
<div className="audit-container" id="audit-results-container">
|
||||
{bodyshop.features.audit_trial && (
|
||||
<Alert
|
||||
type="info"
|
||||
message={`You are currently on a trial of the RPS audit functionality. It will expire on ${bodyshop.features.audit_trial}`}
|
||||
/>
|
||||
)}
|
||||
<Row gutter={[16, 16]} ref={componentRef}>
|
||||
<Col span={24}>
|
||||
<Card>
|
||||
@@ -126,3 +134,42 @@ export function AuditPage({ auditError, queryReportingData }) {
|
||||
</FeatureWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
function NoAuditAccess({ features }) {
|
||||
return (
|
||||
<Result
|
||||
status="warning"
|
||||
title="You do not currently have access to the audit feature of RPS."
|
||||
subTitle="Auditing allows you to instantly and automatically find discrepancies between the data you have recorded in RPS and the scorecard provided to your by your SRA."
|
||||
extra={
|
||||
features.audit_trial ? (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
window.$crisp.push(["do", "message:thread:start", ["Subscription Upgrade - RPS Audit"]]);
|
||||
window.$crisp.push(["set", "message:send", ["I would like to subscribe to the RPS Audit feature."]]);
|
||||
}}
|
||||
>
|
||||
Subscribe
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
window.$crisp.push(["set", "session:event", [[["trial_request", { feature: "audit" }]]]]);
|
||||
window.$crisp.push(["do", "message:thread:start", ["Trial Request - RPS Audit"]]);
|
||||
window.$crisp.push([
|
||||
"do",
|
||||
"message:send",
|
||||
["text", "Hello, I would like to request a trial of the RPS audit feature."]
|
||||
]);
|
||||
window.$crisp.push(["do", "chat:open"]);
|
||||
}}
|
||||
>
|
||||
Request Trial
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user