Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 5bedee9e

Přidáno uživatelem plundrichov před více než 4 roky(ů)

re #58 Rewrited client app to React #58 // yoso internal app // in progress #60 // fixed

Zobrazit rozdíly:

client/src/YourRequests.js
2 2
import './App.css';
3 3
import moment from 'moment';
4 4
import * as api_fetch from './api'
5
import convertVacationType from './convertVacationType'
5 6

  
6 7
function YourRequests(props) {
7 8

  
8 9
  useEffect( () => {
10
    if (props.currentUser !== undefined) {
9 11
      getData();
10
    }, []);
12
    }
13
  }, [props.currentUser]);
11 14

  
12 15
  // get requests from server
13 16
  const getData = async () => {
14 17

  
15
    api_fetch.loadYourRequests().then((data) => {
18
    api_fetch.loadYourRequests(props.currentUser).then((data) => {
16 19

  
17 20
      props.setUser(data.map(request => {
18
        const a = request.date;
19
        const b = [a.slice(0, 4), "-", a.slice(5, 7), "-", a.slice(8, 10)].join('');
21
        const convertedDate = request.date.split("/").join("-");
20 22

  
21 23
      return (
22 24
        {
23
          title: props.userName.name,
25
          title: props.currentUser.name,
24 26
          id: request.id,
25
          start: moment(b).format("D.M.YYYY"),
27
          start: moment(convertedDate).format("D.M.YYYY"),
26 28
          status: request.status = request.status.toLowerCase(),
27 29
          type: convertVacationType(request.type)
28 30
        }
......
33 35
    });
34 36
}
35 37

  
36
function convertVacationType(vacationType) {
37
  switch (vacationType) {
38
    case 'SICK_DAY' :
39
      return 'sickday';
40
    default:
41
      return 'holiday';
42
  }
43
}
44
  
45

  
46 38
  return (
47 39
    <div className="offs-request column">
48 40
      <h3>Your Requests</h3>

Také k dispozici: Unified diff