-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-basic-app.jsx
More file actions
56 lines (50 loc) · 1.61 KB
/
Copy path01-basic-app.jsx
File metadata and controls
56 lines (50 loc) · 1.61 KB
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
/**
* 01 — Basic single-page app
*
* The smallest useful setup: provider, identify the current user, render
* one thread for the resource the page is about.
*
* Assumes your backend already gave you hashed codes via your auth/page API.
* Hashing must happen server-side (see ../README.md).
*/
import {
StromcomProvider,
StromcomConf,
StromcomUser,
StromcomThread,
StromcomHome,
} from '@stromcom/react-snippet';
const CLIENT_KEY = import.meta.env.VITE_STROMCOM_CLIENT_KEY;
const CLIENT_SECRET = import.meta.env.VITE_STROMCOM_CLIENT_SECRET;
export default function App({ user, order }) {
return (
<StromcomProvider clientKey={CLIENT_KEY} clientSecret={CLIENT_SECRET}>
{/* App-level: configuration & current user — render once. */}
<StromcomConf
theme={null} // follow browser preference
notificationElementPosition={3} // bottom-right
onNotification={(count) => {
document.title = count > 0 ? `(${count}) Inbox — Acme` : 'Acme';
}}
/>
<StromcomUser
code={user.stromcomHash}
name={user.name}
emailAddress={user.email}
avatarURL={user.avatar}
/>
{/* Per-resource: one thread for the order this page shows. */}
<main>
<h1>Order #{order.id}</h1>
<StromcomThread
code={order.stromcomHash}
name={`Order #${order.id}`}
url={window.location.href}
style={{ height: 500, border: '1px solid #ddd', borderRadius: 8 }}
/>
</main>
{/* Floating notification center — render once. */}
<StromcomHome />
</StromcomProvider>
);
}