Basic IIF rendering with test component for BOD-83
This commit is contained in:
@@ -1,143 +1,49 @@
|
||||
import { Editor } from "@tinymce/tinymce-react";
|
||||
import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { EmailSettings } from "../../utils/TemplateConstants";
|
||||
import {
|
||||
endLoading,
|
||||
startLoading,
|
||||
} from "../../redux/application/application.actions";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
load: () => dispatch(startLoading()),
|
||||
endload: () => dispatch(endLoading()),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(function Test({ setEmailOptions, load, endload, bodyshop }) {
|
||||
const [state, setState] = useState(temp);
|
||||
|
||||
const handleEditorChange = (content, editor) => {
|
||||
setState(content);
|
||||
)(function Test({ bodyshop }) {
|
||||
const handle = async () => {
|
||||
console.log(
|
||||
"await auth.currentUser.getIdToken(true)",
|
||||
await auth.currentUser.getIdToken(true)
|
||||
);
|
||||
const response = await axios.post(
|
||||
"/accounting/iif/receivables",
|
||||
{ jobId: "661dd1d5-bf06-426f-8bd2-bd9e41de8eb1" },
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("handle -> result", response);
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.setAttribute(
|
||||
"download",
|
||||
response.headers.filename || "receivables.iif"
|
||||
); //or any other extension
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button
|
||||
onClick={() => {
|
||||
axios
|
||||
.post("/render", {
|
||||
view: state,
|
||||
context: {
|
||||
people: ["Yehuda Katz", "Alan Johnson", "Charles Jolley"],
|
||||
},
|
||||
})
|
||||
.then((r) => {
|
||||
var newWin = window.open(
|
||||
"url",
|
||||
"windowName",
|
||||
"height=300,width=300"
|
||||
);
|
||||
newWin.document.write(r.data);
|
||||
});
|
||||
}}>
|
||||
TinyMCE
|
||||
</button>
|
||||
<Editor
|
||||
value={state}
|
||||
apiKey='f3s2mjsd77ya5qvqkee9vgh612cm6h41e85efqakn2d0kknk'
|
||||
init={{
|
||||
height: 500,
|
||||
//menubar: false,
|
||||
encoding: "raw",
|
||||
extended_valid_elements: "span",
|
||||
|
||||
plugins: [
|
||||
"advlist autolink lists link image charmap print preview anchor",
|
||||
"searchreplace visualblocks code fullscreen",
|
||||
"insertdatetime media table paste code help wordcount",
|
||||
],
|
||||
toolbar:
|
||||
"undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help",
|
||||
}}
|
||||
onEditorChange={handleEditorChange}
|
||||
/>
|
||||
|
||||
<button
|
||||
onClick={() =>
|
||||
setEmailOptions({
|
||||
messageOptions: {
|
||||
to: "patrickwf@gmail.com",
|
||||
Subject: "TODO FIX ME",
|
||||
},
|
||||
template: {
|
||||
name: "appointment_reminder",
|
||||
variables: { id: "2b42336f-b8de-4f04-a053-d6bff034d384" },
|
||||
},
|
||||
})
|
||||
}>
|
||||
Set email config.
|
||||
</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
setEmailOptions({
|
||||
messageOptions: {
|
||||
from: {
|
||||
name: bodyshop.shopname || EmailSettings.fromNameDefault,
|
||||
address: EmailSettings.fromAddress,
|
||||
},
|
||||
to: "patrickwf@gmail.com",
|
||||
replyTo: bodyshop.email,
|
||||
Subject: "TODO FIX ME",
|
||||
},
|
||||
template: {
|
||||
name: "parts_order_confirmation",
|
||||
variables: { id: "6fea31e9-ea85-4c89-ac56-6f9cc84531fe" },
|
||||
},
|
||||
})
|
||||
}>
|
||||
Parts Order
|
||||
</button>
|
||||
<button onClick={handle}>Hit with Header.</button>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
const temp = `<div style="font-family: Arial, Helvetica, sans-serif;">
|
||||
<p style="text-align: center;"><span>→<span> This is a full-featured editor demo. </span>Please explore! ←</span></p>
|
||||
<p style="text-align: center;"> </p>
|
||||
<h2 style="text-align: center;"><span>TinyMCE is the world's most customizable, and flexible, rich text editor.</span></h2>
|
||||
<p style="text-align: center;"><span><strong> A featherweight download, TinyMCE can handle any challenge you throw at it. </strong></span></p>
|
||||
<p style="text-align: center;"> </p>
|
||||
<p> </p>
|
||||
<table style="border-collapse: collapse; width: 85%; height: 86px; border-color: initial; border-style: solid; margin-left: auto; margin-right: auto;">
|
||||
<tbody>
|
||||
<tr style="height: 22px;">
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px;"><span>🛠 50+ Plugins</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px;"><span>💡 Premium Support</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px;"><span>🖍 Custom Skins</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px;"><span>⚙ Full API Access</span></td>
|
||||
</tr>
|
||||
<tr style="height: 21px; display: none;">
|
||||
<td style="height: 21px; display: none;"><span>{{#each people}}</span></td>
|
||||
</tr>
|
||||
<tr style="height: 22px;">
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px; border-style: solid; border-width: 1px;"><span>{{this}}</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px; border-style: solid; border-width: 1px;"><span>{{this}}</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px; border-style: solid; border-width: 1px;"><span>{{this}}</span></td>
|
||||
<td style="width: 25%; text-align: center; padding: 7px; height: 22px; border-style: solid; border-width: 1px;"><span>{{this}}</span></td>
|
||||
</tr>
|
||||
<tr style="height: 21px; display: none;">
|
||||
<td style="height: 21px;"><span>{{/each}}</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>`;
|
||||
|
||||
@@ -50,7 +50,7 @@ export function JobsCloseSaveButton({
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
console.log("suspense", suspenseAmount);
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
|
||||
@@ -576,7 +576,7 @@
|
||||
"rate_la3": "LA3 Rate",
|
||||
"rate_la4": "LA4 Rate",
|
||||
"rate_laa": "Aluminum Rate",
|
||||
"rate_lab": "Labor Rate",
|
||||
"rate_lab": "Body Rate",
|
||||
"rate_lad": "Diagnostic Rate",
|
||||
"rate_lae": "Electrical Rate",
|
||||
"rate_laf": "Frame Rate",
|
||||
|
||||
Reference in New Issue
Block a user