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/frontend/account/profile-settings.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 { useIntl } from "react-intl";
7
import { Panel } from "@cocalc/frontend/antd-bootstrap";
8
import { Rendered, useTypedRedux } from "@cocalc/frontend/app-framework";
9
import { ColorPicker } from "@cocalc/frontend/colorpicker";
10
import { Gap, LabeledRow, Loading } from "@cocalc/frontend/components";
11
import { labels } from "@cocalc/frontend/i18n";
12
import { Avatar } from "./avatar/avatar";
13
import { ProfileImageSelector, setProfile } from "./profile-image";
14
15
interface Props {
16
email_address?: string;
17
// first_name?: string;
18
// last_name?: string;
19
}
20
21
export function ProfileSettings({ email_address }: Props) {
22
const intl = useIntl();
23
24
// const [show_instructions, set_show_instructions] = useState<boolean>(false);
25
26
const account_id: string = useTypedRedux("account", "account_id");
27
const profile = useTypedRedux("account", "profile");
28
29
function onColorChange(value: string) {
30
setProfile({
31
account_id,
32
profile: { color: value },
33
});
34
}
35
36
function render_header(): Rendered {
37
return (
38
<>
39
<Avatar account_id={account_id} size={48} />
40
<Gap />
41
<Gap />
42
Avatar
43
</>
44
);
45
}
46
47
if (account_id == null || profile == null) {
48
return <Loading />;
49
}
50
51
return (
52
<Panel header={render_header()}>
53
<LabeledRow label={intl.formatMessage(labels.color)}>
54
<ColorPicker
55
color={profile?.get("color")}
56
justifyContent={"flex-start"}
57
onChange={onColorChange}
58
/>
59
</LabeledRow>
60
<LabeledRow label="Style">
61
<ProfileImageSelector
62
account_id={account_id}
63
email_address={email_address}
64
profile={profile}
65
/>
66
</LabeledRow>
67
</Panel>
68
);
69
}
70
71