pl-fe: migrate reports management
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -3,8 +3,8 @@ import { useIntl, defineMessages } from 'react-intl';
|
||||
import { useRouteMatch } from 'react-router-dom';
|
||||
|
||||
import Tabs from 'pl-fe/components/ui/tabs';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { usePendingUsersCount } from 'pl-fe/queries/admin/use-accounts';
|
||||
import { usePendingReportsCount } from 'pl-fe/queries/admin/use-reports';
|
||||
|
||||
const messages = defineMessages({
|
||||
dashboard: { id: 'admin_nav.dashboard', defaultMessage: 'Dashboard' },
|
||||
@ -17,7 +17,7 @@ const AdminTabs: React.FC = () => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
const { data: awaitingApprovalCount } = usePendingUsersCount();
|
||||
const reportsCount = useAppSelector(state => state.admin.openReports.length);
|
||||
const { data: pendingReportsCount = 0 } = usePendingReportsCount();
|
||||
|
||||
const tabs = [{
|
||||
name: '/pl-fe/admin',
|
||||
@ -27,7 +27,7 @@ const AdminTabs: React.FC = () => {
|
||||
name: '/pl-fe/admin/reports',
|
||||
text: intl.formatMessage(messages.reports),
|
||||
to: '/pl-fe/admin/reports',
|
||||
count: reportsCount,
|
||||
count: pendingReportsCount,
|
||||
}, {
|
||||
name: '/pl-fe/admin/approval',
|
||||
text: intl.formatMessage(messages.waitlist),
|
||||
|
||||
@ -2,7 +2,6 @@ import React, { useCallback, useState } from 'react';
|
||||
import { useIntl, FormattedMessage, defineMessages } from 'react-intl';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { closeReport } from 'pl-fe/actions/admin';
|
||||
import { deactivateUserModal, deleteUserModal } from 'pl-fe/actions/moderation';
|
||||
import DropdownMenu from 'pl-fe/components/dropdown-menu';
|
||||
import HoverAccountWrapper from 'pl-fe/components/hover-account-wrapper';
|
||||
@ -14,6 +13,7 @@ import Stack from 'pl-fe/components/ui/stack';
|
||||
import Text from 'pl-fe/components/ui/text';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useReport, useResolveReport } from 'pl-fe/queries/admin/use-reports';
|
||||
import { makeGetReport } from 'pl-fe/selectors';
|
||||
import toast from 'pl-fe/toast';
|
||||
|
||||
@ -33,9 +33,12 @@ const Report: React.FC<IReport> = ({ id }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const { data: minifiedReport } = useReport(id);
|
||||
const { mutate: resolveReport } = useResolveReport(id);
|
||||
|
||||
const getReport = useCallback(makeGetReport(), []);
|
||||
|
||||
const report = useAppSelector((state) => getReport(state, id));
|
||||
const report = useAppSelector((state) => getReport(state, minifiedReport));
|
||||
|
||||
const [accordionExpanded, setAccordionExpanded] = useState(false);
|
||||
|
||||
@ -56,10 +59,12 @@ const Report: React.FC<IReport> = ({ id }) => {
|
||||
}];
|
||||
|
||||
const handleCloseReport = () => {
|
||||
dispatch(closeReport(report.id)).then(() => {
|
||||
const message = intl.formatMessage(messages.reportClosed, { name: targetAccount.username as string });
|
||||
toast.success(message);
|
||||
}).catch(() => {});
|
||||
resolveReport(undefined, {
|
||||
onSuccess: () => {
|
||||
const message = intl.formatMessage(messages.reportClosed, { name: targetAccount.username as string });
|
||||
toast.success(message);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleDeactivateUser = () => {
|
||||
|
||||
Reference in New Issue
Block a user