import { get } from "@/config/request";

export const getPT = async (params) => {
	try {
		let url = "/perguruan-tinggi";
		if (params) {
			url += "?";
			if (params.id) {
				url += `id=${params.id}`;
			} else if (params.search || params.pembina) {
				const parseURL = [];
				if (params.search) parseURL.push(`search=${params.search}`);
				if (params.pembina) parseURL.push(`pembina=${params.pembina}`);
				url += parseURL.join('&')
			}
		}
		const response = await get(url);
		return response.data;
	} catch (error) {
		console.log("error", error);
		return false;
	}
};

export const getPembina = async (params) => {
	try {
		let url = "/perguruan-tinggi/lembaga";
		if (params) {
			url += "?";
			if (params.search) {
				url += `search=${params.search}`;
			}
		}
		const response = await get(url);
		return response.data;
	} catch (error) {
		console.log("error", error);
		return false;
	}
};
