Skip to content

Commit de89298

Browse files
committed
Created Mutation for Updating Verification
- `useUpdateUserVerification` mutation to update a user's verification status used in `BannedPendingRow.jsx` - updated `admin/users#user_params` to allow for the verified status to be updated
1 parent 123f02a commit de89298

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

app/controllers/api/v1/admin/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def banned
9999
private
100100

101101
def user_params
102-
params.require(:user).permit(:status)
102+
params.require(:user).permit(:status, :verified)
103103
end
104104
end
105105
end

app/javascript/components/admin/manage_users/BannedPendingRow.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import Avatar from '../../users/user/Avatar';
3030
import useUpdateUserStatus from '../../../hooks/mutations/admin/manage_users/useUpdateUserStatus';
3131
import { localizeDateTimeString } from '../../../helpers/DateTimeHelper';
3232
import { useAuth } from '../../../contexts/auth/AuthProvider';
33+
import useUpdateUserVerification from "../../../hooks/mutations/admin/manage_users/useUpdateUserVerification";
3334

3435
export default function BannedPendingRow({ user, tableType }) {
3536
const { t } = useTranslation();
3637
const updateUserStatus = useUpdateUserStatus();
38+
const updateUserVerification = useUpdateUserVerification();
3739
const currentUser = useAuth();
3840
const localizedTime = localizeDateTimeString(user?.created_at, currentUser?.language);
3941

@@ -62,7 +64,7 @@ export default function BannedPendingRow({ user, tableType }) {
6264
}
6365
if (tableType === 'unverified') {
6466
return (
65-
<Dropdown.Item onClick={() => updateUserStatus.mutate({ id: user.id, verified: true })}>
67+
<Dropdown.Item onClick={() => updateUserVerification.mutate({ id: user.id, verified: true })}>
6668
<CheckIcon className="hi-s me-2" />
6769
{t('admin.manage_users.verify')}
6870
</Dropdown.Item>

app/javascript/components/admin/manage_users/ManageUsers.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function ManageUsers() {
100100
<Tab eventKey="active" title={t('admin.manage_users.active')}>
101101
<VerifiedUsers searchInput={searchInput} />
102102
</Tab>
103-
<Tab eventKey="unverified" title="Test Tab">
103+
<Tab eventKey="unverified" title={t('admin.manage_users.unverified')}>
104104
<UnverifiedUsers searchInput={searchInput} />
105105
</Tab>
106106
{registrationMethod === 'approval'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2+
//
3+
// Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
4+
//
5+
// This program is free software; you can redistribute it and/or modify it under the
6+
// terms of the GNU Lesser General Public License as published by the Free Software
7+
// Foundation; either version 3.0 of the License, or (at your option) any later
8+
// version.
9+
//
10+
// Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
11+
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12+
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License along
15+
// with Greenlight; if not, see <http://www.gnu.org/licenses/>.
16+
17+
import { useMutation, useQueryClient } from 'react-query';
18+
import { toast } from 'react-toastify';
19+
import { useTranslation } from 'react-i18next';
20+
import axios from '../../../../helpers/Axios';
21+
22+
export default function useUpdateUserVerification() {
23+
const { t } = useTranslation();
24+
const queryClient = useQueryClient();
25+
26+
return useMutation(
27+
(data) => axios.patch(`/admin/users/${data.id}.json`, { user: { verified: data.verified } }),
28+
{
29+
onSuccess: () => {
30+
queryClient.invalidateQueries(['getPendingUsers']);
31+
queryClient.invalidateQueries(['getBannedUsers']);
32+
queryClient.invalidateQueries(['getAdminUsers']);
33+
34+
toast.success(t('toast.success.user.user_updated'));
35+
},
36+
onError: () => {
37+
toast.error(t('toast.error.problem_completing_action'));
38+
},
39+
},
40+
);
41+
}

0 commit comments

Comments
 (0)