Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2390 Rev 2391
Línea 6... Línea 6...
6
 
6
 
7
import { axios } from '@app/utils'
7
import { axios } from '@app/utils'
Línea 8... Línea 8...
8
import useFetch from '@app/hooks/useFetch'
8
import useFetch from '@app/hooks/useFetch'
9
 
-
 
10
import Widget from '@app/components/UI/Widget'
9
 
Línea 11... Línea 10...
11
import SurveyForm from '@app/components/survey-form/SurveyForm'
10
import Widget from '@app/components/UI/Widget'
12
import AuthNavbar from '@app/components/UI/auth-navbar'
11
import AuthNavbar from '@app/components/UI/auth-navbar'
13
 
12
 
Línea 43... Línea 42...
43
            alignItems: 'center'
42
            alignItems: 'center'
44
          }}
43
          }}
45
        >
44
        >
46
          <Grid item xs={12} md={8}>
45
          <Grid item xs={12} md={8}>
47
            <Widget>
46
            <Widget>
48
              <Widget.Header
-
 
49
                avatar={post.shared_image}
47
              <Widget.Media alt={post.title} src={post.image} />
50
                title={post.shared_title}
-
 
51
              />
-
 
52
 
48
 
53
              <Widget.Body>
-
 
54
                <FeedContent
-
 
55
                  type='description'
-
 
56
                  content={{ owner_description: post.shared_description ?? '' }}
49
              <Widget.Body>{parse(post.description)}</Widget.Body>
57
                />
-
 
58
              </Widget.Body>
-
 
59
            </Widget>
50
            </Widget>
60
          </Grid>
51
          </Grid>
61
        </Grid>
52
        </Grid>
62
      </Container>
53
      </Container>
63
    </>
54
    </>
64
  )
55
  )
65
}
56
}
Línea 66... Línea -...
66
 
-
 
67
const FeedContent = ({ type, content }) => {
-
 
68
  const renderContent = ({
-
 
69
    owner_description,
-
 
70
    owner_file_image_preview,
-
 
71
    owner_file_video,
-
 
72
    owner_file_image,
-
 
73
    shared_name,
-
 
74
    shared_image,
-
 
75
    shared_time_elapse,
-
 
76
    feed_vote_url
-
 
77
  }) => {
-
 
78
    switch (type) {
-
 
79
      case 'fast-survey': {
-
 
80
        const answers = []
-
 
81
        const votes = []
-
 
82
 
-
 
83
        for (let i = 1; i < 6; i++) {
-
 
84
          answers.push(owner_description[`answer${i}`])
-
 
85
          votes.push(owner_description[`votes${i}`])
-
 
86
        }
-
 
87
 
-
 
88
        return (
-
 
89
          <SurveyForm
-
 
90
            active={owner_description.active}
-
 
91
            question={owner_description.question}
-
 
92
            answers={answers}
-
 
93
            votes={votes}
-
 
94
            time={owner_description.time_remaining}
-
 
95
            voteUrl={feed_vote_url}
-
 
96
            resultType={owner_description.result_type}
-
 
97
          />
-
 
98
        )
-
 
99
      }
-
 
100
 
-
 
101
      case 'video': {
-
 
102
        return (
-
 
103
          <>
-
 
104
            {parse(owner_description ?? '')}
-
 
105
            <video controls poster={owner_file_image_preview}>
-
 
106
              <source src={owner_file_video} />
-
 
107
            </video>
-
 
108
          </>
-
 
109
        )
-
 
110
      }
-
 
111
 
-
 
112
      case 'image': {
-
 
113
        return (
-
 
114
          <>
-
 
115
            {parse(owner_description ?? '')}
-
 
116
            <img src={owner_file_image} loading='lazy' />
-
 
117
          </>
-
 
118
        )
-
 
119
      }
-
 
120
 
-
 
121
      case 'document': {
-
 
122
        return (
-
 
123
          <>
-
 
124
            {parse(owner_description ?? '')}
-
 
125
            <a href={document} target='_blank' rel='noreferrer'>
-
 
126
              <img className='pdf' src='/images/extension/pdf.png' alt='pdf' />
-
 
127
            </a>
-
 
128
          </>
-
 
129
        )
-
 
130
      }
-
 
131
 
-
 
132
      case 'shared': {
-
 
133
        return (
-
 
134
          <>
-
 
135
            {parse(owner_description ?? '')}
-
 
136
            <Widget>
-
 
137
              <Widget.Header
-
 
138
                avatar={shared_image}
-
 
139
                title={shared_name}
-
 
140
                subheader={shared_time_elapse}
-
 
141
              />
-
 
142
 
-
 
143
              <Widget.Body>
-
 
144
                {renderContent({
-
 
145
                  owner_description,
-
 
146
                  owner_file_image_preview,
-
 
147
                  owner_file_video,
-
 
148
                  owner_file_image,
-
 
149
                  shared_name,
-
 
150
                  shared_image,
-
 
151
                  shared_time_elapse,
-
 
152
                  feed_vote_url
-
 
153
                })}
-
 
154
              </Widget.Body>
-
 
155
            </Widget>
-
 
156
          </>
-
 
157
        )
-
 
158
      }
-
 
159
 
-
 
160
      default: {
-
 
161
        return parse(owner_description)
-
 
162
      }
-
 
163
    }
-
 
164
  }
-
 
165
 
-
 
166
  return <>{renderContent(content)}</>
-
 
167
}
-
 
168
 
57