import {
	createStash,
	removeStash,
	stashActor,
	stashScene,
	stashMovie,
	unstashActor,
	unstashScene,
	unstashMovie,
	updateStash,
} from '../stashes.js';

export async function createStashApi(req, res) {
	const stash = await createStash(req.body, req.session.user);

	res.send(stash);
}

export async function updateStashApi(req, res) {
	const stash = await updateStash(req.params.stashId, req.body, req.session.user);

	res.send(stash);
}

export async function removeStashApi(req, res) {
	await removeStash(req.params.stashId, req.session.user);

	res.status(204).send();
}

export async function stashActorApi(req, res) {
	const stashes = await stashActor(req.body.actorId, req.params.stashId, req.user);

	res.send(stashes);
}

export async function stashSceneApi(req, res) {
	const stashes = await stashScene(req.body.sceneId, req.params.stashId, req.user);

	res.send(stashes);
}

export async function stashMovieApi(req, res) {
	const stashes = await stashMovie(req.body.movieId, req.params.stashId, req.user);

	res.send(stashes);
}

export async function unstashActorApi(req, res) {
	const stashes = await unstashActor(req.params.actorId, req.params.stashId, req.user);

	res.send(stashes);
}

export async function unstashSceneApi(req, res) {
	const stashes = await unstashScene(Number(req.params.sceneId), Number(req.params.stashId), req.user);

	res.send(stashes);
}

export async function unstashMovieApi(req, res) {
	const stashes = await unstashMovie(req.params.movieId, req.params.stashId, req.user);

	res.send(stashes);
}
