import {
    DropdownMenu,
    DropdownMenuContent,
    DropdownMenuItem,
    DropdownMenuLabel,
    DropdownMenuSeparator,
    DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import OrderImport from "./OrderImport";
import StandardOrderTemplate from "./StandardOrderTemplate";
import { Button } from "@/components/ui/button";
import StandardForecastTemplate from "./StandardForecastTemplate";
import ForecastImport from "./ForecastImport";
import { useSettingStore } from "@/lib/store/useSettings";

export default function DMButtons() {
    const { settings } = useSettingStore();

    const plantToken = settings.filter((n) => n.name === "plantToken");
    console.log(plantToken);
    return (
        <div className="flex flex-row-reverse">
            <div className="m-2">
                <DropdownMenu>
                    <DropdownMenuTrigger asChild>
                        <Button>Standard DM</Button>
                    </DropdownMenuTrigger>
                    <DropdownMenuContent>
                        <DropdownMenuLabel>
                            Standard templates and imports
                        </DropdownMenuLabel>
                        <DropdownMenuSeparator />
                        <DropdownMenuItem>
                            <StandardOrderTemplate />
                        </DropdownMenuItem>
                        <DropdownMenuItem>
                            <OrderImport
                                fileType={"standard"}
                                name={"Standard Order Import"}
                            />
                        </DropdownMenuItem>
                        <DropdownMenuSeparator />
                        <DropdownMenuItem>
                            <StandardForecastTemplate />
                        </DropdownMenuItem>
                        <DropdownMenuItem>
                            <ForecastImport
                                fileType={"standard"}
                                name={"Standard Forecast Import"}
                            />
                        </DropdownMenuItem>
                    </DropdownMenuContent>
                </DropdownMenu>
            </div>
            {plantToken[0]?.value === "usday1" && (
                <div className="m-2">
                    <DropdownMenu>
                        <DropdownMenuTrigger asChild>
                            <Button>Dayton Customs</Button>
                        </DropdownMenuTrigger>
                        <DropdownMenuContent>
                            <DropdownMenuLabel>
                                Custom import templates
                            </DropdownMenuLabel>
                            <DropdownMenuSeparator />

                            <DropdownMenuItem>
                                <OrderImport
                                    fileType={"abbott"}
                                    name={"Abbott truck list"}
                                />
                            </DropdownMenuItem>
                            <DropdownMenuSeparator />
                        </DropdownMenuContent>
                    </DropdownMenu>
                </div>
            )}
        </div>
    );
}
