aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/components/saveToLocalStorage.js
blob: 313b15736a8958aa35614634d4d084d136df2977 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use client";

import { storeLocal } from "./storeHistory";

export default function store_to_local(name, image, episode, id) {
	const currentDate = new Date();

	try {
		let newData = {
			name: name,
			image: image,
			episode: episode,
			id: id,
			type: "anime",
			date: `${currentDate.getDate()}-${String(
				currentDate.getMonth() + 1
			).padStart(2, "0")}`,
			time: `${currentDate.getHours()}:${String(
				currentDate.getMinutes()
			).padStart(2, "0")}`,
		};
		storeLocal(newData);
	} catch (error) {
		console.error(
			"Some error occurred during the process of saving your watch history to local storage. Please try again or contact us on GitHub if this issue persists.",
			error.message
		);
	}
}