import React, { useEffect, useMemo, useState } from 'react'; import { Alert, Badge, Breadcrumb, BreadcrumbItem, Button, ButtonDropdown, ButtonGroup, Col, DropdownItem, DropdownMenu, DropdownToggle, ListGroup, Progress, Row, Table, } from 'reactstrap'; import { Bell, ChatDots, Cloud, Eye, Person, Telephone, } from 'react-bootstrap-icons'; import { Link } from 'react-router-dom'; import { useAppDispatch, useAppSelector } from '../../app/hooks'; import { fetchPosts } from '../../features/posts/postsSlice'; import Widget from '../../components/Widget'; import s from './Dashboard.module.scss'; const formatDate = (value) => new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric', year: 'numeric', }).format(new Date(value)); const quickLinks = [ { to: '/app/main', label: 'Incoming calls', icon: Telephone, badge: { color: 'danger', value: '3' }, }, { to: '/app/notifications', label: 'Notifications', icon: Bell, badge: { color: 'warning', value: '6' }, }, { to: '/app/posts', label: 'Messages', icon: ChatDots, badge: { color: 'success', value: '18' }, }, { to: '/app/main', label: 'Visits total', icon: Eye, }, { to: '/app/main', label: 'Inbox', icon: Cloud, }, ]; const Dashboard = () => { const dispatch = useAppDispatch(); const posts = useAppSelector((state) => state.posts.items); const fetchStatus = useAppSelector((state) => state.posts.fetchStatus); const [isDropdownOpened, setIsDropdownOpened] = useState(false); useEffect(() => { if (fetchStatus === 'idle' && posts.length === 0) { dispatch(fetchPosts()); } }, [dispatch, fetchStatus, posts.length]); const recentPosts = useMemo(() => posts.slice(0, 5), [posts]); return (
| ID | Username | Status | |
|---|---|---|---|
| {id} | {username} | {email} | {status} |
Latest entries from the local demo feed.
)} >| {formatDate(post.updatedAt)} | {post.title} |
| Loading... | |
| No posts yet. | |
For more components, check the{' '} reactstrap documentation .