forked from langfuse/langfuse-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainContentWrapper.tsx
More file actions
202 lines (193 loc) · 5.9 KB
/
MainContentWrapper.tsx
File metadata and controls
202 lines (193 loc) · 5.9 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import { useRouter } from "next/router";
import { useState } from "react";
import { Button } from "./ui/button";
import {
Calendar,
Mail,
MessageSquare,
ThumbsDown,
ThumbsUp,
} from "lucide-react";
import { Textarea } from "./ui/textarea";
import { openChat } from "./supportChat";
import { Background } from "./Background";
import { NotebookBanner } from "./NotebookBanner";
import { ProductUpdateSignup } from "./productUpdateSignup";
import { COOKBOOK_ROUTE_MAPPING } from "@/lib/cookbook_route_mapping";
import IconGithub from "./icons/github";
const pathsWithoutFooterWidgets = ["/imprint", "/blog"];
export const MainContentWrapper = (props) => {
const router = useRouter();
const cookbook = COOKBOOK_ROUTE_MAPPING.find(
(cookbook) => cookbook.path === router.pathname
);
return (
<>
{cookbook ? (
<NotebookBanner src={cookbook.ipynbPath} className="mb-4" />
) : null}
{props.children}
{!pathsWithoutFooterWidgets.includes(router.pathname) ? (
<div
className="flex flex-col gap-10 pt-14 border-t dark:border-neutral-800 mb-20"
id="docs-feedback"
>
<DocsFeedback key={router.pathname} />
<DocsSupport />
<DocsSubscribeToUpdates />
</div>
) : null}
<Background />
</>
);
};
export const DocsSubscribeToUpdates = () => {
return (
<div className="flex flex-col items-start gap-3">
<h3 className="text-xl font-semibold">Subscribe to updates</h3>
<div className="flex gap-3 flex-wrap">
<ProductUpdateSignup source="docs-footer" small />
</div>
</div>
);
};
export const DocsSupport = () => {
return (
<div className="flex flex-col items-start gap-3">
<h3 className="text-xl font-semibold" id="contact">
Questions? We're here to help
</h3>
<div className="flex gap-3 flex-wrap">
<Button variant="outline" size="sm" asChild>
<a href="/gh-support" target="_blank">
<span>GitHub Q&A</span>
<IconGithub className="h-4 w-4 ml-3" />
</a>
</Button>
<Button variant="outline" size="sm" onClick={() => openChat()}>
<span>Chat</span> <MessageSquare className="h-4 w-4 ml-3" />
</Button>
<Button variant="outline" size="sm" asChild>
<a href="mailto:support@langfuse.com" target="_blank">
<span>Email</span>
<Mail className="h-4 w-4 ml-3" />
</a>
</Button>
<Button variant="outline" size="sm" asChild>
<a href="/schedule-demo" target="_blank">
<span>Talk to sales</span>
<Calendar className="h-4 w-4 ml-3" />
</a>
</Button>
</div>
</div>
);
};
export const DocsFeedback = () => {
const router = useRouter();
const [selected, setSelected] = useState<
"positive" | "negative" | "submitted" | null
>(null);
const [feedbackComment, setFeedbackComment] = useState<string>("");
const [submitting, setSubmitting] = useState<boolean>(false);
const handleFeedbackSelection = (newSelection: "positive" | "negative") => {
setSubmitting(true);
fetch("/api/feedback", {
method: "POST",
body: JSON.stringify({
page: router.pathname,
feedback: newSelection,
}),
})
.then(() => {
setFeedbackComment("");
setSelected(newSelection);
setSubmitting(false);
})
.catch(() => setSelected(null));
};
const handleFeedbackCommentSubmit = () => {
setSubmitting(true);
fetch("/api/feedback", {
method: "POST",
body: JSON.stringify({
page: router.pathname,
feedback: selected,
comment: feedbackComment,
}),
})
.then(() => {
setSelected("submitted");
setFeedbackComment("");
setSubmitting(false);
})
.catch(() => setSelected(null));
};
return (
<div className="flex flex-col gap-3">
<h3 className="text-xl font-semibold">
{selected === null
? "Was this page useful?"
: selected === "positive"
? "What was most useful?"
: selected === "negative"
? "What can we improve?"
: "Thanks for your feedback!"}
</h3>
{selected === null ? (
<div className="flex flex-wrap gap-3">
<Button
variant="outline"
size="xl"
onClick={() => handleFeedbackSelection("positive")}
disabled={submitting}
>
<span>Yes</span>
<ThumbsUp className="h-5 w-5 ml-4 text-green-800" />
</Button>
<Button
variant="outline"
size="xl"
onClick={() => handleFeedbackSelection("negative")}
disabled={submitting}
>
<span>Could be better</span>
<ThumbsDown className="h-5 w-5 ml-4 text-red-800" />
</Button>
</div>
) : selected === "positive" || selected === "negative" ? (
<div className="flex flex-col gap-3">
<Textarea
placeholder={
selected === "positive"
? "Let us know what you found most useful"
: "Let us know what we can improve"
}
value={feedbackComment}
onChange={(e) => setFeedbackComment(e.target.value)}
/>
<Button
variant="secondary"
className="self-start"
size="lg"
disabled={submitting}
onClick={handleFeedbackCommentSubmit}
>
{submitting ? "Submitting ..." : "Send feedback"}
</Button>
</div>
) : (
<div className="flex flex-col gap-3">
<Button
variant="outline"
size="lg"
onClick={() => setSelected(null)}
className="self-start"
>
Send more feedback
</Button>
</div>
)}
</div>
);
};