From a1bac0c9869b826978d20300ae0df3c960c4773f Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Sat, 13 Jan 2024 15:09:48 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Update=20admin=20layout=20and=20pag?= =?UTF-8?q?es=20(#976)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 2 +- apps/web/next.config.js | 14 +- apps/web/package.json | 1 + apps/web/public/locales/en/app.json | 37 +-- apps/web/src/app/[locale]/(admin)/layout.tsx | 59 ++++- .../src/app/[locale]/(admin)/menu-item.tsx | 42 ++++ .../src/app/[locale]/(admin)/new/loading.tsx | 3 + .../web/src/app/[locale]/(admin)/new/page.tsx | 33 ++- .../src/app/[locale]/(admin)/polls/page.tsx | 41 +++- .../[locale]/(admin)/polls/polls-folders.tsx | 55 +++++ .../app/[locale]/(admin)/polls/polls-list.tsx | 211 ++++++++++++++++++ .../app/[locale]/(admin)/polls/polls-page.tsx | 174 --------------- .../(admin)/settings/billing/billing-page.tsx | 5 +- .../(admin)/settings/billing/loading.tsx | 3 + .../app/[locale]/(admin)/settings/layout.tsx | 65 +++++- .../[locale]/(admin)/settings/menu-item.tsx | 102 +++++++++ .../(admin)/settings/preferences/loading.tsx | 3 + .../settings/preferences/preferences-page.tsx | 5 +- .../(admin)/settings/profile/loading.tsx | 3 + .../(admin)/settings/profile/profile-page.tsx | 118 ++++++---- apps/web/src/app/[locale]/(admin)/sidebar.tsx | 161 +++++++++++++ .../app/[locale]/{ => auth}/logout/route.ts | 4 +- .../app/[locale]/invite/[urlId]/layout.tsx | 29 +-- .../src/app/[locale]/invite/[urlId]/page.tsx | 56 ++--- apps/web/src/app/[locale]/layout.tsx | 2 + .../web/src/app/[locale]/menu/back-button.tsx | 19 ++ apps/web/src/app/[locale]/menu/page.tsx | 30 +++ .../poll/[urlId]/duplicate/page.tsx | 0 .../poll/[urlId]/edit-details/page.tsx | 0 .../poll/[urlId]/edit-options/page.tsx | 0 .../poll/[urlId]/edit-settings/page.tsx | 0 .../poll/[urlId]/finalize/page.tsx | 0 .../{(admin) => }/poll/[urlId]/layout.tsx | 0 .../src/app/[locale]/poll/[urlId]/loading.tsx | 3 + .../{(admin) => }/poll/[urlId]/page.tsx | 12 +- apps/web/src/app/components/logo-link.tsx | 20 ++ apps/web/src/app/components/logout-button.tsx | 14 ++ apps/web/src/app/components/page-layout.tsx | 57 +++++ apps/web/src/components/auth/auth-forms.tsx | 3 +- .../src/components/billing/billing-plans.tsx | 6 +- apps/web/src/components/container.tsx | 4 +- apps/web/src/components/create-poll.tsx | 11 +- apps/web/src/components/date-card.tsx | 2 +- apps/web/src/components/event-card.tsx | 170 +++++++------- apps/web/src/components/invite-dialog.tsx | 54 ++--- .../src/components/layouts/poll-layout.tsx | 133 +++++------ .../src/components/layouts/profile-layout.tsx | 96 +++----- .../components/layouts/standard-layout.tsx | 207 ----------------- .../layouts/standard-layout/top-bar.tsx | 40 ---- apps/web/src/components/page-dialog.tsx | 6 +- apps/web/src/components/pay-wall.tsx | 163 +------------- apps/web/src/components/poll-status.tsx | 20 +- apps/web/src/components/poll.tsx | 21 +- .../src/components/poll/poll-subheader.tsx | 2 +- apps/web/src/components/pro-badge.tsx | 30 +-- apps/web/src/components/settings/settings.tsx | 12 +- apps/web/src/components/table.tsx | 198 +++++++++++----- apps/web/src/components/text-input.tsx | 4 +- apps/web/src/components/user-dropdown.tsx | 37 +-- apps/web/src/components/user.tsx | 1 + apps/web/src/contexts/plan.tsx | 4 +- apps/web/src/pages/404.tsx | 3 - apps/web/src/pages/api/stripe/checkout.ts | 2 +- apps/web/src/pages/api/stripe/portal.ts | 2 +- apps/web/src/style.css | 23 +- apps/web/src/utils/cookies.ts | 11 + apps/web/src/utils/dayjs.tsx | 17 +- apps/web/tests/authentication.spec.ts | 6 - apps/web/tests/legacy-token.spec.ts | 32 --- package.json | 2 +- packages/backend/trpc/routers/polls.ts | 71 ++++++ packages/ui/alert.tsx | 9 +- packages/ui/badge.tsx | 2 +- packages/ui/billing-plan.tsx | 2 +- packages/ui/button.tsx | 14 +- packages/ui/package.json | 1 + packages/ui/select.tsx | 2 +- packages/ui/toast.tsx | 127 +++++++++++ packages/ui/toaster.tsx | 34 +++ packages/ui/use-toast.ts | 189 ++++++++++++++++ yarn.lock | 171 ++++++++------ 81 files changed, 2060 insertions(+), 1267 deletions(-) create mode 100644 apps/web/src/app/[locale]/(admin)/menu-item.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/new/loading.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/polls/polls-folders.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx delete mode 100644 apps/web/src/app/[locale]/(admin)/polls/polls-page.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/settings/billing/loading.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/settings/menu-item.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/settings/preferences/loading.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/settings/profile/loading.tsx create mode 100644 apps/web/src/app/[locale]/(admin)/sidebar.tsx rename apps/web/src/app/[locale]/{ => auth}/logout/route.ts (65%) create mode 100644 apps/web/src/app/[locale]/menu/back-button.tsx create mode 100644 apps/web/src/app/[locale]/menu/page.tsx rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/duplicate/page.tsx (100%) rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/edit-details/page.tsx (100%) rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/edit-options/page.tsx (100%) rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/edit-settings/page.tsx (100%) rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/finalize/page.tsx (100%) rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/layout.tsx (100%) create mode 100644 apps/web/src/app/[locale]/poll/[urlId]/loading.tsx rename apps/web/src/app/[locale]/{(admin) => }/poll/[urlId]/page.tsx (81%) create mode 100644 apps/web/src/app/components/logo-link.tsx create mode 100644 apps/web/src/app/components/logout-button.tsx create mode 100644 apps/web/src/app/components/page-layout.tsx delete mode 100644 apps/web/src/components/layouts/standard-layout.tsx delete mode 100644 apps/web/src/components/layouts/standard-layout/top-bar.tsx create mode 100644 apps/web/src/utils/cookies.ts delete mode 100644 apps/web/tests/legacy-token.spec.ts create mode 100644 packages/ui/toast.tsx create mode 100644 packages/ui/toaster.tsx create mode 100644 packages/ui/use-toast.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 13292350cef..ee40c449843 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "typescript.tsdk": "node_modules/typescript/lib", "typescript.preferences.importModuleSpecifier": "non-relative", diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 557dcbf446f..7393ba932b4 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -52,13 +52,12 @@ const nextConfig = { }, ]; }, - sentry: { - hideSourceMaps: false, - }, }; const sentryWebpackPluginOptions = { - // Additional config options for the Sentry Webpack plugin. Keep in mind that + org: "stack-snap", + project: "rallly", + // Additional config ocptions for the Sentry Webpack plugin. Keep in mind that // the following options are set automatically, and overriding them is not // recommended: // release, url, org, project, authToken, configFile, stripPrefix, @@ -70,8 +69,9 @@ const sentryWebpackPluginOptions = { // https://github.com/getsentry/sentry-webpack-plugin#options. }; +const withBundleAnalyzerConfig = withBundleAnalyzer(nextConfig); // Make sure adding Sentry options is the last code to run before exporting, to // ensure that your source maps include changes from all other Webpack plugins -module.exports = withSentryConfig( - withBundleAnalyzer(nextConfig, sentryWebpackPluginOptions), -); +module.exports = process.env.SENTRY_AUTH_TOKEN + ? withSentryConfig(withBundleAnalyzerConfig, sentryWebpackPluginOptions) + : withBundleAnalyzerConfig; diff --git a/apps/web/package.json b/apps/web/package.json index cde55bf8343..16179216e4d 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -53,6 +53,7 @@ "iron-session": "^6.3.1", "js-cookie": "^3.0.1", "lodash": "^4.17.21", + "lucide-react": "^0.294.0", "micro": "^10.0.1", "nanoid": "^4.0.0", "next-auth": "^4.24.5", diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json index c0a93c15fb2..9636e9617ff 100644 --- a/apps/web/public/locales/en/app.json +++ b/apps/web/public/locales/en/app.json @@ -112,9 +112,6 @@ "dates": "Dates", "menu": "Menu", "useLocaleDefaults": "Use locale defaults", - "inviteParticipantsDescription": "Copy and share this invite link to start gathering responses from your participants.", - "inviteLink": "Invite Link", - "inviteParticipantLinkInfo": "Anyone with this link will be able to vote on your poll.", "support": "Support", "billing": "Billing", "guestPollAlertDescription": "<0>Create an account or <1>login to claim this poll.", @@ -135,7 +132,6 @@ "permissionDenied": "Unauthorized", "permissionDeniedDescription": "If you are the poll creator, please login to access your poll", "loginDifferent": "Switch user", - "share": "Share", "timeShownIn": "Times shown in {timeZone}", "editDetailsDescription": "Change the details of your event.", "finalizeDescription": "Select a final date for your event.", @@ -210,14 +206,7 @@ "earlyAccess": "Get early access to new features", "earlyAdopterDescription": "As an early adopter, you'll lock in your subscription rate and won't be affected by future price increases.", "upgradeNowSaveLater": "Upgrade now, save later", - "savePercent": "Save {percent}%", - "priceIncreaseSoon": "Price increase soon.", - "lockPrice": "Upgrade today to keep this price forever.", - "features": "Get access to all current and future Pro features!", - "noAds": "No ads", - "supportProject": "Support this project", "pricing": "Pricing", - "pleaseUpgrade": "Please upgrade to Pro to use this feature", "pollSettingsDescription": "Customize the behaviour of your poll", "requireParticipantEmailLabel": "Make email address required for participants", "hideParticipantsLabel": "Hide participant list from other participants", @@ -226,8 +215,28 @@ "authErrorDescription": "There was an error logging you in. Please try again.", "authErrorCta": "Go to login page", "continueAs": "Continue as", - "finalizeFeature": "Finalize", - "duplicateFeature": "Duplicate", "pageMovedDescription": "Redirecting to {newUrl}", - "notRegistered": "Don't have an account? Register" + "notRegistered": "Don't have an account? Register", + "comingSoon": "Coming Soon", + "integrations": "Integrations", + "contacts": "Contacts", + "unlockFeatures": "Unlock all Pro features.", + "back": "Back", + "pollStatusAll": "All", + "pollStatusLive": "Live", + "pollStatusFinalized": "Finalized", + "pending": "Pending", + "xMore": "{count} more", + "share": "Share", + "pageXOfY": "Page {currentPage} of {pageCount}", + "noParticipants": "No participants", + "userId": "User ID", + "aboutGuest": "Guest User", + "aboutGuestDescription": "Profile settings are not available for guest users. <0>Sign in to your existing account or <1>create a new account to customize your profile.", + "logoutDescription": "Sign out of your existing session", + "events": "Events", + "registrations": "Registrations", + "inviteParticipantsDescription": "Copy and share the invite link to start gathering responses from your participants.", + "inviteLink": "Invite Link", + "inviteParticipantLinkInfo": "Anyone with this link will be able to vote on your poll." } diff --git a/apps/web/src/app/[locale]/(admin)/layout.tsx b/apps/web/src/app/[locale]/(admin)/layout.tsx index 5f7fa20fbc6..e1138eddcc4 100644 --- a/apps/web/src/app/[locale]/(admin)/layout.tsx +++ b/apps/web/src/app/[locale]/(admin)/layout.tsx @@ -1,8 +1,13 @@ -"use client"; +import { cn } from "@rallly/ui"; +import { Button } from "@rallly/ui/button"; +import { MenuIcon } from "lucide-react"; +import Link from "next/link"; import { signIn, useSession } from "next-auth/react"; import React from "react"; -import { StandardLayout } from "@/components/layouts/standard-layout"; +import { Sidebar } from "@/app/[locale]/(admin)/sidebar"; +import { LogoLink } from "@/app/components/logo-link"; +import { CurrentUserAvatar } from "@/components/user"; import { isSelfHosted } from "@/utils/constants"; const Auth = ({ children }: { children: React.ReactNode }) => { @@ -22,13 +27,57 @@ const Auth = ({ children }: { children: React.ReactNode }) => { return null; }; -export default function Layout({ children }: { children: React.ReactNode }) { +function MobileNavigation() { + return ( +
+ +
+ + + + +
+
+ ); +} + +export default async function Layout({ + children, +}: { + children: React.ReactNode; +}) { + function SidebarLayout() { + return ( +
+ +
+
+ +
+ +
+
{children}
+
+ ); + } + if (isSelfHosted) { return ( - {children} + ); } - return {children}; + return ; } diff --git a/apps/web/src/app/[locale]/(admin)/menu-item.tsx b/apps/web/src/app/[locale]/(admin)/menu-item.tsx new file mode 100644 index 00000000000..9235b17ad90 --- /dev/null +++ b/apps/web/src/app/[locale]/(admin)/menu-item.tsx @@ -0,0 +1,42 @@ +"use client"; + +import { cn } from "@rallly/ui"; +import { Link } from "lucide-react"; +import { usePathname } from "next/navigation"; + +import { IconComponent } from "@/types"; + +export function MenuItem({ + href, + children, + icon: Icon, +}: { + href: string; + icon: IconComponent; + children: React.ReactNode; +}) { + const pathname = usePathname(); + const isCurrent = pathname === href; + return ( + +