import { useForm, UseFormReturnType } from "@mantine/form";
import { SortDir } from "@/lib/client";

export type SortingForm = {
    sortingField?: string;
    sortingDirection: SortDir;
};

type ReturnType = {
    form: UseFormReturnType<SortingForm>;
};

const useSorting = (): ReturnType => {
    const initialFilters = {
        sortingField: "createdAt",
        sortingDirection: "asc" as SortDir,
    };

    const form = useForm<SortingForm>({
        initialValues: initialFilters,
    });

    return {
        form,
    };
};

export default useSorting;
