refactor: modified badge design for count

pull/3470/head
Brandon Cohen 1 year ago
parent 630ebe3f2a
commit b0160828be
No known key found for this signature in database
GPG Key ID: 3E759476348594C9

@ -9,8 +9,7 @@ interface BadgeProps {
| 'warning' | 'warning'
| 'success' | 'success'
| 'dark' | 'dark'
| 'light' | 'light';
| 'gradient';
className?: string; className?: string;
href?: string; href?: string;
children: React.ReactNode; children: React.ReactNode;
@ -67,11 +66,6 @@ const Badge = (
badgeStyle.push('hover:bg-gray-600'); badgeStyle.push('hover:bg-gray-600');
} }
break; break;
case 'gradient':
badgeStyle.push(
'border border-white bg-gradient-to-br from-indigo-600 to-purple-600 !text-indigo-100 shadow-black'
);
break;
default: default:
badgeStyle.push( badgeStyle.push(
'bg-indigo-500 bg-opacity-80 border border-indigo-500 !text-indigo-100' 'bg-indigo-500 bg-opacity-80 border border-indigo-500 !text-indigo-100'

@ -31,8 +31,7 @@ import { useRouter } from 'next/router';
import { useState } from 'react'; import { useState } from 'react';
import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl'; import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR, { mutate } from 'swr';
import useSWRMutation from 'swr/mutation';
import * as Yup from 'yup'; import * as Yup from 'yup';
const messages = defineMessages({ const messages = defineMessages({
@ -105,16 +104,6 @@ const IssueDetails = () => {
(opt) => opt.issueType === issueData?.issueType (opt) => opt.issueType === issueData?.issueType
); );
const fetchIssuesCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: issueTrigger } = useSWRMutation(
'/api/v1/issue/count',
fetchIssuesCount
);
if (!data && !error) { if (!data && !error) {
return <LoadingSpinner />; return <LoadingSpinner />;
} }
@ -155,7 +144,7 @@ const IssueDetails = () => {
autoDismiss: true, autoDismiss: true,
}); });
revalidateIssue(); revalidateIssue();
issueTrigger(); mutate('/api/v1/issue/count');
} catch (e) { } catch (e) {
addToast(intl.formatMessage(messages.toaststatusupdatefailed), { addToast(intl.formatMessage(messages.toaststatusupdatefailed), {
appearance: 'error', appearance: 'error',
@ -167,6 +156,7 @@ const IssueDetails = () => {
const deleteIssue = async () => { const deleteIssue = async () => {
try { try {
await axios.delete(`/api/v1/issue/${issueData.id}`); await axios.delete(`/api/v1/issue/${issueData.id}`);
mutate('/api/v1/issue/count');
addToast(intl.formatMessage(messages.toastissuedeleted), { addToast(intl.formatMessage(messages.toastissuedeleted), {
appearance: 'success', appearance: 'success',

@ -29,8 +29,8 @@ import { cloneElement, useRef, useState } from 'react';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
interface MobileMenuProps { interface MobileMenuProps {
pendingRequestsCount?: number; pendingRequestsCount: number;
openIssuesCount?: number; openIssuesCount: number;
} }
interface MenuLink { interface MenuLink {
@ -170,24 +170,20 @@ const MobileMenu = ({
})} })}
<span className="ml-2">{link.content}</span> <span className="ml-2">{link.content}</span>
{link.href === '/requests' && {link.href === '/requests' &&
pendingRequestsCount &&
pendingRequestsCount > 0 && pendingRequestsCount > 0 &&
hasPermission(Permission.MANAGE_REQUESTS) && ( hasPermission(Permission.MANAGE_REQUESTS) && (
<div className="ml-auto"> <div className="ml-auto">
<Badge badgeType="gradient"> <Badge className="rounded-md border-indigo-500 bg-gradient-to-br from-indigo-600 to-purple-600">
{pendingRequestsCount < 100 {pendingRequestsCount}
? pendingRequestsCount
: '99+'}
</Badge> </Badge>
</div> </div>
)} )}
{link.href === '/issues' && {link.href === '/issues' &&
openIssuesCount && openIssuesCount > 0 &&
openIssuesCount &&
hasPermission(Permission.MANAGE_ISSUES) && ( hasPermission(Permission.MANAGE_ISSUES) && (
<div className="ml-auto"> <div className="ml-auto">
<Badge badgeType="gradient"> <Badge className="rounded-md border-indigo-500 bg-gradient-to-br from-indigo-600 to-purple-600">
{openIssuesCount < 100 ? openIssuesCount : '99+'} {openIssuesCount}
</Badge> </Badge>
</div> </div>
)} )}
@ -217,14 +213,18 @@ const MobileMenu = ({
} }
)} )}
{link.href === '/requests' && {link.href === '/requests' &&
pendingRequestsCount && pendingRequestsCount > 0 &&
hasPermission(Permission.MANAGE_REQUESTS) && ( hasPermission(Permission.MANAGE_REQUESTS) && (
<div className="absolute left-3 bottom-2.5"> <div className="absolute left-3 bottom-3">
<span className="inline-flex whitespace-nowrap rounded-full border border-white bg-gradient-to-br from-indigo-600 to-purple-600 px-1 text-xs font-semibold !text-indigo-100 shadow-black"> <Badge
{pendingRequestsCount < 100 className={`bg-gradient-to-br ${
? pendingRequestsCount router.pathname.match(link.activeRegExp)
: '99+'} ? 'border-indigo-600 from-indigo-700 to-purple-700'
</span> : 'border-indigo-500 from-indigo-600 to-purple-600'
} !px-1 leading-none`}
>
{pendingRequestsCount}
</Badge>
</div> </div>
)} )}
</a> </a>

@ -31,8 +31,8 @@ export const menuMessages = defineMessages({
interface SidebarProps { interface SidebarProps {
open?: boolean; open?: boolean;
setClosed: () => void; setClosed: () => void;
pendingRequestsCount?: number; pendingRequestsCount: number;
openIssuesCount?: number; openIssuesCount: number;
} }
interface SidebarLinkProps { interface SidebarLinkProps {
@ -263,26 +263,36 @@ const Sidebar = ({
menuMessages[sidebarLink.messagesKey] menuMessages[sidebarLink.messagesKey]
)} )}
{sidebarLink.messagesKey === 'requests' && {sidebarLink.messagesKey === 'requests' &&
pendingRequestsCount &&
pendingRequestsCount > 0 && pendingRequestsCount > 0 &&
hasPermission(Permission.MANAGE_REQUESTS) && ( hasPermission(Permission.MANAGE_REQUESTS) && (
<div className="ml-auto"> <div className="ml-auto">
<Badge badgeType="gradient"> <Badge
{pendingRequestsCount < 100 className={`rounded-md bg-gradient-to-br ${
? pendingRequestsCount router.pathname.match(
: '99+'} sidebarLink.activeRegExp
)
? 'border-indigo-600 from-indigo-700 to-purple-700'
: 'border-indigo-500 from-indigo-600 to-purple-600'
}`}
>
{pendingRequestsCount}
</Badge> </Badge>
</div> </div>
)} )}
{sidebarLink.messagesKey === 'issues' && {sidebarLink.messagesKey === 'issues' &&
openIssuesCount &&
openIssuesCount > 0 && openIssuesCount > 0 &&
hasPermission(Permission.MANAGE_ISSUES) && ( hasPermission(Permission.MANAGE_ISSUES) && (
<div className="ml-auto"> <div className="ml-auto">
<Badge badgeType="gradient"> <Badge
{openIssuesCount < 100 className={`rounded-md bg-gradient-to-br ${
? openIssuesCount router.pathname.match(
: '99+'} sidebarLink.activeRegExp
)
? 'border-indigo-600 from-indigo-700 to-purple-700'
: 'border-indigo-500 from-indigo-600 to-purple-600'
}`}
>
{openIssuesCount}
</Badge> </Badge>
</div> </div>
)} )}

@ -58,22 +58,19 @@ const Layout = ({ children }: LayoutProps) => {
<div className="absolute top-0 h-64 w-full bg-gradient-to-bl from-gray-800 to-gray-900"> <div className="absolute top-0 h-64 w-full bg-gradient-to-bl from-gray-800 to-gray-900">
<div className="relative inset-0 h-full w-full bg-gradient-to-t from-gray-900 to-transparent" /> <div className="relative inset-0 h-full w-full bg-gradient-to-t from-gray-900 to-transparent" />
</div> </div>
{requestResponse && issueResponse && ( <Sidebar
<Sidebar open={isSidebarOpen}
open={isSidebarOpen} setClosed={() => setSidebarOpen(false)}
setClosed={() => setSidebarOpen(false)} pendingRequestsCount={requestResponse?.pending}
pendingRequestsCount={requestResponse.pending} openIssuesCount={issueResponse?.open}
openIssuesCount={issueResponse.open} />
<div className="sm:hidden">
<MobileMenu
pendingRequestsCount={requestResponse?.pending}
openIssuesCount={issueResponse?.open}
/> />
)} </div>
{requestResponse && issueResponse && (
<div className="sm:hidden">
<MobileMenu
pendingRequestsCount={requestResponse.pending}
openIssuesCount={issueResponse.open}
/>
</div>
)}
<div className="relative mb-16 flex w-0 min-w-0 flex-1 flex-col lg:ml-64"> <div className="relative mb-16 flex w-0 min-w-0 flex-1 flex-col lg:ml-64">
<PullToRefresh /> <PullToRefresh />
<div <div

@ -20,7 +20,7 @@ import axios from 'axios';
import Link from 'next/link'; import Link from 'next/link';
import { useState } from 'react'; import { useState } from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import useSWRMutation from 'swr/mutation'; import { mutate } from 'swr';
const messages = defineMessages({ const messages = defineMessages({
seasons: '{seasonCount, plural, one {Season} other {Seasons}}', seasons: '{seasonCount, plural, one {Season} other {Seasons}}',
@ -51,23 +51,13 @@ const RequestBlock = ({ request, onUpdate }: RequestBlockProps) => {
const { profile, rootFolder, server, languageProfile } = const { profile, rootFolder, server, languageProfile } =
useRequestOverride(request); useRequestOverride(request);
const fetchRequestsCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: requestTrigger } = useSWRMutation(
'/api/v1/request/count',
fetchRequestsCount
);
const updateRequest = async (type: 'approve' | 'decline'): Promise<void> => { const updateRequest = async (type: 'approve' | 'decline'): Promise<void> => {
setIsUpdating(true); setIsUpdating(true);
await axios.post(`/api/v1/request/${request.id}/${type}`); await axios.post(`/api/v1/request/${request.id}/${type}`);
if (onUpdate) { if (onUpdate) {
onUpdate(); onUpdate();
requestTrigger(); mutate('/api/v1/request/count');
} }
setIsUpdating(false); setIsUpdating(false);
}; };
@ -78,7 +68,7 @@ const RequestBlock = ({ request, onUpdate }: RequestBlockProps) => {
if (onUpdate) { if (onUpdate) {
onUpdate(); onUpdate();
requestTrigger(); mutate('/api/v1/request/count');
} }
setIsUpdating(false); setIsUpdating(false);

@ -15,7 +15,7 @@ import type { MediaRequest } from '@server/entity/MediaRequest';
import axios from 'axios'; import axios from 'axios';
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import useSWRMutation from 'swr/mutation'; import { mutate } from 'swr';
const messages = defineMessages({ const messages = defineMessages({
viewrequest: 'View Request', viewrequest: 'View Request',
@ -90,16 +90,6 @@ const RequestButton = ({
: undefined; : undefined;
}, [active4kRequests, user]); }, [active4kRequests, user]);
const fetchRequestsCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: requestTrigger } = useSWRMutation(
'/api/v1/request/count',
fetchRequestsCount
);
const modifyRequest = async ( const modifyRequest = async (
request: MediaRequest, request: MediaRequest,
type: 'approve' | 'decline' type: 'approve' | 'decline'
@ -108,7 +98,7 @@ const RequestButton = ({
if (response) { if (response) {
onUpdate(); onUpdate();
requestTrigger(); mutate('/api/v1/request/count');
} }
}; };
@ -127,7 +117,7 @@ const RequestButton = ({
); );
onUpdate(); onUpdate();
requestTrigger(); mutate('/api/v1/request/count');
}; };
const buttons: ButtonOption[] = []; const buttons: ButtonOption[] = [];

@ -27,7 +27,6 @@ import { useInView } from 'react-intersection-observer';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR, { mutate } from 'swr'; import useSWR, { mutate } from 'swr';
import useSWRMutation from 'swr/mutation';
const messages = defineMessages({ const messages = defineMessages({
seasons: '{seasonCount, plural, one {Season} other {Seasons}}', seasons: '{seasonCount, plural, one {Season} other {Seasons}}',
@ -76,6 +75,7 @@ const RequestCardError = ({ requestData }: RequestCardErrorProps) => {
await axios.delete(`/api/v1/media/${requestData?.media.id}`); await axios.delete(`/api/v1/media/${requestData?.media.id}`);
mutate('/api/v1/media?filter=allavailable&take=20&sort=mediaAdded'); mutate('/api/v1/media?filter=allavailable&take=20&sort=mediaAdded');
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
mutate('/api/v1/request/count');
}; };
return ( return (
@ -248,29 +248,19 @@ const RequestCard = ({ request, onTitleData }: RequestCardProps) => {
iOSPlexUrl4k: requestData?.media?.iOSPlexUrl4k, iOSPlexUrl4k: requestData?.media?.iOSPlexUrl4k,
}); });
const fetchRequestsCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: requestTrigger } = useSWRMutation(
'/api/v1/request/count',
fetchRequestsCount
);
const modifyRequest = async (type: 'approve' | 'decline') => { const modifyRequest = async (type: 'approve' | 'decline') => {
const response = await axios.post(`/api/v1/request/${request.id}/${type}`); const response = await axios.post(`/api/v1/request/${request.id}/${type}`);
if (response) { if (response) {
revalidate(); revalidate();
requestTrigger(); mutate('/api/v1/request/count');
} }
}; };
const deleteRequest = async () => { const deleteRequest = async () => {
await axios.delete(`/api/v1/request/${request.id}`); await axios.delete(`/api/v1/request/${request.id}`);
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
requestTrigger(); mutate('/api/v1/request/count');
}; };
const retryRequest = async () => { const retryRequest = async () => {

@ -25,8 +25,7 @@ import { useState } from 'react';
import { useInView } from 'react-intersection-observer'; import { useInView } from 'react-intersection-observer';
import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl'; import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR, { mutate } from 'swr';
import useSWRMutation from 'swr/mutation';
const messages = defineMessages({ const messages = defineMessages({
seasons: '{seasonCount, plural, one {Season} other {Seasons}}', seasons: '{seasonCount, plural, one {Season} other {Seasons}}',
@ -63,6 +62,7 @@ const RequestItemError = ({
const deleteRequest = async () => { const deleteRequest = async () => {
await axios.delete(`/api/v1/media/${requestData?.media.id}`); await axios.delete(`/api/v1/media/${requestData?.media.id}`);
revalidateList(); revalidateList();
mutate('/api/v1/request/count');
}; };
const { plexUrl, plexUrl4k } = useDeepLinks({ const { plexUrl, plexUrl4k } = useDeepLinks({
@ -307,22 +307,12 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => {
const [isRetrying, setRetrying] = useState(false); const [isRetrying, setRetrying] = useState(false);
const fetchRequestsCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: requestTrigger } = useSWRMutation(
'/api/v1/request/count',
fetchRequestsCount
);
const modifyRequest = async (type: 'approve' | 'decline') => { const modifyRequest = async (type: 'approve' | 'decline') => {
const response = await axios.post(`/api/v1/request/${request.id}/${type}`); const response = await axios.post(`/api/v1/request/${request.id}/${type}`);
if (response) { if (response) {
revalidate(); revalidate();
requestTrigger(); mutate('/api/v1/request/count');
} }
}; };
@ -330,7 +320,7 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => {
await axios.delete(`/api/v1/request/${request.id}`); await axios.delete(`/api/v1/request/${request.id}`);
revalidateList(); revalidateList();
requestTrigger(); mutate('/api/v1/request/count');
}; };
const retryRequest = async () => { const retryRequest = async () => {

@ -16,7 +16,7 @@ import axios from 'axios';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR, { mutate } from 'swr';
const messages = defineMessages({ const messages = defineMessages({
requestadmin: 'This request will be approved automatically.', requestadmin: 'This request will be approved automatically.',
@ -36,7 +36,6 @@ interface RequestModalProps extends React.HTMLAttributes<HTMLDivElement> {
onCancel?: () => void; onCancel?: () => void;
onComplete?: (newStatus: MediaStatus) => void; onComplete?: (newStatus: MediaStatus) => void;
onUpdating?: (isUpdating: boolean) => void; onUpdating?: (isUpdating: boolean) => void;
requestTrigger: () => void;
} }
const CollectionRequestModal = ({ const CollectionRequestModal = ({
@ -45,7 +44,6 @@ const CollectionRequestModal = ({
tmdbId, tmdbId,
onUpdating, onUpdating,
is4k = false, is4k = false,
requestTrigger,
}: RequestModalProps) => { }: RequestModalProps) => {
const [isUpdating, setIsUpdating] = useState(false); const [isUpdating, setIsUpdating] = useState(false);
const [requestOverrides, setRequestOverrides] = const [requestOverrides, setRequestOverrides] =
@ -213,7 +211,7 @@ const CollectionRequestModal = ({
? MediaStatus.UNKNOWN ? MediaStatus.UNKNOWN
: MediaStatus.PARTIALLY_AVAILABLE : MediaStatus.PARTIALLY_AVAILABLE
); );
requestTrigger(); mutate('/api/v1/request/count');
} }
addToast( addToast(
@ -242,7 +240,6 @@ const CollectionRequestModal = ({
intl, intl,
selectedParts, selectedParts,
is4k, is4k,
requestTrigger,
]); ]);
const hasAutoApprove = hasPermission( const hasAutoApprove = hasPermission(

@ -42,7 +42,6 @@ interface RequestModalProps extends React.HTMLAttributes<HTMLDivElement> {
onCancel?: () => void; onCancel?: () => void;
onComplete?: (newStatus: MediaStatus) => void; onComplete?: (newStatus: MediaStatus) => void;
onUpdating?: (isUpdating: boolean) => void; onUpdating?: (isUpdating: boolean) => void;
requestTrigger: () => void;
} }
const MovieRequestModal = ({ const MovieRequestModal = ({
@ -52,7 +51,6 @@ const MovieRequestModal = ({
onUpdating, onUpdating,
editRequest, editRequest,
is4k = false, is4k = false,
requestTrigger,
}: RequestModalProps) => { }: RequestModalProps) => {
const [isUpdating, setIsUpdating] = useState(false); const [isUpdating, setIsUpdating] = useState(false);
const [requestOverrides, setRequestOverrides] = const [requestOverrides, setRequestOverrides] =
@ -97,7 +95,7 @@ const MovieRequestModal = ({
...overrideParams, ...overrideParams,
}); });
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
requestTrigger(); mutate('/api/v1/request/count');
if (response.data) { if (response.data) {
if (onComplete) { if (onComplete) {
@ -137,7 +135,6 @@ const MovieRequestModal = ({
data?.id, data?.id,
data?.title, data?.title,
is4k, is4k,
requestTrigger,
onComplete, onComplete,
addToast, addToast,
intl, intl,
@ -152,7 +149,7 @@ const MovieRequestModal = ({
`/api/v1/request/${editRequest?.id}` `/api/v1/request/${editRequest?.id}`
); );
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
requestTrigger(); mutate('/api/v1/request/count');
if (response.status === 204) { if (response.status === 204) {
if (onComplete) { if (onComplete) {
@ -190,7 +187,7 @@ const MovieRequestModal = ({
await axios.post(`/api/v1/request/${editRequest?.id}/approve`); await axios.post(`/api/v1/request/${editRequest?.id}/approve`);
} }
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
requestTrigger(); mutate('/api/v1/request/count');
addToast( addToast(
<span> <span>

@ -56,7 +56,6 @@ interface RequestModalProps extends React.HTMLAttributes<HTMLDivElement> {
onCancel?: () => void; onCancel?: () => void;
onComplete?: (newStatus: MediaStatus) => void; onComplete?: (newStatus: MediaStatus) => void;
onUpdating?: (isUpdating: boolean) => void; onUpdating?: (isUpdating: boolean) => void;
requestTrigger: () => void;
is4k?: boolean; is4k?: boolean;
editRequest?: MediaRequest; editRequest?: MediaRequest;
} }
@ -68,7 +67,6 @@ const TvRequestModal = ({
onUpdating, onUpdating,
editRequest, editRequest,
is4k = false, is4k = false,
requestTrigger,
}: RequestModalProps) => { }: RequestModalProps) => {
const settings = useSettings(); const settings = useSettings();
const { addToast } = useToasts(); const { addToast } = useToasts();
@ -108,7 +106,7 @@ const TvRequestModal = ({
if (onUpdating) { if (onUpdating) {
onUpdating(true); onUpdating(true);
requestTrigger(); mutate('/api/v1/request/count');
} }
try { try {
@ -131,7 +129,7 @@ const TvRequestModal = ({
await axios.delete(`/api/v1/request/${editRequest.id}`); await axios.delete(`/api/v1/request/${editRequest.id}`);
} }
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0'); mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
requestTrigger(); mutate('/api/v1/request/count');
addToast( addToast(
<span> <span>
@ -180,7 +178,7 @@ const TvRequestModal = ({
if (onUpdating) { if (onUpdating) {
onUpdating(true); onUpdating(true);
requestTrigger(); mutate('/api/v1/request/count');
} }
try { try {

@ -4,8 +4,6 @@ import TvRequestModal from '@app/components/RequestModal/TvRequestModal';
import { Transition } from '@headlessui/react'; import { Transition } from '@headlessui/react';
import type { MediaStatus } from '@server/constants/media'; import type { MediaStatus } from '@server/constants/media';
import type { MediaRequest } from '@server/entity/MediaRequest'; import type { MediaRequest } from '@server/entity/MediaRequest';
import axios from 'axios';
import useSWRMutation from 'swr/mutation';
interface RequestModalProps { interface RequestModalProps {
show: boolean; show: boolean;
@ -28,16 +26,6 @@ const RequestModal = ({
onUpdating, onUpdating,
onCancel, onCancel,
}: RequestModalProps) => { }: RequestModalProps) => {
const fetchRequestsCount = async () => {
const response = await axios.get('/api/v1/request/count');
return response.data;
};
const { trigger: requestTrigger } = useSWRMutation(
'/api/v1/request/count',
fetchRequestsCount
);
return ( return (
<Transition <Transition
as="div" as="div"
@ -57,7 +45,6 @@ const RequestModal = ({
onUpdating={onUpdating} onUpdating={onUpdating}
is4k={is4k} is4k={is4k}
editRequest={editRequest} editRequest={editRequest}
requestTrigger={requestTrigger}
/> />
) : type === 'tv' ? ( ) : type === 'tv' ? (
<TvRequestModal <TvRequestModal
@ -67,7 +54,6 @@ const RequestModal = ({
onUpdating={onUpdating} onUpdating={onUpdating}
is4k={is4k} is4k={is4k}
editRequest={editRequest} editRequest={editRequest}
requestTrigger={requestTrigger}
/> />
) : ( ) : (
<CollectionRequestModal <CollectionRequestModal
@ -76,7 +62,6 @@ const RequestModal = ({
tmdbId={tmdbId} tmdbId={tmdbId}
onUpdating={onUpdating} onUpdating={onUpdating}
is4k={is4k} is4k={is4k}
requestTrigger={requestTrigger}
/> />
)} )}
</Transition> </Transition>

Loading…
Cancel
Save