-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.component.tsx
More file actions
43 lines (36 loc) · 892 Bytes
/
dashboard.component.tsx
File metadata and controls
43 lines (36 loc) · 892 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
37
38
39
40
41
42
43
import { ApiClient } from "adminjs";
import React, { useEffect, useState } from "react";
import styled from "styled-components";
type DashboardResponse = {
moviesCount: number;
}
export const Dashboard = () => {
const [data, setData] = useState<DashboardResponse>({ moviesCount: 0 });
const api = new ApiClient();
useEffect(() => {
getData();
}, []);
const getData = async () => {
const response = await api.getDashboard<DashboardResponse>();
setData(response.data);
};
const Box = styled.div`
background-color: #fff;
border-radius: 4px;
padding: 20px;
margin: 20px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
border-color: #ddd;
max-width: 200px;
`
return (
<div>
<h1>Dashboard</h1>
<Box>
<h2>Filmes</h2>
<span>{data.moviesCount}</span>
</Box>
</div>
);
};
export default Dashboard;