123456789101112131415161718192021222324252627282930313233 |
- import { useState, useEffect } from 'react';
- import { getVideoContentCategoryListApi } from '@src/http/api';
- import request from '@src/http/index';
- export const useVideoCategoryOptions = () => {
- const [videoCategoryOptions, setVideoCategoryOptions] = useState<string[]>([]);
- const [loading, setLoading] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const getVideoCategoryList = async () => {
- try {
- setLoading(true);
- setError(null);
- const data = await request.get(getVideoContentCategoryListApi);
- setVideoCategoryOptions(data.data as string[]);
- } catch (err) {
- setError(err instanceof Error ? err.message : 'Failed to fetch accounts');
- } finally {
- setLoading(false);
- }
- };
- useEffect(() => {
- getVideoCategoryList();
- }, []);
- return {
- videoCategoryOptions,
- getVideoCategoryList,
- loading,
- error
- };
- };
|