fix(dashboard): broken af

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-11-20 14:19:48 +01:00
parent cd16ac878d
commit 9c8badd68d
7 changed files with 81 additions and 12 deletions

View File

@@ -13,14 +13,14 @@ import SideEffects from './side-effects';
interface AppLayoutProps { interface AppLayoutProps {
children: React.ReactNode; children: React.ReactNode;
params: { params: {
organizationId: string; organizationSlug: string;
projectId: string; projectId: string;
}; };
} }
export default async function AppLayout({ export default async function AppLayout({
children, children,
params: { organizationId, projectId }, params: { organizationSlug: organizationId, projectId },
}: AppLayoutProps) { }: AppLayoutProps) {
const [organizations, projects, dashboards] = await Promise.all([ const [organizations, projects, dashboards] = await Promise.all([
getCurrentOrganizations(), getCurrentOrganizations(),

View File

@@ -6,10 +6,10 @@ import { getInvites, getProjectsByOrganizationId } from '@openpanel/db';
import CreateInvite from './create-invite'; import CreateInvite from './create-invite';
interface Props { interface Props {
organizationId: string; organizationSlug: string;
} }
const InvitesServer = async ({ organizationId }: Props) => { const InvitesServer = async ({ organizationSlug: organizationId }: Props) => {
const [invites, projects] = await Promise.all([ const [invites, projects] = await Promise.all([
getInvites(organizationId), getInvites(organizationId),
getProjectsByOrganizationId(organizationId), getProjectsByOrganizationId(organizationId),

View File

@@ -3,10 +3,10 @@ import { MembersTable } from '@/components/settings/members';
import { getMembers, getProjectsByOrganizationId } from '@openpanel/db'; import { getMembers, getProjectsByOrganizationId } from '@openpanel/db';
interface Props { interface Props {
organizationId: string; organizationSlug: string;
} }
const MembersServer = async ({ organizationId }: Props) => { const MembersServer = async ({ organizationSlug: organizationId }: Props) => {
const [members, projects] = await Promise.all([ const [members, projects] = await Promise.all([
getMembers(organizationId), getMembers(organizationId),
getProjectsByOrganizationId(organizationId), getProjectsByOrganizationId(organizationId),

View File

@@ -14,13 +14,13 @@ import MembersServer from './members';
interface PageProps { interface PageProps {
params: { params: {
organizationId: string; organizationSlug: string;
}; };
searchParams: Record<string, string>; searchParams: Record<string, string>;
} }
export default async function Page({ export default async function Page({
params: { organizationId }, params: { organizationSlug: organizationId },
searchParams, searchParams,
}: PageProps) { }: PageProps) {
const tab = parseAsStringEnum(['org', 'members', 'invites']) const tab = parseAsStringEnum(['org', 'members', 'invites'])

View File

@@ -9,11 +9,13 @@ import ListProjects from './list-projects';
interface PageProps { interface PageProps {
params: { params: {
organizationId: string; organizationSlug: string;
}; };
} }
export default async function Page({ params: { organizationId } }: PageProps) { export default async function Page({
params: { organizationSlug: organizationId },
}: PageProps) {
const [projects, clients] = await Promise.all([ const [projects, clients] = await Promise.all([
getProjectsByOrganizationId(organizationId), getProjectsByOrganizationId(organizationId),
getClientsByOrganizationId(organizationId), getClientsByOrganizationId(organizationId),

View File

@@ -8,17 +8,20 @@ import { getCurrentOrganizations, getCurrentProjects } from '@openpanel/db';
interface PageProps { interface PageProps {
params: { params: {
organizationId: string; organizationSlug: string;
}; };
} }
export default async function Page({ params: { organizationId } }: PageProps) { export default async function Page({
params: { organizationSlug: organizationId },
}: PageProps) {
const [organizations, projects] = await Promise.all([ const [organizations, projects] = await Promise.all([
getCurrentOrganizations(), getCurrentOrganizations(),
getCurrentProjects(organizationId), getCurrentProjects(organizationId),
]); ]);
const organization = organizations.find((org) => org.id === organizationId); const organization = organizations.find((org) => org.id === organizationId);
console.log(organizations, organizationId, projects);
if (!organization) { if (!organization) {
return ( return (

View File

@@ -0,0 +1,64 @@
/*
Warnings:
- You are about to drop the column `organizationSlug` on the `clients` table. All the data in the column will be lost.
- You are about to drop the column `organizationSlug` on the `dashboards` table. All the data in the column will be lost.
- You are about to drop the column `organizationSlug` on the `project_access` table. All the data in the column will be lost.
- You are about to drop the column `organizationSlug` on the `projects` table. All the data in the column will be lost.
- You are about to drop the column `organizationSlug` on the `shares` table. All the data in the column will be lost.
- Made the column `organizationId` on table `clients` required. This step will fail if there are existing NULL values in that column.
- Made the column `organizationId` on table `dashboards` required. This step will fail if there are existing NULL values in that column.
- Made the column `organizationId` on table `project_access` required. This step will fail if there are existing NULL values in that column.
- Made the column `organizationId` on table `projects` required. This step will fail if there are existing NULL values in that column.
- Made the column `organizationId` on table `shares` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "clients" DROP CONSTRAINT "clients_organizationId_fkey";
-- DropForeignKey
ALTER TABLE "dashboards" DROP CONSTRAINT "dashboards_organizationId_fkey";
-- DropForeignKey
ALTER TABLE "project_access" DROP CONSTRAINT "project_access_organizationId_fkey";
-- DropForeignKey
ALTER TABLE "projects" DROP CONSTRAINT "projects_organizationId_fkey";
-- DropForeignKey
ALTER TABLE "shares" DROP CONSTRAINT "shares_organizationId_fkey";
-- AlterTable
ALTER TABLE "clients" DROP COLUMN "organizationSlug",
ALTER COLUMN "organizationId" SET NOT NULL;
-- AlterTable
ALTER TABLE "dashboards" DROP COLUMN "organizationSlug",
ALTER COLUMN "organizationId" SET NOT NULL;
-- AlterTable
ALTER TABLE "project_access" DROP COLUMN "organizationSlug",
ALTER COLUMN "organizationId" SET NOT NULL;
-- AlterTable
ALTER TABLE "projects" DROP COLUMN "organizationSlug",
ALTER COLUMN "organizationId" SET NOT NULL;
-- AlterTable
ALTER TABLE "shares" DROP COLUMN "organizationSlug",
ALTER COLUMN "organizationId" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "projects" ADD CONSTRAINT "projects_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "project_access" ADD CONSTRAINT "project_access_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "clients" ADD CONSTRAINT "clients_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "dashboards" ADD CONSTRAINT "dashboards_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "shares" ADD CONSTRAINT "shares_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;