"use client";

import { useState } from "react";
import useApiMutation, { useApi } from "./use-api";
import IPaginatedResponse from "@/interfaces/IPaginatedResponse";
import Media from "@/interfaces/Media";

interface MediaResponse {
	page: number;
	limit: number;
	totalPages: number;
	items: [];
}

export default function useMedia(_limit: number = 20) {
	const [page, setPage] = useState(1);
	const [limit, setLimit] = useState(_limit);
	const res = useApi<IPaginatedResponse<Media>>(
		`/media?page=${page}&limit=${limit}`,
	);
	return {
		...res,
		setPage,
		setLimit,
	};
}
