feat(frontend/api): beginning of new request modal
also includes new api endpoints for seasons
This commit is contained in:
47
src/components/RequestModal/index.tsx
Normal file
47
src/components/RequestModal/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import useSWR from 'swr';
|
||||
import MovieRequestModal from './MovieRequestModal';
|
||||
import type { MediaRequest } from '../../../server/entity/MediaRequest';
|
||||
import type { MediaStatus } from '../../../server/constants/media';
|
||||
|
||||
interface RequestModalProps {
|
||||
requestId?: number;
|
||||
show: boolean;
|
||||
type: 'movie' | 'tv';
|
||||
tmdbId: number;
|
||||
onComplete?: (newStatus: MediaStatus) => void;
|
||||
onError?: (error: string) => void;
|
||||
onCancel?: () => void;
|
||||
onUpdating?: (isUpdating: boolean) => void;
|
||||
}
|
||||
|
||||
const RequestModal: React.FC<RequestModalProps> = ({
|
||||
type,
|
||||
requestId,
|
||||
show,
|
||||
tmdbId,
|
||||
onComplete,
|
||||
onError,
|
||||
onUpdating,
|
||||
onCancel,
|
||||
}) => {
|
||||
const { data } = useSWR<MediaRequest>(
|
||||
requestId ? `/api/v1/request/${requestId}` : null
|
||||
);
|
||||
if (type === 'tv') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<MovieRequestModal
|
||||
onComplete={onComplete}
|
||||
onCancel={onCancel}
|
||||
visible={show}
|
||||
request={data}
|
||||
tmdbId={tmdbId}
|
||||
onUpdating={onUpdating}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestModal;
|
||||
Reference in New Issue
Block a user