import { apiClient } from "./client";

export interface UserConfig {
	default_editor: string | null;
	theme: string;
	git_user_name: string | null;
	git_user_email: string | null;
	last_session_id: string | null;
	notification_toast_level?: "all" | "errors" | "none";
	notification_mute_categories?: string[];
}

export interface UserConfigUpdate {
	default_editor?: string | null;
	theme?: string | null;
	git_user_name?: string | null;
	git_user_email?: string | null;
	last_session_id?: string | null;
	notification_toast_level?: "all" | "errors" | "none";
	notification_mute_categories?: string[];
}

export const getUserConfig = async (): Promise<UserConfig> => {
	const response = await apiClient.get<UserConfig>("/users/me/config");
	return response.data;
};

export const updateUserConfig = async (
	data: UserConfigUpdate,
): Promise<UserConfig> => {
	const response = await apiClient.patch<UserConfig>("/users/me/config", data);
	return response.data;
};
