const sitesURL = "/sites";
const navigationURL = "/sites/navigations";
const dataURL = "/data";

const PREV_URLS = {
	pages: `${sitesURL}/pages`,
	defaults: `${navigationURL}/defaults`,
};

const getPrevURL = (currLocation: string) => {
	const isSite = currLocation.includes(sitesURL) && currLocation.length > sitesURL.length;
	const isNavigation = currLocation.includes(navigationURL) && currLocation.length > navigationURL.length;
	const prev = isNavigation ? "defaults" : "pages";

	const prevURL = isSite ? PREV_URLS[prev] : dataURL;

	return prevURL;
};

export { getPrevURL };
