-
Notifications
You must be signed in to change notification settings - Fork 355
/
FlagDetails.tsx
48 lines (42 loc) · 1.11 KB
/
FlagDetails.tsx
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
import React, { FunctionComponent } from "react";
import NotAvailable from "coral-admin/components/NotAvailable";
import FlagDetailsCategory from "./FlagDetailsCategory";
import FlagDetailsEntry from "./FlagDetailsEntry";
interface Props {
category: React.ReactNode;
nodes: ReadonlyArray<{
flagger: { id: string; username: string | null } | null;
additionalDetails: string | null;
}>;
onUsernameClick: (id?: string) => void;
}
const FlagDetails: FunctionComponent<Props> = ({
category,
nodes,
onUsernameClick,
}) => {
if (nodes.length === 0) {
return null;
}
return (
<FlagDetailsCategory category={category}>
{nodes.map((flag, i) => (
<FlagDetailsEntry
key={i}
onClick={() =>
flag.flagger ? onUsernameClick(flag.flagger.id) : null
}
user={
flag.flagger && flag.flagger.username ? (
flag.flagger.username
) : (
<NotAvailable />
)
}
details={flag.additionalDetails}
/>
))}
</FlagDetailsCategory>
);
};
export default FlagDetails;