import { AxiosInstance } from 'axios';
import React, { ReactElement } from 'react';
import { libraryClient, accountClient, userClient } from '../axios';
import useAxiosWithAuth from '../hooks/useAxiosWithAuth';

export interface IAxiosProviderProps extends React.PropsWithChildren{
	libraryClient?: AxiosInstance | undefined | null,
	accountClient?: AxiosInstance | undefined | null,
	userClient?: AxiosInstance | undefined | null,
	children: ReactElement
} 

export default function AxiosProvider(props: IAxiosProviderProps) {
    useAxiosWithAuth(props.libraryClient ?? libraryClient);
    useAxiosWithAuth(props.accountClient ?? accountClient);
    useAxiosWithAuth(props.userClient ?? userClient);
    return (props.children);
};