import flet as ft
from pages.auth.login import Login
from pages.auth.register import Register

class Auth:
    def __init__(self, page: ft.Page, go_to = 'login'):
        self.page = page
        self.go_to = go_to
        self.logo = ft.Image("images/tainagustului.png", width=200)
        self.login = Login(self.page, self)
        self.register = Register(self.page, self, self.login)

        go_to = 'login' if self.page.session.get('go_to') == None or 'login' else self.page.session.get('go_to')
        if go_to == 'login':
            self.placeholder = ft.Container(
                content=self.login.build(),
                width=350
            )
        if go_to == 'register':
            self.placeholder = ft.Container(
                content=self.register.build(),
                width=350
            )

    def build(self):
        return ft.Container(
            content=ft.Column(
                [
                    self.logo,
                    self.placeholder,
                ],
                horizontal_alignment=ft.CrossAxisAlignment.CENTER
            )
        )