Fakultas Ilmu Komputer UI

NotificationPage.jsx 1.83 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
60
61
62
  console.log('Notifikasi');
  Storage.set('menu-active-state', 'Notifikasi');
}

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

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

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

   })
 }

 
63

MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
64
  render() {
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
65
    var id=-1
66
    return (
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
67
68
      <div className="notificationPage">
        <Segment className="notifikasi">
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
69
70
71
72
73
74
75
76
77
78
79
80
          {
            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
81
          />
RAMA WIDRAGAMA PUTRA's avatar
RAMA WIDRAGAMA PUTRA committed
82
83
84
85
            )}
            
          )}
          
MADE WIRA DHANAR SANTIKA's avatar
MADE WIRA DHANAR SANTIKA committed
86
87
        </Segment>
      </div>
88
    );
89
90
  }
}