Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3607 | Rev 3612 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3607 Rev 3610
Línea 1... Línea 1...
1
import React, { useState } from 'react';
1
import React from 'react';
2
import { Grid } from '@mui/material';
2
import { Grid } from '@mui/material';
Línea 3... Línea 3...
3
 
3
 
Línea 4... Línea 4...
4
import { useFetch, usePagination } from '@shared/hooks';
4
import { useConversations } from '@inmail/hooks';
5
 
5
 
Línea 6... Línea 6...
6
import { Spinner } from '@shared/components';
6
import { Spinner } from '@shared/components';
7
import { ConversationsList, MessagesList } from '@inmail/components';
-
 
8
 
-
 
9
export function InmailPage() {
-
 
10
  const [selectedConversation, setSelectedConversation] = useState(null);
-
 
11
 
7
import { ConversationsList, MessagesList } from '@inmail/components';
12
  const { data: conversations, loading } = useFetch('/email');
8
 
13
 
9
const InmailPage = () => {
-
 
10
  const {
-
 
11
    conversations,
14
  const {
12
    currentConversation,
15
    items: messages,
13
    loading,
16
    loading: loadingMessages,
14
    setCurrentConversation,
17
    elementRef
15
    deleteConversation
18
  } = usePagination(selectedConversation?.messages_url);
16
  } = useConversations();
19
 
17
 
-
 
18
  const toggleConversationModal = () => {
-
 
19
    // TODO: Implementar modal de inicio de conversación
Línea 20... Línea 20...
20
  if (loading || !conversations) {
20
  };
21
    return <Spinner />;
21
 
-
 
22
  if (loading) return <Spinner />;
-
 
23
 
22
  }
24
  return (
-
 
25
    <Grid container spacing={1}>
-
 
26
      <Grid
-
 
27
        item
-
 
28
        xs={12}
-
 
29
        md={4}
23
 
30
        sx={{
24
  return (
31
          display: { xs: currentConversation ? 'none' : 'flex', md: 'flex' }
25
    <Grid container spacing={2}>
32
        }}
-
 
33
      >
26
      <Grid item xs={12} md={3}>
34
        <ConversationsList
27
        <ConversationsList
35
          conversations={conversations}
-
 
36
          onSelectConversation={setCurrentConversation}
-
 
37
          onStartConversation={toggleConversationModal}
-
 
38
        />
-
 
39
      </Grid>
-
 
40
 
-
 
41
      <Grid
-
 
42
        item
-
 
43
        xs={12}
-
 
44
        md={8}
-
 
45
        sx={{
-
 
46
          display: { xs: currentConversation ? 'flex' : 'none', md: 'flex' }
-
 
47
        }}
28
          conversations={conversations}
48
      >
29
          onSelectConversation={setSelectedConversation}
49
        <MessagesList
-
 
50
          conversation={currentConversation}
-
 
51
          onClose={() => setCurrentConversation(null)}
30
        />
52
          onDelete={() =>
31
      </Grid>
53
            currentConversation?.delete_link && deleteConversation(currentConversation.delete_link)
32
      <Grid item xs={12} md={9}>
54
          }
33
        <MessagesList messages={messages} loading={loadingMessages} elementRef={elementRef} />
55
        />
-
 
56
      </Grid>
-
 
57
    </Grid>