import flet as ft
from pages.report_order_out_page import ReportOrderOutPage
from pages.report_order_in_page import ReportOrderInPage

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

    def on_report_orders_in_btn_click(self, e):
        order_in_page = ReportOrderInPage(self.page, self.dashboard)
        self.dashboard.placeholder.content = order_in_page.build()
        self.dashboard.placeholder.update()

    def on_report_orders_out_btn_click(self, e):
        orders_out_page = ReportOrderOutPage(self.page, self.dashboard)
        self.dashboard.placeholder.content = orders_out_page.build()
        self.dashboard.placeholder.update()

    def build(self):
        return ft.Container(
            content=ft.Column(
                [
                    ft.Text("Reports", size=24, weight=ft.FontWeight.BOLD),
                    ft.Row(
                        [
                            ft.Container(
                                content=ft.Column(
                                    [
                                        ft.Icon(ft.Icons.ASSESSMENT, size=150),
                                        ft.Container(
                                            ft.Row(
                                                [
                                                    ft.Text("Report for Orders In", size=20)
                                                ],
                                                alignment=ft.MainAxisAlignment.CENTER
                                            ),
                                            bgcolor=ft.Colors.BLUE_200,
                                            width=250,
                                            height=80
                                        ),
                                        ft.Row(
                                            [
                                                ft.FilledButton(
                                                    "Report",
                                                    on_click=self.on_report_orders_in_btn_click,
                                                    width=100
                                                )
                                            ],
                                            alignment=ft.MainAxisAlignment.SPACE_EVENLY
                                        )
                                        
                                    ],
                                    alignment=ft.MainAxisAlignment.CENTER,
                                    horizontal_alignment=ft.CrossAxisAlignment.CENTER
                                ),
                                border=ft.border.all(1, ft.Colors.GREY_300),
                                bgcolor=ft.Colors.BLUE_50,
                                padding = ft.padding.symmetric(vertical=20),
                                width=250,
                                height=350,
                                border_radius=20
                            ),
                            ft.Container(
                                content=ft.Column(
                                    [
                                        ft.Icon(ft.Icons.ASSESSMENT, size=150),
                                        ft.Container(
                                            ft.Row(
                                                [
                                                    ft.Text("Report for Orders Out", size=20)
                                                ],
                                                alignment=ft.MainAxisAlignment.CENTER
                                            ),
                                            bgcolor=ft.Colors.BLUE_200,
                                            width=250,
                                            height=80
                                        ),
                                        ft.Row(
                                            [
                                                ft.FilledButton(
                                                    "Report",
                                                    on_click=self.on_report_orders_out_btn_click,
                                                    width=100
                                                )
                                            ],
                                            alignment=ft.MainAxisAlignment.SPACE_EVENLY
                                        )
                                    ],
                                    alignment=ft.MainAxisAlignment.CENTER,
                                    horizontal_alignment=ft.CrossAxisAlignment.CENTER
                                ),
                                border=ft.border.all(1, ft.Colors.GREY_300),
                                bgcolor=ft.Colors.BLUE_50,
                                padding = ft.padding.symmetric(vertical=20),
                                width=250,
                                height=350,
                                border_radius=20
                            )
                        ],
                        alignment=ft.MainAxisAlignment.CENTER,
                        spacing=50
                    ),
                    ft.Text(" ")
                ],
                expand=True,
                alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
            ),
            expand=True
        )