Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
chore(*): code cleanup and indicate props required
Browse files Browse the repository at this point in the history
Signed-off-by: irmerk <[email protected]>
  • Loading branch information
jolanglinais committed Nov 12, 2019
1 parent 142cd5f commit 2d9af85
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 129 deletions.
24 changes: 3 additions & 21 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { render } from 'react-dom';
import 'semantic-ui-css/semantic.min.css';
import ContractEditor from '../../src/ContractEditor';

const templates = {};

const slateTransformer = new SlateTransformer();

const templateUri = 'https://templates.accordproject.org/archives/[email protected]';
Expand Down Expand Up @@ -61,29 +59,13 @@ const parseClause = (template, text, clauseId) => {
}
};

const fetchTemplateObj = async (action) => {
const fetchTemplateObj = async (uri) => {
try {
const templateObj = await Template.fromUrl(action.uri);
const templateObj = await Template.fromUrl(uri);
return templateObj;
} catch (err) { return err; }
};

/**
* Called by the clause plugin into the contract editor
* when we need to load a template
* Note: This is used for example and is not actually used in the demo
*/
const loadTemplate = async (templateUri) => {
let template = templates[templateUri];
if (!template) {
console.log(`Loading template: ${templateUri}`);
template = await Template.fromUrl(templateUri);
templates[templateUri] = template;
}

return template;
};

/**
* A demo component that uses ContractEditor
*/
Expand Down Expand Up @@ -135,7 +117,7 @@ function Demo() {
onChange={onContractChange}
editorProps={editorProps}
parseClause={(uri, text, clauseId) => parseClause(templateObj, text, clauseId)}
loadTemplateObject={loadTemplate}
loadTemplateObject={fetchTemplateObj}
/>;

return (
Expand Down
Loading

0 comments on commit 2d9af85

Please sign in to comment.