Fakultas Ilmu Komputer UI

NotificationPage.jsx 1.75 KB
Newer Older
1
import React from 'react';
2
import PropTypes from 'prop-types';
3
4
import { Segment } from 'semantic-ui-react';
import Notification from './components/Notification';
5
import Storage from './lib/Storage';
6
7
8

export default class NotificationPage extends React.Component {
  static propTypes = {
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
9
    user: PropTypes.object,
10
11
12
13
  };

  constructor(props) {
    super(props);
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    this.state = {
  
    list : [
      {
        title: "Your Application Has Been Rejected",
        text: "Tutuplapak has rejected your applications",
        timestamp: "2019-10-10T13:00:00",

      },
      {
        title: "Your Application Has Been Accepted",
        text: "Tutuplapak has rejected your applications",
        timestamp: "2019-12-10T13:00:00",

      },
      {
        title: "Your Application Has Been Responded",
        text: "Tutuplapak has rejected your applications",
        timestamp: "2019-11-10T13:00:00",

      },
    ]

37

38
  }
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  Storage.set('menu-active-state', 'Notifikasi');
}

// componentDidUpdate(prevprops,prevstate){
//   this.updateList();
// }

//  updateList = () => {
   
//  }

 onClickDismiss = (index) => {
  var array = [...this.state.list];
  array.splice(index, 1);
   this.setState({
    list : array

   })
 }

 
60

MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
61
  render() {
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
62
    var id=-1
63
    return (
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
64
65
      <div className="notificationPage">
        <Segment className="notifikasi">
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
66
67
68
69
70
71
72
73
74
75
76
77
          {
            this.state.list.map(item=>{
              id=id+1
              console.log(id)
            return (
            <Notification
            id={id}
            title={item.title}
            text={item.text}
            timestamp={item.timestamp}
            dismiss = {this.onClickDismiss}
          
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
78
          />
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
79
80
81
82
            )}
            
          )}
          
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
83
84
        </Segment>
      </div>
85
    );
86
87
  }
}