blob: b9dafc90c8436af7eebd1bf451ae8332f99a7a53 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
idillon-sfl5d174552022-08-23 14:34:24 -040018import { Card, CardActionArea, CardContent, CircularProgress, Typography } from '@mui/material';
simon5da8ca62022-11-09 15:21:25 -050019import { useNavigate } from 'react-router';
simon07b4eb02022-09-29 17:50:26 -040020
idillon07d31cc2022-12-06 22:40:14 -050021import { useConversationsSummariesQuery } from '../services/conversationQueries';
Adrien Béraud150b4782021-04-21 19:40:59 -040022
simon5da8ca62022-11-09 15:21:25 -050023export default function ConversationsOverviewCard() {
simond47ef9e2022-09-28 22:24:28 -040024 const navigate = useNavigate();
simon5da8ca62022-11-09 15:21:25 -050025
idillon07d31cc2022-12-06 22:40:14 -050026 const conversationSummariesQuery = useConversationsSummariesQuery();
Adrien Béraud150b4782021-04-21 19:40:59 -040027
28 return (
simon3f5f3e72022-11-08 21:01:57 -050029 <Card onClick={() => navigate(`/`)}>
Adrien Béraud150b4782021-04-21 19:40:59 -040030 <CardActionArea>
31 <CardContent>
idillonfb2af5b2022-09-16 13:40:08 -040032 <Typography color="textSecondary" gutterBottom>
Adrien Béraud150b4782021-04-21 19:40:59 -040033 Conversations
34 </Typography>
35 <Typography gutterBottom variant="h5" component="h2">
idillon07d31cc2022-12-06 22:40:14 -050036 {conversationSummariesQuery?.data?.length ?? <CircularProgress size={24} />}
Adrien Béraud150b4782021-04-21 19:40:59 -040037 </Typography>
38 </CardContent>
39 </CardActionArea>
40 </Card>
simond47ef9e2022-09-28 22:24:28 -040041 );
Adrien Béraud150b4782021-04-21 19:40:59 -040042}