Browse Source

[ADD] user information in requests list

Gogs 7 years ago
parent
commit
dd2d0e3a62
2 changed files with 13 additions and 5 deletions
  1. 4 2
      src/components/pages/RequestsList.js
  2. 9 3
      src/reducers/notification.js

+ 4 - 2
src/components/pages/RequestsList.js

@@ -29,17 +29,19 @@ class RequestsList extends Component {
                     <Table>
                         <TableHead>
                             <TableRow>
+                                <TableCell>Fecha</TableCell>
                                 <TableCell>Nombre</TableCell>
+                                <TableCell>Usuario</TableCell>
                                 <TableCell>Estado</TableCell>
-                                <TableCell>Fecha</TableCell>
                             </TableRow>
                         </TableHead>
                         <TableBody>
                             {this.props.data.map(item => 
                                 <TableRow key={item.id}>
+                                    <TableCell>{item.create_at}</TableCell>
                                     <TableCell>{item.name}</TableCell>
+                                    <TableCell>{item.user ? item.user.username : 'Anónimo'}</TableCell>
                                     <TableCell>{item.status[1]}</TableCell>
-                                    <TableCell>{item.create_at}</TableCell>
                                 </TableRow>
                             )}
                         </TableBody>

+ 9 - 3
src/reducers/notification.js

@@ -27,9 +27,10 @@ const hideNotification = () => {
  * 
  */
 const notificationVisibilityReducer = createReducer(false, {
+    'SHOW_NOTIFICATION': showNotification,
+    'HIDE_NOTIFICATION': hideNotification,
     'LOGIN_FAILURE': showNotification,
     'CHECK_TOKEN_FAILURE': hideNotification,
-    'HIDE_NOTIFICATION': hideNotification,
     'REQUEST_KO': showNotification
 })
 
@@ -39,6 +40,10 @@ const notificationVisibilityReducer = createReducer(false, {
  * @param {*} action 
  */
 const setNotificationMessage = (message, action) => {
+    if (action.type === 'SHOW_NOTIFICATION') {
+        return action.payload.message
+    }
+
     if (action.type === 'LOGIN_FAILURE') {
         return 'Fallo al autenticar el usuario'
     }
@@ -48,7 +53,7 @@ const setNotificationMessage = (message, action) => {
     }
 
     if (action.type === 'REQUEST_KO' && action.payload !== 401) {
-        return 'No se pudo procesar su petición, intente nuevamente'
+        return 'No se pudo procesar su petición'
     }
 
     return null
@@ -58,9 +63,10 @@ const setNotificationMessage = (message, action) => {
  * 
  */
 const notificationMessageReducer = createReducer(null, {
+    'SHOW_NOTIFICATION': setNotificationMessage,
+    'HIDE_NOTIFICATION': setNotificationMessage,
     'LOGIN_FAILURE': setNotificationMessage,
     'CHECK_TOKEN_FAILURE': setNotificationMessage,
-    'HIDE_NOTIFICATION': setNotificationMessage,
     'REQUEST_KO': setNotificationMessage
 })