@selfcommunity/react-ui 0.10.2-courses.162 → 0.10.2-courses.163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/EditCourse/Requests.js +9 -9
- package/lib/cjs/components/EditCourse/Users.js +10 -7
- package/lib/cjs/shared/AddUsersButton/AddUsersButton.js +1 -1
- package/lib/cjs/shared/CourseUsersTable/ChangeUsersStatus.js +1 -1
- package/lib/cjs/shared/CourseUsersTable/CourseUsersTable.js +2 -2
- package/lib/esm/components/EditCourse/Requests.js +9 -9
- package/lib/esm/components/EditCourse/Users.js +10 -7
- package/lib/esm/shared/AddUsersButton/AddUsersButton.js +1 -1
- package/lib/esm/shared/CourseUsersTable/ChangeUsersStatus.js +1 -1
- package/lib/esm/shared/CourseUsersTable/CourseUsersTable.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -63,7 +63,14 @@ function Requests(props) {
|
|
|
63
63
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
}, [state.isLoadingNext, state.initialized, course, dispatch]);
|
|
66
|
+
}, [state.isLoadingNext, state.initialized, course, dispatch, endpointQueryParams]);
|
|
67
|
+
// HANDLERS
|
|
68
|
+
const handleRemoveUser = (0, react_1.useCallback)((_msg, user) => {
|
|
69
|
+
dispatch({
|
|
70
|
+
type: widget_1.actionWidgetTypes.SET_RESULTS,
|
|
71
|
+
payload: { count: state.results.length - 1, results: state.results.filter((result) => result.id !== user.id) }
|
|
72
|
+
});
|
|
73
|
+
}, [state.count, state.results, dispatch]);
|
|
67
74
|
// EFFECTS
|
|
68
75
|
(0, react_1.useEffect)(() => {
|
|
69
76
|
let _t;
|
|
@@ -79,14 +86,7 @@ function Requests(props) {
|
|
|
79
86
|
return () => {
|
|
80
87
|
updatedUsers.current && pubsub_js_1.default.unsubscribe(updatedUsers.current);
|
|
81
88
|
};
|
|
82
|
-
}, []);
|
|
83
|
-
// HANDLERS
|
|
84
|
-
const handleRemoveUser = (0, react_1.useCallback)((user) => {
|
|
85
|
-
dispatch({
|
|
86
|
-
type: widget_1.actionWidgetTypes.SET_RESULTS,
|
|
87
|
-
payload: { count: state.count - 1, results: state.results.filter((result) => result.id !== user.id) }
|
|
88
|
-
});
|
|
89
|
-
}, [dispatch]);
|
|
89
|
+
}, [handleRemoveUser]);
|
|
90
90
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.requests.title", defaultMessage: "ui.editCourse.tab.requests.title", values: { requestsNumber: state.results.length } }) })), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.usersStatusWrapper }, { children: (0, jsx_runtime_1.jsx)(Status_1.default, { course: course }) })), (0, jsx_runtime_1.jsx)(CourseUsersTable_1.default, { course: course, state: state, dispatch: dispatch, headerCells: headerCells, mode: "requests", emptyStatusTitle: "ui.courseUsersTable.empty.requests.title" })] }));
|
|
91
91
|
}
|
|
92
92
|
exports.default = (0, react_1.memo)(Requests);
|
|
@@ -70,7 +70,11 @@ function Users(props) {
|
|
|
70
70
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
}, [state.isLoadingNext, state.initialized, course, dispatch]);
|
|
73
|
+
}, [state.isLoadingNext, state.initialized, course, dispatch, endpointQueryParams]);
|
|
74
|
+
// HANDLERS
|
|
75
|
+
const handleAddUser = (0, react_1.useCallback)((_msg, user) => {
|
|
76
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_PREVIOUS_SUCCESS, payload: { count: state.count + 1, results: [user], initialized: true } });
|
|
77
|
+
}, [state.count, dispatch]);
|
|
74
78
|
// EFFECTS
|
|
75
79
|
(0, react_1.useEffect)(() => {
|
|
76
80
|
let _t;
|
|
@@ -86,18 +90,17 @@ function Users(props) {
|
|
|
86
90
|
return () => {
|
|
87
91
|
updatedUsers.current && pubsub_js_1.default.unsubscribe(updatedUsers.current);
|
|
88
92
|
};
|
|
89
|
-
}, []);
|
|
90
|
-
// HANDLERS
|
|
91
|
-
const handleAddUser = (0, react_1.useCallback)((user) => {
|
|
92
|
-
dispatch({ type: widget_1.actionWidgetTypes.LOAD_PREVIOUS_SUCCESS, payload: { count: state.count + 1, results: [user], initialized: true } });
|
|
93
|
-
}, [dispatch]);
|
|
93
|
+
}, [handleAddUser]);
|
|
94
94
|
const handleConfirm = (0, react_1.useCallback)((newUsers) => {
|
|
95
95
|
const data = {
|
|
96
96
|
joined: newUsers.map((user) => user.id)
|
|
97
97
|
};
|
|
98
98
|
api_services_1.CourseService.changeCourseUserRole(course.id, data)
|
|
99
99
|
.then(() => {
|
|
100
|
-
dispatch({
|
|
100
|
+
dispatch({
|
|
101
|
+
type: widget_1.actionWidgetTypes.LOAD_PREVIOUS_SUCCESS,
|
|
102
|
+
payload: { count: state.count + newUsers.length, results: newUsers, initialized: true }
|
|
103
|
+
});
|
|
101
104
|
})
|
|
102
105
|
.catch((error) => {
|
|
103
106
|
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
@@ -95,7 +95,7 @@ function AddUsersButton(inProps) {
|
|
|
95
95
|
const handleConfirm = (0, react_1.useCallback)(() => {
|
|
96
96
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(invited);
|
|
97
97
|
setInvited([]);
|
|
98
|
-
}, [invited]);
|
|
98
|
+
}, [invited, onConfirm]);
|
|
99
99
|
// HANDLERS AUTOCOMPLETE
|
|
100
100
|
const handleInputChange = (0, react_1.useCallback)((_, newValue, reason) => {
|
|
101
101
|
switch (reason) {
|
|
@@ -21,7 +21,7 @@ function ChangeUserStatus(props) {
|
|
|
21
21
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
22
22
|
// EFFECTS
|
|
23
23
|
(0, react_1.useEffect)(() => {
|
|
24
|
-
setValue(`ui.editCourse.tab.users.table.select.${user.join_status}`);
|
|
24
|
+
setValue(`ui.editCourse.tab.users.table.select.${user.join_status || 'joined'}`);
|
|
25
25
|
}, [user, setValue]);
|
|
26
26
|
// HANDLERS
|
|
27
27
|
const handleChange = (0, react_1.useCallback)((e) => {
|
|
@@ -52,7 +52,7 @@ function CourseUsersTable(inProps) {
|
|
|
52
52
|
// EFFECTS
|
|
53
53
|
(0, react_1.useEffect)(() => {
|
|
54
54
|
setUsers(state.results);
|
|
55
|
-
}, [state.results]);
|
|
55
|
+
}, [state.results, setUsers]);
|
|
56
56
|
// HANDLERS
|
|
57
57
|
const handleChange = (0, react_1.useCallback)((e) => {
|
|
58
58
|
const _value = e.target.value;
|
|
@@ -100,6 +100,6 @@ function CourseUsersTable(inProps) {
|
|
|
100
100
|
}
|
|
101
101
|
return ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: mode === 'dashboard' ? '20%' : '25%' }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: cell.id, defaultMessage: cell.id }) })) }), i));
|
|
102
102
|
}) }) }), (0, jsx_runtime_1.jsxs)(material_1.TableBody, { children: [users.length > 0 &&
|
|
103
|
-
users.map((user, i) => ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.avatarWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: user.username, src: user.avatar }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: user.username }))] })) }), mode === 'dashboard' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.progressWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.LinearProgress, { className: classes.progress, variant: "determinate", value: user.user_completion_rate }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: `${Math.round(user.user_completion_rate)}%` }))] })) })), mode === 'edit' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: user.join_status !== types_1.SCCourseJoinStatusType.CREATOR && scUserContext.user.id !== user.id ? ((0, jsx_runtime_1.jsx)(ChangeUsersStatus_1.default, { course: course, user: user })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.editCourse.tab.users.table.select.${user.join_status}`, defaultMessage: `ui.editCourse.tab.users.table.select.${user.join_status}` }) }))) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.joined_at).toLocaleDateString() })) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.last_active_at).toLocaleDateString() })) }), mode === 'dashboard' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(SeeProgressButton_1.default, { course: course, user: user }) })), mode === 'requests' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(RequestButton_1.default, { course: course, user: user }) }))] }, i))), state.isLoadingNext && (0, jsx_runtime_1.jsx)(RowSkeleton_1.default, { editMode: mode !== 'dashboard' })] })] }) }), users.length > 0 && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ size: "small", variant: "outlined", color: "inherit", loading: state.isLoadingNext, disabled: !state.next, className: classes.loadingButton, onClick: handleNext }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseUsersTable.btn.label", defaultMessage: "ui.courseUsersTable.btn.label" }) })) }))), users.length === 0 && value.length === 0 && (0, jsx_runtime_1.jsx)(EmptyStatus_1.default, { icon: "face", title: emptyStatusTitle, description: emptyStatusDescription })] }));
|
|
103
|
+
users.map((user, i) => ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.avatarWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: user.username, src: user.avatar }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: user.username }))] })) }), mode === 'dashboard' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.progressWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.LinearProgress, { className: classes.progress, variant: "determinate", value: user.user_completion_rate }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: `${Math.round(user.user_completion_rate)}%` }))] })) })), mode === 'edit' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: user.join_status !== types_1.SCCourseJoinStatusType.CREATOR && scUserContext.user.id !== user.id ? ((0, jsx_runtime_1.jsx)(ChangeUsersStatus_1.default, { course: course, user: user })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.editCourse.tab.users.table.select.${user.join_status}`, defaultMessage: `ui.editCourse.tab.users.table.select.${user.join_status}` }) }))) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.joined_at || new Date()).toLocaleDateString() })) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.last_active_at || new Date()).toLocaleDateString() })) }), mode === 'dashboard' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(SeeProgressButton_1.default, { course: course, user: user }) })), mode === 'requests' && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(RequestButton_1.default, { course: course, user: user }) }))] }, i))), state.isLoadingNext && (0, jsx_runtime_1.jsx)(RowSkeleton_1.default, { editMode: mode !== 'dashboard' })] })] }) }), users.length > 0 && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ size: "small", variant: "outlined", color: "inherit", loading: state.isLoadingNext, disabled: !state.next, className: classes.loadingButton, onClick: handleNext }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseUsersTable.btn.label", defaultMessage: "ui.courseUsersTable.btn.label" }) })) }))), users.length === 0 && value.length === 0 && (0, jsx_runtime_1.jsx)(EmptyStatus_1.default, { icon: "face", title: emptyStatusTitle, description: emptyStatusDescription })] }));
|
|
104
104
|
}
|
|
105
105
|
exports.default = (0, react_1.memo)(CourseUsersTable);
|
|
@@ -60,7 +60,14 @@ function Requests(props) {
|
|
|
60
60
|
Logger.error(SCOPE_SC_UI, error);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
}, [state.isLoadingNext, state.initialized, course, dispatch]);
|
|
63
|
+
}, [state.isLoadingNext, state.initialized, course, dispatch, endpointQueryParams]);
|
|
64
|
+
// HANDLERS
|
|
65
|
+
const handleRemoveUser = useCallback((_msg, user) => {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: actionWidgetTypes.SET_RESULTS,
|
|
68
|
+
payload: { count: state.results.length - 1, results: state.results.filter((result) => result.id !== user.id) }
|
|
69
|
+
});
|
|
70
|
+
}, [state.count, state.results, dispatch]);
|
|
64
71
|
// EFFECTS
|
|
65
72
|
useEffect(() => {
|
|
66
73
|
let _t;
|
|
@@ -76,14 +83,7 @@ function Requests(props) {
|
|
|
76
83
|
return () => {
|
|
77
84
|
updatedUsers.current && PubSub.unsubscribe(updatedUsers.current);
|
|
78
85
|
};
|
|
79
|
-
}, []);
|
|
80
|
-
// HANDLERS
|
|
81
|
-
const handleRemoveUser = useCallback((user) => {
|
|
82
|
-
dispatch({
|
|
83
|
-
type: actionWidgetTypes.SET_RESULTS,
|
|
84
|
-
payload: { count: state.count - 1, results: state.results.filter((result) => result.id !== user.id) }
|
|
85
|
-
});
|
|
86
|
-
}, [dispatch]);
|
|
86
|
+
}, [handleRemoveUser]);
|
|
87
87
|
return (_jsxs(Box, { children: [_jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.requests.title", defaultMessage: "ui.editCourse.tab.requests.title", values: { requestsNumber: state.results.length } }) })), _jsx(Stack, Object.assign({ className: classes.usersStatusWrapper }, { children: _jsx(Status, { course: course }) })), _jsx(CourseUsersTable, { course: course, state: state, dispatch: dispatch, headerCells: headerCells, mode: "requests", emptyStatusTitle: "ui.courseUsersTable.empty.requests.title" })] }));
|
|
88
88
|
}
|
|
89
89
|
export default memo(Requests);
|
|
@@ -67,7 +67,11 @@ function Users(props) {
|
|
|
67
67
|
Logger.error(SCOPE_SC_UI, error);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
}, [state.isLoadingNext, state.initialized, course, dispatch]);
|
|
70
|
+
}, [state.isLoadingNext, state.initialized, course, dispatch, endpointQueryParams]);
|
|
71
|
+
// HANDLERS
|
|
72
|
+
const handleAddUser = useCallback((_msg, user) => {
|
|
73
|
+
dispatch({ type: actionWidgetTypes.LOAD_PREVIOUS_SUCCESS, payload: { count: state.count + 1, results: [user], initialized: true } });
|
|
74
|
+
}, [state.count, dispatch]);
|
|
71
75
|
// EFFECTS
|
|
72
76
|
useEffect(() => {
|
|
73
77
|
let _t;
|
|
@@ -83,18 +87,17 @@ function Users(props) {
|
|
|
83
87
|
return () => {
|
|
84
88
|
updatedUsers.current && PubSub.unsubscribe(updatedUsers.current);
|
|
85
89
|
};
|
|
86
|
-
}, []);
|
|
87
|
-
// HANDLERS
|
|
88
|
-
const handleAddUser = useCallback((user) => {
|
|
89
|
-
dispatch({ type: actionWidgetTypes.LOAD_PREVIOUS_SUCCESS, payload: { count: state.count + 1, results: [user], initialized: true } });
|
|
90
|
-
}, [dispatch]);
|
|
90
|
+
}, [handleAddUser]);
|
|
91
91
|
const handleConfirm = useCallback((newUsers) => {
|
|
92
92
|
const data = {
|
|
93
93
|
joined: newUsers.map((user) => user.id)
|
|
94
94
|
};
|
|
95
95
|
CourseService.changeCourseUserRole(course.id, data)
|
|
96
96
|
.then(() => {
|
|
97
|
-
dispatch({
|
|
97
|
+
dispatch({
|
|
98
|
+
type: actionWidgetTypes.LOAD_PREVIOUS_SUCCESS,
|
|
99
|
+
payload: { count: state.count + newUsers.length, results: newUsers, initialized: true }
|
|
100
|
+
});
|
|
98
101
|
})
|
|
99
102
|
.catch((error) => {
|
|
100
103
|
dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
@@ -93,7 +93,7 @@ function AddUsersButton(inProps) {
|
|
|
93
93
|
const handleConfirm = useCallback(() => {
|
|
94
94
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(invited);
|
|
95
95
|
setInvited([]);
|
|
96
|
-
}, [invited]);
|
|
96
|
+
}, [invited, onConfirm]);
|
|
97
97
|
// HANDLERS AUTOCOMPLETE
|
|
98
98
|
const handleInputChange = useCallback((_, newValue, reason) => {
|
|
99
99
|
switch (reason) {
|
|
@@ -19,7 +19,7 @@ function ChangeUserStatus(props) {
|
|
|
19
19
|
const { enqueueSnackbar } = useSnackbar();
|
|
20
20
|
// EFFECTS
|
|
21
21
|
useEffect(() => {
|
|
22
|
-
setValue(`ui.editCourse.tab.users.table.select.${user.join_status}`);
|
|
22
|
+
setValue(`ui.editCourse.tab.users.table.select.${user.join_status || 'joined'}`);
|
|
23
23
|
}, [user, setValue]);
|
|
24
24
|
// HANDLERS
|
|
25
25
|
const handleChange = useCallback((e) => {
|
|
@@ -49,7 +49,7 @@ function CourseUsersTable(inProps) {
|
|
|
49
49
|
// EFFECTS
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
setUsers(state.results);
|
|
52
|
-
}, [state.results]);
|
|
52
|
+
}, [state.results, setUsers]);
|
|
53
53
|
// HANDLERS
|
|
54
54
|
const handleChange = useCallback((e) => {
|
|
55
55
|
const _value = e.target.value;
|
|
@@ -97,6 +97,6 @@ function CourseUsersTable(inProps) {
|
|
|
97
97
|
}
|
|
98
98
|
return (_jsx(TableCell, Object.assign({ width: mode === 'dashboard' ? '20%' : '25%' }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: cell.id, defaultMessage: cell.id }) })) }), i));
|
|
99
99
|
}) }) }), _jsxs(TableBody, { children: [users.length > 0 &&
|
|
100
|
-
users.map((user, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsxs(Stack, Object.assign({ className: classes.avatarWrapper }, { children: [_jsx(Avatar, { alt: user.username, src: user.avatar }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: user.username }))] })) }), mode === 'dashboard' && (_jsx(TableCell, { children: _jsxs(Stack, Object.assign({ className: classes.progressWrapper }, { children: [_jsx(LinearProgress, { className: classes.progress, variant: "determinate", value: user.user_completion_rate }), _jsx(Typography, Object.assign({ variant: "body1" }, { children: `${Math.round(user.user_completion_rate)}%` }))] })) })), mode === 'edit' && (_jsx(TableCell, { children: user.join_status !== SCCourseJoinStatusType.CREATOR && scUserContext.user.id !== user.id ? (_jsx(ChangeUserStatus, { course: course, user: user })) : (_jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: `ui.editCourse.tab.users.table.select.${user.join_status}`, defaultMessage: `ui.editCourse.tab.users.table.select.${user.join_status}` }) }))) })), _jsx(TableCell, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.joined_at).toLocaleDateString() })) }), _jsx(TableCell, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.last_active_at).toLocaleDateString() })) }), mode === 'dashboard' && (_jsx(TableCell, { children: _jsx(SeeProgressButton, { course: course, user: user }) })), mode === 'requests' && (_jsx(TableCell, { children: _jsx(RequestButton, { course: course, user: user }) }))] }, i))), state.isLoadingNext && _jsx(RowSkeleton, { editMode: mode !== 'dashboard' })] })] }) }), users.length > 0 && (_jsx(LoadingButton, Object.assign({ size: "small", variant: "outlined", color: "inherit", loading: state.isLoadingNext, disabled: !state.next, className: classes.loadingButton, onClick: handleNext }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.courseUsersTable.btn.label", defaultMessage: "ui.courseUsersTable.btn.label" }) })) }))), users.length === 0 && value.length === 0 && _jsx(EmptyStatus, { icon: "face", title: emptyStatusTitle, description: emptyStatusDescription })] }));
|
|
100
|
+
users.map((user, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsxs(Stack, Object.assign({ className: classes.avatarWrapper }, { children: [_jsx(Avatar, { alt: user.username, src: user.avatar }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: user.username }))] })) }), mode === 'dashboard' && (_jsx(TableCell, { children: _jsxs(Stack, Object.assign({ className: classes.progressWrapper }, { children: [_jsx(LinearProgress, { className: classes.progress, variant: "determinate", value: user.user_completion_rate }), _jsx(Typography, Object.assign({ variant: "body1" }, { children: `${Math.round(user.user_completion_rate)}%` }))] })) })), mode === 'edit' && (_jsx(TableCell, { children: user.join_status !== SCCourseJoinStatusType.CREATOR && scUserContext.user.id !== user.id ? (_jsx(ChangeUserStatus, { course: course, user: user })) : (_jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: `ui.editCourse.tab.users.table.select.${user.join_status}`, defaultMessage: `ui.editCourse.tab.users.table.select.${user.join_status}` }) }))) })), _jsx(TableCell, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.joined_at || new Date()).toLocaleDateString() })) }), _jsx(TableCell, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: new Date(mode === 'requests' ? user.date_joined : user.last_active_at || new Date()).toLocaleDateString() })) }), mode === 'dashboard' && (_jsx(TableCell, { children: _jsx(SeeProgressButton, { course: course, user: user }) })), mode === 'requests' && (_jsx(TableCell, { children: _jsx(RequestButton, { course: course, user: user }) }))] }, i))), state.isLoadingNext && _jsx(RowSkeleton, { editMode: mode !== 'dashboard' })] })] }) }), users.length > 0 && (_jsx(LoadingButton, Object.assign({ size: "small", variant: "outlined", color: "inherit", loading: state.isLoadingNext, disabled: !state.next, className: classes.loadingButton, onClick: handleNext }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.courseUsersTable.btn.label", defaultMessage: "ui.courseUsersTable.btn.label" }) })) }))), users.length === 0 && value.length === 0 && _jsx(EmptyStatus, { icon: "face", title: emptyStatusTitle, description: emptyStatusDescription })] }));
|
|
101
101
|
}
|
|
102
102
|
export default memo(CourseUsersTable);
|