11
22import React , { Component } from 'react' ;
3+ import { Button } from 'react-bootstrap' ;
34
45import * as api from '../../api' ;
56import './Activity.css' ;
@@ -8,50 +9,84 @@ export default class Activity extends Component {
89 constructor ( props ) {
910 super ( props ) ;
1011 this . state = {
12+ activityId : - 1 ,
13+ activityType : '' ,
14+ problemType : '' ,
15+ editActivity : false ,
1116 showContent : false
1217 }
1318 }
19+
20+ editActivity ( ) {
21+ console . log ( "Activity Id:" , this . state . activityId , "Activity Type:" , this . state . activityType ) ;
22+ console . log ( "Content:" , this . props . content . props ) ;
23+ }
1424
1525 render ( ) {
26+ let isAdmin = this . props . User . info . role === 1 ;
27+ let displayEdit = ! isAdmin ? { display : "none" } : { } ;
28+
1629 return (
17- < div className = "act-wrapper" >
18- < div className = "act-bar-wrapper"
19- onClick = { ( ) => {
20- /* If this is a video, update progress */
21- if ( this . props . type === 'video' && ! this . state . showContent && this . props . userIsEnrolled ) {
22- let body = {
23- activityId : this . props . activity . id ,
24- activityType : this . props . activity . activityType ,
25- grade : 100
26- } ;
27- console . log ( 'body:' , body ) ;
28- api . modifyUserProgress ( this . props . User . info . id , body ) ;
29- }
30- this . setState ( { showContent : ! this . state . showContent } ) ;
31- } } >
32-
33- < div className = "act-icon" >
34- { this . props . type === 'video' && < i className = "fas fa-play" > </ i > }
35- { this . props . type === 'problems' && < i className = "fas fa-pencil-alt" > </ i > }
36- { this . props . type === 'form' && < i className = "fas fa-file" > </ i > }
37- </ div >
30+ < div >
31+ < div className = "act-wrapper" >
32+
33+ < div className = "act-bar-wrapper"
34+ onClick = { ( ) => {
35+ /* If this is a video, update progress */
36+ if ( this . props . type === 'video' && ! this . state . showContent && this . props . userIsEnrolled ) {
37+ let body = {
38+ activityId : this . props . activity . id ,
39+ activityType : this . props . activity . activityType ,
40+ grade : 100
41+ } ;
42+ console . log ( 'body:' , body ) ;
43+ api . modifyUserProgress ( this . props . User . info . id , body ) ;
44+ }
45+ this . setState ( { showContent : ! this . state . showContent } ) ;
46+ } } >
3847
39- < div className = { 'act-main' + ( this . props . done ? ' done' : '' ) } >
48+ < div className = "act-icon" >
49+ { this . props . type === 'video' && < i className = "fas fa-play" > </ i > }
50+ { this . props . type === 'problems' && < i className = "fas fa-pencil-alt" > </ i > }
51+ { this . props . type === 'form' && < i className = "fas fa-file" > </ i > }
52+ </ div >
4053
41- < div className = " act-title" > { this . props . title } </ div >
54+ < div className = { ' act-main' + ( this . props . done ? ' done' : '' ) } >
4255
43- < div className = "act-right" >
44- { this . props . right }
45- </ div >
56+ < div className = "act-title" > { this . props . title } </ div >
57+
58+ < div className = "act-right" >
59+ { this . props . right }
60+
61+
62+ </ div >
4663
64+ </ div >
65+
4766 </ div >
48- </ div >
4967
68+
69+
70+ < Button style = { displayEdit } className = "activity-edit-icon" onClick = { ( ) => {
71+ this . setState ( {
72+ editTopic : true ,
73+ activityId : this . props . activity . id ,
74+ activityType : this . props . type ,
75+ problemType : this . props . activity . type
76+ } ) ;
77+ this . editActivity ( ) ;
78+ } } >
79+ < i className = "fas fa-pencil-alt" > </ i >
80+ </ Button >
81+
82+
83+
84+ </ div >
85+
5086 {
5187 this . state . showContent &&
5288 < div className = "act-content" > { this . props . content } </ div >
5389 }
54-
5590 </ div >
5691 )
5792
0 commit comments