-
-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathLoginAdvice.tsx
More file actions
36 lines (33 loc) · 931 Bytes
/
LoginAdvice.tsx
File metadata and controls
36 lines (33 loc) · 931 Bytes
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
import React from "react";
import { Alert } from "reactstrap";
import { Link } from "react-router-dom";
import { UserResponse } from "../Internal/types";
import { ACCOUNT_INFO } from "../../utils/RouterPath";
import { useLoginLink } from "../../utils/Url";
interface Props {
user: UserResponse | undefined;
loading: boolean;
}
export const LoginAdvice: React.FC<Props> = (props) => {
const loginLink = useLoginLink();
if (!props.user) {
return (
<Alert color="danger">
<a href={loginLink}>Login</a> to record your progress.
</Alert>
);
}
if (props.loading) {
return <Alert color="primary">Loading user info...</Alert>;
}
if (!props.user.atcoder_user_id) {
return (
<Alert color="warning">
<Link to={ACCOUNT_INFO}>Set your AtCoder ID.</Link>
</Alert>
);
}
return (
<Alert color="success">Training as {props.user.atcoder_user_id}</Alert>
);
};