51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import React from "react";
|
|
import { useState, useEffect } from "react";
|
|
import { Question, Chevron } from "./assets";
|
|
|
|
const Analytics: React.FC = () => {
|
|
const [viewCount, setViewCount] = useState(0);
|
|
const [clickCount, setClickCount] = useState(0);
|
|
|
|
useEffect(() => {
|
|
fetch("https://dog.ceo/api/breeds/list/all") // TODO: Change to '/api/editor/links'
|
|
.then((results) => results.json())
|
|
.then((data) => {
|
|
console.log("Success:", data);
|
|
// TODO: Assign the correct values here:
|
|
// setViewCount(data.views);
|
|
// setClickCount(data.clicks);
|
|
})
|
|
.catch((error) => {
|
|
console.error("Error:", error);
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<div className="w-full h-12 lt-lg:h-16 mr-0 px-4 lt-lg:px-6 flex flex-row border-b border-analytics-border text-sm font-karla">
|
|
<div className="w-full h-full flex-analytics flex flex-row justify-start items-center">
|
|
<span className="mr-4 font-bold">Lifetime Analytics:</span>
|
|
<div className="mr-8 flex flex-row justify-center items-center">
|
|
<div className="h-2 w-2 mr-2 rounded bg-analytics-view-icon"></div>
|
|
<div className="flex flex-col lt-lg:flex-row text-xs lt-lg:text-base font-normal">
|
|
<p className="whitespace-pre">Views: </p>
|
|
<p className="font-bold lt-lg:font-normal">{viewCount || "-"}</p>
|
|
</div>
|
|
</div>
|
|
<div className="mr-8 flex flex-row justify-center items-center">
|
|
<div className="h-2 w-2 mr-2 rounded bg-analytics-click-icon"></div>
|
|
<div className="flex flex-col lt-lg:flex-row text-xs lt-lg:text-base font-normal">
|
|
<p className="whitespace-pre">Clicks: </p>
|
|
<p className="font-bold lt-lg:font-normal">{clickCount || "-"}</p>
|
|
</div>
|
|
</div>
|
|
<div>{Question}</div>
|
|
</div>
|
|
<div className="w-full h-full flex-chevron flex flex-row justify-center items-center">
|
|
{Chevron}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Analytics;
|