import axios from "axios";
import { authedFunction } from "../session";
import { getUrl } from "../helper";

export const stringActions = {
	getString: (site, id, useDefault) => {
		const url = getUrl(
			"strings",
			`get/${site}_${id}`,
			useDefault ? { useDefault } : undefined,
		);
		return axios({
			method: "GET",
			url,
		}).catch((error) => {
			console.log("getString error", error);
			throw error;
		});
	},
	setString: (site, key, value) => {
		const url = getUrl("strings", "set");
		return authedFunction({
			method: "POST",
			url,
			data: {
				site,
				key,
				value,
			},
		});
	},
};
