-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
66 lines (63 loc) · 2.35 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Sample React Native App
* @format
*/
import { SpiffCommerceClient, WorkflowExperience } from "@spiffcommerce/core";
import React, { useEffect, useState } from "react";
import { Text, View } from "react-native";
/**
* This is the main wrapper component for the App editor.
* See app in src/index.tsx for usage.
*/
const App: React.FunctionComponent<{
/**
* The workflow to be used.
*/
workflowId: string;
/**
* The integration product associated to the workflow being run.
*/
integrationProductId: string;
}> = ({ workflowId, integrationProductId }) => {
const [workflowExperience, setWorkflowExperience] = useState<WorkflowExperience | undefined>(undefined);
// This effect handles initialize of the workflow experience when the user first arrives at the page. Loading
// saved designs will be handled within App separately.
useEffect(() => {
const init = async () => {
// TODO: Core currently does not provide a way to supply a custom storage provider. This should be updated once that is available.
const client = new SpiffCommerceClient({});
const experience = await client.getWorkflowExperience(
workflowId,
undefined,
(workflow) => {
// TODO: implement a 3D preview service.
},
{
type: "integration",
integrationProductId,
workflowId: workflowId,
},
);
// experience.getWorkflowManager().getPreviewService().registerView(canvasRef.current);
setWorkflowExperience(experience);
};
init().then(() => console.log("Workflow Experience Initialized"));
// We only want this to run when the parameters passed in change. The workflow experience
// changing internally due to saved designs etc.. Should not trigger this.
}, [integrationProductId, workflowId]);
return (
<View
style={{
flex: 1,
overflow: "hidden",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
}}
>
<Text>Welcome to React Native 👋</Text>
</View>
);
};
export default App;