Skip to content

Commit 7d9e634

Browse files
author
Elise Bach
committed
Added actor + a bit more structure and styling
1 parent 206c3a9 commit 7d9e634

File tree

6 files changed

+90
-36
lines changed

6 files changed

+90
-36
lines changed

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!apiKey) {
99
throw new Error("Please set the `PLAIN_API_KEY` environment variable");
1010
}
1111

12-
const client = new PlainClient({
12+
export const client = new PlainClient({
1313
apiKey,
1414
});
1515

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
.main {
22
display: flex;
3-
flex-direction: column;
4-
gap: 16px;
5-
align-items: center;
6-
padding: 6rem;
3+
justify-content: space-between;
74
min-height: 100vh;
5+
width: 100%;
6+
}
7+
8+
.timeline {
9+
padding: 24px;
10+
flex-grow: 1;
11+
}
12+
13+
.threadinfo {
14+
min-width: 350px;
15+
padding: 24px;
16+
background: #fff;
17+
border-left: 1px solid #eee;
818
}
919

1020
.message {
11-
border: 1px solid #ccc;
12-
border-radius: 8px;
1321
padding: 12px;
22+
border-bottom: 1px solid #eee;
23+
width: 100%;
1424
}

app/thread/[threadId]/page.tsx

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import Navigation from "@/components/navigation";
22
import styles from "./page.module.css";
3+
import Actor from "@/components/actor";
4+
import { ActorPartsFragment } from "@team-plain/typescript-sdk";
5+
6+
function getFullname(actor) {
7+
switch (actor.__typename) {
8+
case "CustomerActor": {
9+
return actor.customer.fullName;
10+
}
11+
case "UserActor": {
12+
return actor.user.fullName;
13+
}
14+
case "MachineUserActor": {
15+
return actor.user.fullName;
16+
}
17+
}
18+
}
319

420
export default async function ThreadPage({
521
params,
@@ -79,25 +95,33 @@ export default async function ThreadPage({
7995
<>
8096
<Navigation hasBackButton title={thread.title} />
8197
<main className={styles.main}>
82-
<div className={styles.message}>
83-
{timelineEntries.edges.map((entry) => {
84-
console.log("ENTRY", entry);
98+
<div className={styles.timeline}>
99+
<div className={styles.message}>
100+
{timelineEntries.edges.map((e) => {
101+
const entry = e.node;
102+
console.log("ENTRY", entry.actor);
85103

86-
return (
87-
<div key={entry.node.id}>
88-
{entry.node.entry.components.map((component, idx) => {
89-
if (component.__typename === "ComponentText") {
90-
return (
91-
<div key={`comp_${component.text}`}>{component.text}</div>
92-
);
93-
}
104+
return (
105+
<div key={entry.id}>
106+
<Actor fullName={getFullname(entry.actor)} />
107+
{entry.entry.components.map((component, idx) => {
108+
if (component.__typename === "ComponentText") {
109+
return (
110+
<div key={`comp_${component.text}`}>
111+
{component.text}
112+
</div>
113+
);
114+
}
94115

95-
return <div key={`comp_${idx}`}>TODO</div>;
96-
})}
97-
</div>
98-
);
99-
})}
116+
return <div key={`comp_${idx}`}>TODO</div>;
117+
})}
118+
</div>
119+
);
120+
})}
121+
</div>
100122
</div>
123+
124+
<div className={styles.threadinfo}>jkdsfjkfsd</div>
101125
</main>
102126
</>
103127
);

components/actor.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.actor {
2+
display: flex;
3+
gap: 8px;
4+
align-items: center;
5+
margin-bottom: 12px;
6+
}
7+
8+
.avatar {
9+
background: #000;
10+
color: #fff;
11+
border-radius: 100%;
12+
padding: 8px;
13+
width: 24px;
14+
height: 24px;
15+
display: flex;
16+
justify-content: center;
17+
align-items: center;
18+
}

components/actor.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import styles from "./actor.module.css";
2+
3+
export default function Actor({
4+
fullName,
5+
}: {
6+
fullName: string;
7+
}) {
8+
return (
9+
<div className={styles.actor}>
10+
<div className={styles.avatar}>{fullName[0].toUpperCase()}</div>
11+
<div>{fullName}</div>
12+
</div>
13+
);
14+
}

components/navigation.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
import styles from "./navigation.module.css";
2-
import { PlainClient } from "@team-plain/typescript-sdk";
32

4-
export const fetchCache = "force-no-store";
5-
6-
const apiKey = process.env.PLAIN_API_KEY;
7-
if (!apiKey) {
8-
throw new Error("Please set the `PLAIN_API_KEY` environment variable");
9-
}
10-
11-
const client = new PlainClient({
12-
apiKey,
13-
});
14-
15-
export default async function Navigation({
3+
export default function Navigation({
164
hasBackButton = false,
175
title,
186
}: {

0 commit comments

Comments
 (0)