Skip to content

Commit 2b81fef

Browse files
committed
add tabs
show unpublished activities for staff and educators
1 parent 81a6269 commit 2b81fef

File tree

5 files changed

+219
-205
lines changed

5 files changed

+219
-205
lines changed

Diff for: zubhub_frontend/zubhub/public/locales/en/translation.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@
649649
},
650650
"activityLog": {
651651
"activity": "Activity Log",
652-
"addActivityLog": "Seems like there isn't any activity on your account yet! Get involved to see activity logs!"
652+
"addActivityLog": "Seems like there isn't any activity on your account yet! Get involved to see activity logs!"
653653
},
654654
"team": "Team",
655655
"createteam": "Create Team",
@@ -1075,6 +1075,12 @@
10751075
},
10761076

10771077
"activities": {
1078+
"title": "Activities",
1079+
"tabs": {
1080+
"published": "Published",
1081+
"unpublished": "Unpublished",
1082+
"ariaLabel": "Activity Tabs"
1083+
},
10781084
"LinkedProjects": "Linked Projects",
10791085
"errors": {
10801086
"emptyList": "No activities created yet !",
@@ -1191,4 +1197,4 @@
11911197
"buttonLabel": "Get Started"
11921198
}
11931199
}
1194-
}
1200+
}

Diff for: zubhub_frontend/zubhub/src/assets/js/styles/views/activities/activitiesStyles.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
const styles = theme => ({
2+
tabs: {
3+
margin: '2em 0',
4+
[theme.breakpoints.up('900')]: {
5+
paddingRight: '1em',
6+
},
7+
},
8+
tab: {
9+
textTransform: 'none',
10+
fontSize: '1.2em',
11+
fontWeight: 600,
12+
},
213
activityListContainer: {
314
padding: '4em 0',
415
width: '70%',
@@ -10,6 +21,9 @@ const styles = theme => ({
1021
width: '95%',
1122
},
1223
},
24+
activitiesContainer: {
25+
marginTop: 0,
26+
},
1327
activityBoxContainer: {
1428
padding: '5vh 10px',
1529
position: 'relative',

Diff for: zubhub_frontend/zubhub/src/store/actions/activityActions.js

+93-119
Original file line numberDiff line numberDiff line change
@@ -2,181 +2,155 @@ import { toast } from 'react-toastify';
22

33
import API from '../../api/api';
44
import * as at from '../actionTypes';
5-
let ActivityAPI = new API();
65

7-
export const setActivities = activities => {
8-
return dispatch => {
9-
dispatch({
10-
type: at.SET_ACTIVITIES,
11-
payload: { all_activities: activities },
12-
});
13-
};
6+
const ActivityAPI = new API();
7+
8+
export const setActivities = activities => dispatch => {
9+
dispatch({
10+
type: at.SET_ACTIVITIES,
11+
payload: { all_activities: activities },
12+
});
1413
};
1514

16-
export const setActivity = activity => {
17-
return dispatch => {
18-
dispatch({
19-
type: at.SET_ACTIVITY,
20-
payload: { activity: activity },
21-
});
22-
};
15+
export const setActivity = activity => dispatch => {
16+
dispatch({
17+
type: at.SET_ACTIVITY,
18+
payload: { activity },
19+
});
2320
};
2421

2522
export const getMyActivities = ({ t, token }) => {
2623
console.log('getMyActivities', token);
27-
return async dispatch => {
28-
return ActivityAPI.getMyActivities(token)
24+
return async dispatch =>
25+
ActivityAPI.getMyActivities(token)
2926
.then(res => {
3027
console.log('result', res);
3128

3229
if (res.status >= 200 && res.status < 300) {
33-
let response = res.json();
30+
const response = res.json();
3431
response.then(all => {
3532
console.log('all', all);
3633
dispatch({
3734
type: at.SET_ACTIVITIES,
3835
payload: {
39-
all_activities: all,
36+
userActivities: all,
4037
},
4138
});
4239
});
40+
} else if (res.status === 403 && res.statusText === 'Forbidden') {
41+
toast.warning(t('activityDetails.activity.delete.dialog.forbidden'));
4342
} else {
44-
if (res.status === 403 && res.statusText === 'Forbidden') {
45-
toast.warning(
46-
t('activityDetails.activity.delete.dialog.forbidden'),
47-
);
48-
} else {
49-
toast.warning(t('activities.errors.dialog.serverError'));
50-
}
43+
toast.warning(t('activities.errors.dialog.serverError'));
5144
}
5245
})
53-
.catch(error => {
46+
.catch(() => {
5447
toast.warning(t('activities.errors.dialog.serverError'));
5548
});
56-
};
5749
};
5850

5951
export const getUnPublishedActivities = ({ t, token }) => {
6052
console.log('getUnPublishedActivities', token);
61-
return async dispatch => {
62-
return ActivityAPI.getUnPublishedActivities(token)
53+
return async dispatch =>
54+
ActivityAPI.getUnPublishedActivities(token)
6355
.then(res => {
6456
console.log('result', res);
6557

6658
if (res.status >= 200 && res.status < 300) {
67-
let response = res.json();
59+
const response = res.json();
6860
response.then(all => {
6961
console.log('all', all);
7062
dispatch({
7163
type: at.SET_ACTIVITIES,
7264
payload: {
73-
all_activities: all,
65+
unPublishedActivities: all,
7466
},
7567
});
7668
});
69+
} else if (res.status === 403 && res.statusText === 'Forbidden') {
70+
toast.warning(t('activityDetails.activity.delete.dialog.forbidden'));
7771
} else {
78-
if (res.status === 403 && res.statusText === 'Forbidden') {
79-
toast.warning(
80-
t('activityDetails.activity.delete.dialog.forbidden'),
81-
);
82-
} else {
83-
toast.warning(t('activities.errors.dialog.serverError'));
84-
}
72+
toast.warning(t('activities.errors.dialog.serverError'));
8573
}
8674
})
87-
.catch(error => {
75+
.catch(() => {
8876
toast.warning(t('activities.errors.dialog.serverError'));
8977
});
90-
};
9178
};
9279

93-
export const getActivities = t => {
94-
return async dispatch => {
95-
return ActivityAPI.getActivities()
96-
.then(res => {
97-
if (res.status >= 200 && res.status < 300) {
98-
let response = res.json();
99-
response.then(all => {
100-
dispatch({
101-
type: at.SET_ACTIVITIES,
102-
payload: {
103-
all_activities: all,
104-
},
105-
});
80+
export const getActivities = t => async dispatch =>
81+
ActivityAPI.getActivities()
82+
.then(res => {
83+
if (res.status >= 200 && res.status < 300) {
84+
const response = res.json();
85+
response.then(all => {
86+
dispatch({
87+
type: at.SET_ACTIVITIES,
88+
payload: {
89+
all_activities: all,
90+
},
10691
});
107-
} else {
108-
if (res.status === 403 && res.statusText === 'Forbidden') {
109-
toast.warning(
110-
t('activityDetails.activity.delete.dialog.forbidden'),
111-
);
112-
} else {
113-
toast.warning(t('activities.errors.dialog.serverError'));
114-
}
115-
}
116-
})
117-
.catch(error => {
118-
toast.warning(t('activities.errors.dialog.serverError'));
119-
});
120-
};
121-
};
122-
123-
export const activityCountView = args => {
124-
return async dispatch => {
125-
try {
126-
const result = await ActivityAPI.activityToggleSave(args);
127-
dispatch({
128-
type: at.SET_ACTIVITY,
129-
payload: { activity: result },
130-
});
131-
return { loading: false };
132-
} catch (error) {
133-
if (error.message.startsWith('Unexpected')) {
134-
toast.warning(args.t('projects.errors.unexpected'));
92+
});
93+
} else if (res.status === 403 && res.statusText === 'Forbidden') {
94+
toast.warning(t('activityDetails.activity.delete.dialog.forbidden'));
13595
} else {
136-
toast.warning(error.message);
96+
toast.warning(t('activities.errors.dialog.serverError'));
13797
}
138-
return { loading: false };
98+
})
99+
.catch(() => {
100+
toast.warning(t('activities.errors.dialog.serverError'));
101+
});
102+
103+
export const activityCountView = args => async dispatch => {
104+
try {
105+
const result = await ActivityAPI.activityToggleSave(args);
106+
dispatch({
107+
type: at.SET_ACTIVITY,
108+
payload: { activity: result },
109+
});
110+
return { loading: false };
111+
} catch (error) {
112+
if (error.message.startsWith('Unexpected')) {
113+
toast.warning(args.t('projects.errors.unexpected'));
114+
} else {
115+
toast.warning(error.message);
139116
}
140-
};
117+
return { loading: false };
118+
}
141119
};
142120

143-
export const activityToggleSave = args => {
144-
return async dispatch => {
145-
try {
146-
const result = await ActivityAPI.activityToggleSave(args);
147-
dispatch({
148-
type: at.SET_ACTIVITY,
149-
payload: { activity: result },
150-
});
151-
return { loading: false };
152-
} catch (error) {
153-
if (error.message.startsWith('Unexpected')) {
154-
toast.warning(args.t('projects.errors.unexpected'));
155-
} else {
156-
toast.warning(error.message);
157-
}
158-
return { loading: false };
121+
export const activityToggleSave = args => async dispatch => {
122+
try {
123+
const result = await ActivityAPI.activityToggleSave(args);
124+
dispatch({
125+
type: at.SET_ACTIVITY,
126+
payload: { activity: result },
127+
});
128+
return { loading: false };
129+
} catch (error) {
130+
if (error.message.startsWith('Unexpected')) {
131+
toast.warning(args.t('projects.errors.unexpected'));
132+
} else {
133+
toast.warning(error.message);
159134
}
160-
};
135+
return { loading: false };
136+
}
161137
};
162138

163-
export const activityTogglePublish = args => {
164-
return async dispatch => {
165-
try {
166-
const result = await ActivityAPI.activityTogglePublish(args);
139+
export const activityTogglePublish = args => async dispatch => {
140+
try {
141+
const result = await ActivityAPI.activityTogglePublish(args);
167142

168-
dispatch({
169-
type: at.SET_ACTIVITY,
170-
payload: { activity: result },
171-
});
172-
return result;
173-
} catch (error) {
174-
if (error.message.startsWith('Unexpected')) {
175-
toast.warning(args.t('projects.errors.unexpected'));
176-
} else {
177-
toast.warning(error.message);
178-
}
179-
return { error: error };
143+
dispatch({
144+
type: at.SET_ACTIVITY,
145+
payload: { activity: result },
146+
});
147+
return result;
148+
} catch (error) {
149+
if (error.message.startsWith('Unexpected')) {
150+
toast.warning(args.t('projects.errors.unexpected'));
151+
} else {
152+
toast.warning(error.message);
180153
}
181-
};
154+
return { error };
155+
}
182156
};

Diff for: zubhub_frontend/zubhub/src/store/reducers/activityReducer.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as at from '../actionTypes';
2+
23
const default_state = {
34
all_activities: [],
45
published: [],
56
unPublishedActivities: [],
67
selectedActivity: {},
8+
userActivities: [],
79
};
810
const activities = (state = default_state, action) => {
911
switch (action.type) {

0 commit comments

Comments
 (0)