import flet as ft
from admin.company_data import CompanyData
from admin.company_details import CompanyDetails

class Settings:
    def __init__(self, page: ft.Page, dashboard):
        self.page = page
        self.dashboard = dashboard

    def on_add_policy_btn_click(self, e):
        policy = CompanyDetails(self.page)
        self.dashboard.placeholder.content = policy.build()
        self.dashboard.placeholder.update()

    def on_add_data_btn_click(self, e):
        data = CompanyData(self.page)
        self.dashboard.placeholder.content = data.build()
        self.dashboard.placeholder.update()

    def build(self):
        return ft.Container(
            content=ft.Column(
                [
                    ft.GridView(
                        [
                            ft.Card(
                                content=ft.Container(
                                    content=ft.Column(
                                        [
                                            ft.Icon(name=ft.Icons.DATASET, size=100),
                                            ft.Text("Adauga datele companiei", size=16, weight=ft.FontWeight.BOLD),
                                            ft.Button("Adauga", icon=ft.Icons.ADD, on_click=self.on_add_data_btn_click)
                                        ],
                                        horizontal_alignment=ft.CrossAxisAlignment.CENTER
                                    ),
                                    padding=10
                                )
                            ),
                            ft.Card(
                                content=ft.Container(
                                    content=ft.Column(
                                        [
                                            ft.Icon(name=ft.Icons.POLICY, size=100),
                                            ft.Text("Adauga politicile companiei", size=16, weight=ft.FontWeight.BOLD),
                                            ft.Button("Adauga", icon=ft.Icons.ADD, on_click=self.on_add_policy_btn_click)
                                        ],
                                        horizontal_alignment=ft.CrossAxisAlignment.CENTER
                                    ),
                                    padding=10
                                )
                            )
                        ],
                        spacing=10,
                        runs_count=4,
                        max_extent=250,
                        child_aspect_ratio=1.0,
                        expand=True,
                        width=1000
                    )
                ]
            )
        )