"use client"; import { ny } from "@/lib/utils"; import GridPattern from "./ui/grid-pattern"; import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "./ui/select"; import { Button } from "./ui/button"; import { Form, FormField, FormItem, FormLabel } from "./ui/form"; import { useForm } from "react-hook-form"; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod' import { releases } from "@/lib/releases"; import { addDownload } from "@/lib/db"; const BASE_URL = "https://github.com/zen-browser/desktop/releases/latest/download"; function getDefaultPlatformBasedOnUserAgent() { let userAgent = ""; if (typeof window !== "undefined") { userAgent = window.navigator.userAgent; } if (userAgent.includes("Win")) { return "WindowsInstaller"; } if (userAgent.includes("Mac")) { // TODO: // return "MacOS"; return ""; } if (userAgent.includes("Linux")) { return "Linux"; } return ""; } const formSchema = z.object({ platform: z.string().nonempty(), }); export default function DownloadPage() { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { platform: getDefaultPlatformBasedOnUserAgent(), }, }); const onSubmit = async (data: any) => { const platform = data.platform; addDownload(platform); console.log("Data: ", data) console.log("Platform: ", platform) console.log("Releases: ", releases) const releasesForPlatform = releases[platform]; console.log("Releases for platform: ", releasesForPlatform) const url = `${BASE_URL}/${releasesForPlatform}`; console.log("URL: ", url) window.open(url, "_blank"); } return (

Download Zen Browser

Get started with Zen Browser today. Get back to browsing the web with peace of mind.

( Select your operating system )} />
); }