Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2780 Rev 2806
Línea 1... Línea 1...
1
import React, { useMemo, useRef, useState } from 'react'
1
import React, { useMemo, useRef, useState } from 'react'
2
import { useLocation } from 'react-router-dom'
2
import { useLocation } from 'react-router-dom'
3
import { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
4
import { Box, Container, Grid, MenuItem, Select, styled } from '@mui/material'
4
import { Box, Grid, MenuItem, Select, styled } from '@mui/material'
5
import { Search } from '@mui/icons-material'
5
import { Search } from '@mui/icons-material'
Línea 6... Línea 6...
6
 
6
 
7
import { axios, debounce } from '../../utils'
7
import { axios, debounce } from '../../utils'
8
import { useFetch, useSearchParams } from '@hooks'
8
import { useFetch, useSearchParams } from '@hooks'
Línea 97... Línea 97...
97
 
97
 
Línea 98... Línea 98...
98
  const handleInputChange = debounce((value) => setParams('search', value), 500)
98
  const handleInputChange = debounce((value) => setParams('search', value), 500)
99
 
99
 
100
  return (
-
 
101
    <>
100
  return (
102
      <Container sx={{ px: 0 }}>
101
    <>
103
        <TitleSection
102
      <TitleSection
104
          title={labels.my_coach}
103
        title={labels.my_coach}
105
          onAdd={() => addQuestion()}
104
        onAdd={() => addQuestion()}
106
          addLabel={labels.my_coach_question_add}
105
        addLabel={labels.my_coach_question_add}
107
        />
106
      />
108
 
107
 
109
        <Grid container spacing={2} sx={{ pt: 1 }}>
108
      <Grid container spacing={2} sx={{ pt: 1 }}>
110
          <Grid
109
        <Grid
111
            item
110
          item
-
 
111
          xs={12}
-
 
112
          md={3}
-
 
113
          sx={{
-
 
114
            display: { md: 'block', xs: 'none' }
-
 
115
          }}
-
 
116
        >
-
 
117
          <SideMenu
-
 
118
            title='Categorias'
-
 
119
            items={categories}
-
 
120
            onChange={(value) => setParams('category_id', value)}
-
 
121
            current={params.category_id}
-
 
122
          />
-
 
123
        </Grid>
-
 
124
 
-
 
125
        <Grid item xs={12} md={9}>
-
 
126
          <Input
-
 
127
            icon={Search}
-
 
128
            onChange={(e) => handleInputChange(e.target.value)}
-
 
129
            placeholder={labels.search}
-
 
130
            className='mx-3 mx-md-0'
-
 
131
          />
-
 
132
 
-
 
133
          <Select
-
 
134
            name='categories'
112
            xs={12}
135
            options={categories}
-
 
136
            onChange={(e) => setParams('category_id', e.target.value)}
-
 
137
            sx={{
113
            md={3}
138
              mt: 1,
114
            sx={{
139
              mx: 2,
115
              display: { md: 'block', xs: 'none' }
140
              display: { md: 'none', xs: 'block' }
116
            }}
-
 
117
          >
-
 
118
            <SideMenu
-
 
119
              title='Categorias'
-
 
120
              items={categories}
-
 
121
              onChange={(value) => setParams('category_id', value)}
-
 
122
              current={params.category_id}
-
 
123
            />
-
 
124
          </Grid>
-
 
125
 
-
 
126
          <Grid item xs={12} md={9}>
-
 
127
            <Input
-
 
128
              icon={Search}
-
 
129
              onChange={(e) => handleInputChange(e.target.value)}
-
 
130
              placeholder={labels.search}
-
 
131
              className='mx-3 mx-md-0'
-
 
132
            />
-
 
133
 
-
 
134
            <Select
-
 
135
              name='categories'
-
 
136
              options={categories}
-
 
137
              onChange={(e) => setParams('category_id', e.target.value)}
-
 
138
              sx={{
-
 
139
                mt: 1,
-
 
140
                mx: 2,
-
 
141
                display: { md: 'none', xs: 'block' }
-
 
142
              }}
141
            }}
143
            >
142
          >
144
              {categories.map(({ name, value }) => (
143
            {categories.map(({ name, value }) => (
145
                <MenuItem key={value} value={value}>
144
              <MenuItem key={value} value={value}>
146
                  {name}
145
                {name}
147
                </MenuItem>
146
              </MenuItem>
148
              ))}
147
            ))}
149
            </Select>
148
          </Select>
150
 
149
 
151
            <QuestionsGrid className='mt-3'>
150
          <QuestionsGrid className='mt-3'>
152
              {data.items?.length ? (
151
            {data.items?.length ? (
153
                data.items.map((question) => (
152
              data.items.map((question) => (
154
                  <QuestionCard
153
                <QuestionCard
155
                    key={question.uuid}
154
                  key={question.uuid}
156
                    onEdit={editQuestion}
155
                  onEdit={editQuestion}
157
                    onDelete={deleteQuestion}
-
 
158
                    {...question}
-
 
159
                  />
-
 
160
                ))
-
 
161
              ) : (
-
 
162
                <EmptySection
156
                  onDelete={deleteQuestion}
163
                  message={labels.error_no_record_matched_your_query}
157
                  {...question}
-
 
158
                />
-
 
159
              ))
-
 
160
            ) : (
-
 
161
              <EmptySection
-
 
162
                message={labels.error_no_record_matched_your_query}
164
                />
163
              />
165
              )}
164
            )}
166
            </QuestionsGrid>
165
          </QuestionsGrid>
167
 
166
 
168
            <PaginationComponent
167
          <PaginationComponent
169
              onChangePage={(page) => setParams('page', page)}
168
            onChangePage={(page) => setParams('page', page)}
170
              currentActivePage={data.page}
169
            currentActivePage={data.page}
171
              pages={data.total_pages}
170
            pages={data.total_pages}
172
              isRow
-
 
173
            />
171
            isRow
174
          </Grid>
172
          />
Línea 175... Línea 173...
175
        </Grid>
173
        </Grid>
176
      </Container>
174
      </Grid>
177
 
175
 
178
      <QuestionModal
176
      <QuestionModal