"use client";
import type { Metadata } from "next";
import "./globals.css";

import { action, createStore, StoreProvider } from "easy-peasy";
import { Inter } from "next/font/google";

import { StoreModel } from "@appTypes/StoreModel";
import Navbar from "@components/Navbar";

const inter = Inter({
	subsets: ["latin"],
	variable: "--font-inter",
});

const store = createStore<StoreModel>({
	currency: {
		selectedCurrency: "GBP",
		setSelectedCurrency: action((state, payload) => {
			state.selectedCurrency = payload;
		}),
		currencies: ["GBP", "USD", "EUR"],
		conversionRates: { GBP: 1, USD: 1.33, EUR: 1.17 },
		tickers: { GBP: "£", USD: "$", EUR: "€" },
	},
});

export default function RootLayout({
	children,
}: Readonly<{
	children: React.ReactNode;
}>) {
	return (
		<html lang="en">
			<StoreProvider store={store}>
				<body className={`${inter.variable} h-[calc(100vh-3.5rem)] flex flex-col min-h-screen antialiased`}>
					<Navbar></Navbar>
					<div className="flex-1 overflow-y-auto">{children}</div>
				</body>
			</StoreProvider>
		</html>
	);
}
