diff --git a/app/(api)/api/calendar/[ownerId]/[projectId]/route.ts b/app/(api)/api/calendar/[ownerId]/[projectId]/route.ts index 17a4eb1..b609293 100644 --- a/app/(api)/api/calendar/[ownerId]/[projectId]/route.ts +++ b/app/(api)/api/calendar/[ownerId]/[projectId]/route.ts @@ -1,5 +1,6 @@ import { calendarEvent, project, task, taskList } from "@/drizzle/schema"; import { getDatabaseForOwner } from "@/lib/utils/useDatabase"; +import { getVtimezoneComponent } from "@touch4it/ical-timezones"; import { and, desc, eq, lte } from "drizzle-orm"; import ical, { ICalCalendarMethod } from "ical-generator"; @@ -46,7 +47,7 @@ export async function GET( const calendar = ical({ name: projectDetails.name, method: ICalCalendarMethod.PUBLISH, - timezone: { name: "UTC" }, + timezone: { name: "Australia/Sydney", generator: getVtimezoneComponent }, }); for (const event of events) { @@ -60,7 +61,7 @@ export async function GET( created: event.createdAt, lastModified: event.updatedAt, repeating: event.repeatRule, - timezone: "UTC", + timezone: "Australia/Sydney", }); } @@ -82,7 +83,7 @@ export async function GET( allDay: true, created: task.createdAt, lastModified: task.updatedAt, - timezone: "UTC", + timezone: "Australia/Sydney", }); } } diff --git a/app/(dashboard)/[tenant]/layout.tsx b/app/(dashboard)/[tenant]/layout.tsx index 767dd21..3dc41a4 100644 --- a/app/(dashboard)/[tenant]/layout.tsx +++ b/app/(dashboard)/[tenant]/layout.tsx @@ -1,7 +1,7 @@ import NavBar from "@/components/console/navbar"; import { ReportTimezone } from "@/components/core/report-timezone"; import { isDatabaseReady } from "@/lib/utils/useDatabase"; -import { getOrgs, getOwner } from "@/lib/utils/useOwner"; +import { getOrganizations, getOwner } from "@/lib/utils/useOwner"; import { redirect } from "next/navigation"; export const fetchCache = "force-no-store"; // disable cache for console pages @@ -19,8 +19,8 @@ export default async function ConsoleLayout(props: { const ready = await isDatabaseReady(); const { orgId, orgSlug } = await getOwner(); - const orgs = await getOrgs(); - const activatedOrg = orgs.find((org) => org.id === orgId) ?? null; + const organizations = await getOrganizations(); + const activatedOrg = organizations.find((org) => org.id === orgId) ?? null; if (!ready || params.tenant !== orgSlug) { redirect("/start"); @@ -28,7 +28,7 @@ export default async function ConsoleLayout(props: { return (
- +
diff --git a/app/(dashboard)/[tenant]/settings/actions.ts b/app/(dashboard)/[tenant]/settings/actions.ts index bc1e69b..1448a3f 100644 --- a/app/(dashboard)/[tenant]/settings/actions.ts +++ b/app/(dashboard)/[tenant]/settings/actions.ts @@ -1,5 +1,7 @@ "use server"; +import { updateUser } from "@/lib/ops/auth"; +import { getOwner } from "@/lib/utils/useOwner"; import { cookies } from "next/headers"; export async function saveUserTimezone(timezone: string) { @@ -9,4 +11,7 @@ export async function saveUserTimezone(timezone: string) { sameSite: "strict", maxAge: 60 * 60 * 24 * 365, }); + + const { userId } = await getOwner(); + await updateUser(userId, { customData: { timezone } }); } diff --git a/components/console/navbar.tsx b/components/console/navbar.tsx index 7387f52..9dbd579 100644 --- a/components/console/navbar.tsx +++ b/components/console/navbar.tsx @@ -1,7 +1,8 @@ +import type { Organization } from "@/lib/ops/auth"; import Image from "next/image"; import Link from "next/link"; import logo from "../../public/images/logo.png"; -import { OrgSwitcher, type Organization, UserButton } from "../core/auth"; +import { OrgSwitcher, UserButton } from "../core/auth"; import NavBarLinks from "./navbar-links"; export default function NavBar({ diff --git a/components/core/auth.tsx b/components/core/auth.tsx index d70c84d..e4618d8 100644 --- a/components/core/auth.tsx +++ b/components/core/auth.tsx @@ -1,4 +1,5 @@ import { logtoConfig } from "@/app/logto"; +import type { Organization } from "@/lib/ops/auth"; import { signOut } from "@logto/next/server-actions"; import { ChevronsUpDown, Plus, User } from "lucide-react"; import Link from "next/link"; @@ -12,13 +13,6 @@ import { DropdownMenuTrigger, } from "../ui/dropdown-menu"; -// WIP, this should be changed -export type Organization = { - id: string; - name: string; - slug: string; -}; - export const OrgSwitcher = ({ orgs, activeOrg, @@ -67,7 +61,11 @@ export const OrgSwitcher = ({ // } > - +