Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change folder structure for organization - /org/[organizationId] #1

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23,196 changes: 10,250 additions & 12,946 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
import { T } from '@/components/ui/Typography';
import { Badge } from '@/components/ui/badge';
import { Skeleton } from '@/components/ui/skeleton';
import { getOrganizationIdBySlug, getOrganizationTitle } from '@/data/user/organizations';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { getOrganizationTitle } from '@/data/user/organizations';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { UsersRound } from 'lucide-react';
import Link from 'next/link';
import { Suspense } from 'react';

export async function generateMetadata({ params }: { params: unknown }) {
try {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)

const { organizationId } = organizationParamSchema.parse(params);
console.log('----------------------------------------')
console.log('in [...catchAll]/page organizationId', organizationId)
console.log('----------------------------------------')
const organizationTitle = await getOrganizationTitle(organizationId);

return {
Expand Down Expand Up @@ -46,12 +47,11 @@ export default async function OrganizationProjectsNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)
const { organizationId } = organizationParamSchema.parse(params);

return (
<div className="flex items-center">
<Link href={`/${organizationSlug}`}>
<Link href={`/org/${organizationId}`}>
<span className="flex items-center space-x-2">
<Suspense fallback={<Skeleton className="w-16 h-6" />}>
<Title organizationId={organizationId} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
import { T } from '@/components/ui/Typography';
import { Badge } from '@/components/ui/badge';
import { Skeleton } from '@/components/ui/skeleton';
import { getOrganizationIdBySlug, getOrganizationTitle } from '@/data/user/organizations';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { getOrganizationTitle } from '@/data/user/organizations';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { UsersRound } from 'lucide-react';
import Link from 'next/link';
import { Suspense } from 'react';

export async function generateMetadata({ params }: { params: unknown }) {
try {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)
const { organizationId } = organizationParamSchema.parse(params);

const organizationTitle = await getOrganizationTitle(organizationId);

Expand Down Expand Up @@ -45,11 +44,10 @@ export default async function OrganizationNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)
const { organizationId } = organizationParamSchema.parse(params);
return (
<div className="flex items-center">
<Link href={`/${organizationSlug}`}>
<Link href={`/org/${organizationId}`}>
<span className="flex items-center space-x-2">
<Suspense fallback={<Skeleton className="w-16 h-6" />}>
<Title organizationId={organizationId} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { T } from '@/components/ui/Typography';
import { cn } from '@/utils/cn';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { ArrowLeftIcon } from '@radix-ui/react-icons';
import Link from 'next/link';

Expand All @@ -9,12 +9,12 @@ export default async function OrganizationSettingsNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const { organizationId } = organizationParamSchema.parse(params);

return (
<div className={cn('hidden lg:block', 'relative ')}>
<T.P className="my-0">
<Link href={`/${organizationSlug}`}>
<Link href={`/org/${organizationId}`}>
<span className="space-x-2 flex items-center">
<ArrowLeftIcon />
<span>Back to Organization catch all</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from '@/utils/cn';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { ArrowLeftIcon } from '@radix-ui/react-icons';
import Link from 'next/link';

Expand All @@ -8,13 +8,13 @@ export default async function OrganizationSettingsNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const { organizationId } = organizationParamSchema.parse(params);
return (
<div className={cn('hidden ', 'relative flex gap-2 items-center')}>
Billing
<Link
className="flex gap-1.5 py-1.5 px-3 cursor-pointer items-center group rounded-md transition hover:cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-800"
href={`/${organizationSlug}`}
href={`/org/${organizationId}`}
>
<ArrowLeftIcon className="w-4 h-4 text-neutral-500 dark:text-neutral-400 group-hover:text-neutral-700 dark:group-hover:text-neutral-300" />
<span className="text-neutral-500 dark:text-neutral-400 group-hover:text-neutral-700 dark:group-hover:text-neutral-300 text-sm font-normal">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from '@/utils/cn';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { ArrowLeftIcon } from '@radix-ui/react-icons';
import Link from 'next/link';

Expand All @@ -8,13 +8,13 @@ export default async function OrganizationSettingsNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const { organizationId } = organizationParamSchema.parse(params);

return (
<div className={cn('hidden', 'relative flex gap-2 items-center')}>
<Link
className="flex gap-1.5 py-1.5 px-3 cursor-pointer items-center group rounded-md transition hover:cursor-pointer hover:bg-primary-100 dark:hover:bg-primary-900"
href={`/${organizationSlug}`}
href={`/org/${organizationId}`}
>
<ArrowLeftIcon className="w-4 h-4 text-primary-500 dark:text-primary-500 group-hover:text-primary-700 dark:group-hover:text-primary-700" />
<span className="text-primary-500 dark:text-primary-500 group-hover:text-primary-700 dark:group-hover:text-primary-700 text-sm font-normal">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from '@/utils/cn';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { ArrowLeftIcon } from '@radix-ui/react-icons';
import Link from 'next/link';

Expand All @@ -8,13 +8,13 @@ export default async function OrganizationSettingsNavbar({
}: {
params: unknown;
}) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const { organizationId } = organizationParamSchema.parse(params);

return (
<div className={cn('hidden ', 'relative flex gap-2 items-center ')}>
<Link
className="flex gap-1.5 py-1.5 px-3 cursor-pointer items-center group rounded-md transition hover:cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-800"
href={`/${organizationSlug}`}
href={`/org/${organizationId}`}
>
<ArrowLeftIcon className="w-4 h-4 text-neutral-500 dark:text-neutral-400 group-hover:text-neutral-700 dark:group-hover:text-neutral-300" />
<p className="text-neutral-500 dark:text-neutral-400 group-hover:text-neutral-700 dark:group-hover:text-neutral-300 text-sm font-normal">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ProFeatureGateDialog } from '@/components/ProFeatureGateDialog';
import { SidebarLink } from '@/components/SidebarLink';
import { fetchSlimOrganizations, getOrganizationIdBySlug } from '@/data/user/organizations';
import { fetchSlimOrganizations, getOrganizationSlugByOrganizationId } from '@/data/user/organizations';
import { cn } from '@/utils/cn';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { notFound } from 'next/navigation';
import { Suspense } from 'react';

Expand Down Expand Up @@ -36,32 +36,32 @@ async function OrganizationSidebarInternal({
<div>
<SidebarLink
label="Home"
href={`/${organizationSlug}`}
href={`/org/${organizationId}`}
icon={<Home className="h-5 w-5" />}
/>
<SidebarLink
label="Settings"
href={`/${organizationSlug}/settings`}
href={`/org/${organizationId}/settings`}
icon={<Settings className="h-5 w-5" />}
/>
<SidebarLink
label="Projects"
href={`/${organizationSlug}/projects`}
href={` /org/${organizationId}/projects`}
icon={<Layers className="h-5 w-5" />}
/>
<SidebarLink
label="Members"
href={`/${organizationSlug}/settings/members`}
href={`/org/${organizationId}/settings/members`}
icon={<UserRound className="h-5 w-5" />}
/>
<SidebarLink
label="Billing"
href={`/${organizationSlug}/settings/billing`}
href={`/org/${organizationId}/settings/billing`}
icon={<DollarSign className="h-5 w-5" />}
/>
<Suspense>
<ProFeatureGateDialog
organizationSlug={organizationSlug}
organizationId={organizationId}
label="Feature Pro"
icon={<FileBox className="h-5 w-5" />}
/>
Expand All @@ -84,8 +84,8 @@ async function OrganizationSidebarInternal({

export async function OrganizationSidebar({ params }: { params: unknown }) {
try {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)
const { organizationId } = organizationParamSchema.parse(params);
const organizationSlug = await getOrganizationSlugByOrganizationId(organizationId)
return (
<Suspense fallback={<DesktopSidebarFallback />}>
<OrganizationSidebarInternal organizationId={organizationId} organizationSlug={organizationSlug} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { ProFeatureGateDialog } from '@/components/ProFeatureGateDialog';
import { SidebarLink } from '@/components/SidebarLink';
import { SubscriptionCardSmall } from '@/components/SubscriptionCardSmall';
import { T } from '@/components/ui/Typography';
import { fetchSlimOrganizations, getOrganizationIdBySlug } from '@/data/user/organizations';
import { fetchSlimOrganizations, getOrganizationSlugByOrganizationId } from '@/data/user/organizations';
import { cn } from '@/utils/cn';
import { notFound } from 'next/navigation';
import { Suspense } from 'react';

import { DesktopSidebarFallback } from '@/components/SidebarComponents/SidebarFallback';
import { SwitcherAndToggle } from '@/components/SidebarComponents/SidebarLogo';
import { organizationSlugParamSchema } from '@/utils/zod-schemas/params';
import { organizationParamSchema } from '@/utils/zod-schemas/params';
import { DollarSign, FileBox, Home, Layers, Settings, UserRound } from 'lucide-react';

async function OrganizationSidebarInternal({
Expand All @@ -36,32 +36,32 @@ async function OrganizationSidebarInternal({
<div>
<SidebarLink
label="Home"
href={`/${organizationSlug}`}
href={`/org/${organizationId}`}
icon={<Home className="h-5 w-5" />}
/>
<SidebarLink
label="Projects"
href={`/${organizationSlug}/projects`}
href={`/org/${organizationId}/projects`}
icon={<Layers className="h-5 w-5" />}
/>
<SidebarLink
label="Settings"
href={`/${organizationSlug}/settings`}
href={`/org/${organizationId}/settings`}
icon={<Settings className="h-5 w-5" />}
/>
<SidebarLink
label="Members"
href={`/${organizationSlug}/settings/members`}
href={`/org/${organizationId}/settings/members`}
icon={<UserRound className="h-5 w-5" />}
/>
<SidebarLink
label="Billing"
href={`/${organizationSlug}/settings/billing`}
href={`/org/${organizationId}/settings/billing`}
icon={<DollarSign className="h-5 w-5" />}
/>
<Suspense>
<ProFeatureGateDialog
organizationSlug={organizationSlug}
organizationId={organizationId}
label="Feature Pro"
icon={<FileBox className="h-5 w-5" />}
/>
Expand All @@ -87,8 +87,8 @@ export default async function OrganizationSidebar({
params: unknown;
}) {
try {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug)
const { organizationId } = organizationParamSchema.parse(params);
const organizationSlug = await getOrganizationSlugByOrganizationId(organizationId);
return (
<Suspense fallback={<DesktopSidebarFallback />}>
<OrganizationSidebarInternal organizationId={organizationId} organizationSlug={organizationSlug} />
Expand All @@ -97,4 +97,4 @@ export default async function OrganizationSidebar({
} catch (e) {
return notFound();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ProjectsCardList } from "@/components/Projects/ProjectsCardList";
import { Search } from "@/components/Search";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { getOrganizationIdBySlug, getOrganizationTitle } from "@/data/user/organizations";
import { getOrganizationTitle } from "@/data/user/organizations";
import { getProjects } from "@/data/user/projects";
import {
organizationSlugParamSchema,
projectsfilterSchema,
organizationParamSchema,
projectsfilterSchema
} from "@/utils/zod-schemas/params";
import { FileText, Layers } from "lucide-react";
import type { Metadata } from 'next';
Expand All @@ -34,13 +34,12 @@ async function Projects({
}

export type DashboardProps = {
params: { organizationSlug: string };
params: { organizationId: string };
searchParams: unknown;
};

async function Dashboard({ params, searchParams }: DashboardProps) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug);
const { organizationId } = organizationParamSchema.parse(params);
const validatedSearchParams = projectsfilterSchema.parse(searchParams);

return (
Expand All @@ -62,7 +61,7 @@ async function Dashboard({ params, searchParams }: DashboardProps) {
<div className="flex items-center space-x-4">
<Search className="w-[200px]" placeholder="Search projects" />
<Button variant="secondary" size="sm" asChild>
<Link href={`/${organizationSlug}/projects`}>
<Link href={`/org/${organizationId}/projects`}>
<Layers className="mr-2 h-4 w-4" />
View all projects
</Link>
Expand All @@ -89,9 +88,13 @@ async function Dashboard({ params, searchParams }: DashboardProps) {
}

export async function generateMetadata({ params }: DashboardProps): Promise<Metadata> {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug);
const { organizationId } = organizationParamSchema.parse(params);
console.log('------------------------------------')
console.log('Params', params);
console.log('Organization id', organizationId);
console.log('------------------------------------')
const title = await getOrganizationTitle(organizationId);
console.log('Organization title', title);

return {
title: `Dashboard | ${title}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { PageHeading } from "@/components/PageHeading";
import { Pagination } from "@/components/Pagination";
import { Search } from "@/components/Search";
import { T } from "@/components/ui/Typography";
import {
getOrganizationIdBySlug
} from "@/data/user/organizations";
import { getProjects, getProjectsTotalCount } from "@/data/user/projects";
import {
organizationSlugParamSchema,
projectsfilterSchema,
organizationParamSchema,
projectsfilterSchema
} from "@/utils/zod-schemas/params";
import type { Metadata } from "next";
import { Suspense } from "react";
Expand Down Expand Up @@ -43,8 +40,7 @@ export default async function Page({
params,
searchParams,
}: DashboardProps) {
const { organizationSlug } = organizationSlugParamSchema.parse(params);
const organizationId = await getOrganizationIdBySlug(organizationSlug);
const { organizationId } = organizationParamSchema.parse(params);
const filters = projectsfilterSchema.parse(searchParams);

return (
Expand Down
Loading
Loading