2023-03-15 20:06:21 +00:00
|
|
|
// ui
|
2023-06-19 07:29:57 +00:00
|
|
|
import { CalendarGraph } from "components/ui";
|
2023-03-15 20:06:21 +00:00
|
|
|
// helpers
|
2023-06-19 07:29:57 +00:00
|
|
|
import { renderShortDateWithYearFormat } from "helpers/date-time.helper";
|
2023-03-23 10:24:59 +00:00
|
|
|
// types
|
|
|
|
import { IUserActivity } from "types";
|
2023-03-15 20:06:21 +00:00
|
|
|
|
2023-03-23 10:24:59 +00:00
|
|
|
type Props = {
|
|
|
|
activities: IUserActivity[] | undefined;
|
|
|
|
};
|
|
|
|
|
2023-06-19 07:29:57 +00:00
|
|
|
export const ActivityGraph: React.FC<Props> = ({ activities }) => (
|
|
|
|
<CalendarGraph
|
|
|
|
data={
|
|
|
|
activities?.map((activity) => ({
|
|
|
|
day: activity.created_date,
|
|
|
|
value: activity.activity_count,
|
|
|
|
})) ?? []
|
2023-03-15 20:06:21 +00:00
|
|
|
}
|
2023-06-19 07:29:57 +00:00
|
|
|
from={activities?.length ? activities[0].created_date : new Date()}
|
|
|
|
to={activities?.length ? activities[activities.length - 1].created_date : new Date()}
|
|
|
|
height="200px"
|
|
|
|
margin={{ bottom: 0, left: 10, right: 10, top: 0 }}
|
|
|
|
tooltip={(datum) => (
|
|
|
|
<div className="rounded-md border border-brand-base bg-brand-surface-2 p-2 text-xs">
|
|
|
|
<span className="text-brand-secondary">{renderShortDateWithYearFormat(datum.day)}:</span>{" "}
|
|
|
|
{datum.value}
|
2023-03-15 20:06:21 +00:00
|
|
|
</div>
|
2023-06-19 07:29:57 +00:00
|
|
|
)}
|
|
|
|
theme={{
|
|
|
|
background: "rgb(var(--color-bg-base))",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|