diff --git a/config/tsconfig/nextjs.json b/config/tsconfig/nextjs.json index b047bb894..c81b2e54b 100644 --- a/config/tsconfig/nextjs.json +++ b/config/tsconfig/nextjs.json @@ -4,7 +4,7 @@ "extends": "./base.json", "compilerOptions": { "plugins": [{ "name": "next" }], - "target": "es5", + "target": "es2018", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, diff --git a/core/app/c/[communitySlug]/stages/manage/StagesContext.tsx b/core/app/c/[communitySlug]/stages/manage/StagesContext.tsx index 336bcfef1..b8b607ee9 100644 --- a/core/app/c/[communitySlug]/stages/manage/StagesContext.tsx +++ b/core/app/c/[communitySlug]/stages/manage/StagesContext.tsx @@ -253,7 +253,7 @@ export const StagesProvider = (props: StagesProviderProps) => { ); const fetchStages = useCallback(() => { - actions.revalidateStages(props.communityId); + actions.revalidateStages(); }, [props.communityId]); useEffect(() => { diff --git a/core/app/components/PubCRUD/PubCreateOld.tsx b/core/app/components/PubCRUD/PubCreateOld.tsx deleted file mode 100644 index e4e896768..000000000 --- a/core/app/components/PubCRUD/PubCreateOld.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import type { ExpressionBuilder, ExpressionWrapper } from "kysely"; - -import { Suspense } from "react"; -import dynamic from "next/dynamic"; -import { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/postgres"; - -import type { CommunitiesId } from "~/kysely/types/public/Communities"; -import type PublicSchema from "~/kysely/types/public/PublicSchema"; -import type { StagesId } from "~/kysely/types/public/Stages"; -import { db } from "~/kysely/database"; -import { autoCache } from "~/lib/server/cache/autoCache"; -import { SkeletonCard } from "../skeletons/SkeletonCard"; - -export type CreatePubProps = - | { - communityId: CommunitiesId; - stageId?: never; - } - | { - stageId: StagesId; - communityId?: never; - }; - -const getCommunityById = >( - eb: EB, - communityId: CommunitiesId | ExpressionWrapper -) => { - const query = eb.selectFrom("communities").select((eb) => [ - "communities.id", - jsonArrayFrom( - eb - .selectFrom("pub_types") - .select((eb) => [ - "pub_types.id", - "pub_types.name", - "pub_types.description", - jsonArrayFrom( - eb - .selectFrom("pub_fields") - .innerJoin("_PubFieldToPubType", "A", "pub_fields.id") - .select((eb) => [ - "pub_fields.id", - "pub_fields.name", - "pub_fields.pubFieldSchemaId", - "pub_fields.slug", - "pub_fields.name", - jsonObjectFrom( - eb - .selectFrom("PubFieldSchema") - .select([ - "PubFieldSchema.id", - "PubFieldSchema.namespace", - "PubFieldSchema.name", - "PubFieldSchema.schema", - ]) - .whereRef( - "PubFieldSchema.id", - "=", - eb.ref("pub_fields.pubFieldSchemaId") - ) - ).as("schema"), - ]) - .where("_PubFieldToPubType.B", "=", eb.ref("pub_types.id")) - ).as("fields"), - ]) - .whereRef("pub_types.community_id", "=", eb.ref("communities.id")) - ).as("pubTypes"), - jsonArrayFrom( - eb - .selectFrom("stages") - .select(["stages.id", "stages.name", "stages.order"]) - .orderBy("stages.order desc") - .where("stages.community_id", "=", communityId) - ).as("stages"), - ]); - - const completeQuery = - typeof communityId === "string" - ? query.where("communities.id", "=", communityId) - : query.whereRef("communities.id", "=", communityId); - - // return { qb: completeQuery }; - return completeQuery; //.executeTakeFirstOrThrow(); -}; - -const getStage = (stageId: StagesId) => - db - .selectFrom("stages") - .select((eb) => [ - "stages.id", - "stages.community_id", - "stages.name", - "stages.order", - jsonObjectFrom(getCommunityById(eb, eb.ref("stages.community_id"))).as("community"), - ]) - .where("stages.id", "=", stageId) - .executeTakeFirstOrThrow(); - -const PubCreateForm = dynamic( - async () => { - return import("./PubCreateForm").then((mod) => ({ - default: mod.PubCreateForm, - })); - }, - { ssr: false, loading: () => } -); - -export async function PubCreate({ communityId, stageId }: CreatePubProps) { - const query = stageId - ? getStage(stageId) - : getCommunityById(db, communityId).executeTakeFirstOrThrow(); - // // @ts-expect-error FIXME: I don't know how to fix this - // db, - // communityId - // ); - const result = await query; - - const { community, ...stage } = "community_id" in result ? result : { community: result }; - const currentStage = "id" in stage ? stage : null; - - if (!community) { - return null; - } - - return ( - <> - Loading...}> - - - - ); -} diff --git a/core/tsconfig.json b/core/tsconfig.json index 1fa45a301..db9c87a0c 100644 --- a/core/tsconfig.json +++ b/core/tsconfig.json @@ -2,6 +2,7 @@ "extends": "tsconfig/nextjs.json", "compilerOptions": { "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, "noErrorTruncation": true, "plugins": [ { @@ -20,6 +21,13 @@ "module": "CommonJS" } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + "instrumentation.node.mts", + "kysely/scripts/generateDatabaseObject.mts" + ], "exclude": ["node_modules"] }