CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/account/account.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { useEffect } from "react";
7
import { useRouter } from "next/router";
8
import { trunc } from "lib/share/util";
9
import Loading from "components/share/loading";
10
import { Customize } from "lib/share/customize";
11
import PublicPaths from "components/share/public-paths";
12
import { Layout } from "components/share/layout";
13
import Avatar from "components/account/avatar";
14
15
interface Props {
16
first_name: string;
17
last_name: string;
18
publicPaths;
19
customize;
20
account_id: string;
21
redirect?: string;
22
}
23
24
export default function Account({
25
first_name,
26
last_name,
27
publicPaths,
28
customize,
29
account_id,
30
redirect,
31
}: Props) {
32
const router = useRouter();
33
useEffect(() => {
34
if (redirect) {
35
router.replace(redirect);
36
}
37
}, [redirect]);
38
39
if (first_name == null || last_name == null || publicPaths == null) {
40
return <Loading style={{ fontSize: "30px" }} />;
41
}
42
const name = trunc(`${first_name} ${last_name}`, 150);
43
const client_id = customize.account?.account_id;
44
return (
45
<Customize value={customize}>
46
<Layout title={name}>
47
<h1>
48
<Avatar account_id={account_id} /> {name}
49
</h1>
50
{client_id == account_id ? (
51
<>
52
You are an active collaborator on projects that contain the
53
published documents listed below. We include any unlisted or
54
disabled published documents so that you can browse or edit them
55
from here. This full list is only visible to you (other people only
56
see public documents).
57
</>
58
) : (
59
<>
60
{name} is an active collaborator on projects that contain the
61
following public documents:
62
</>
63
)}
64
<br />
65
<br />
66
<PublicPaths publicPaths={publicPaths} />
67
</Layout>
68
</Customize>
69
);
70
}
71
72