Skip to content

Commit c1534db

Browse files
authored
Merge pull request #119 from techulus/feat/react-sdk
feat: React SDK
2 parents 8b89672 + 42e2331 commit c1534db

File tree

142 files changed

+888
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+888
-211
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ yarn-error.log*
4444

4545
# Sentry Auth Token
4646
.sentryclirc
47+
48+
# packages
49+
dist/
50+
node_modules/

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@changes-page/docs",
2+
"name": "@changespage/docs",
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {

apps/page/components/footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IPageSettings } from "@changes-page/supabase/types/page";
1+
import { IPageSettings } from "@changespage/supabase/types/page";
22
import Image from "next/image";
33
import { useEffect } from "react";
44
import { PageRoadmap } from "../lib/data";

apps/page/components/page-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IPage, IPageSettings } from "@changes-page/supabase/types/page";
1+
import { IPage, IPageSettings } from "@changespage/supabase/types/page";
22
import { Menu } from "@headlessui/react";
33
import { ChevronDownIcon } from "@heroicons/react/outline";
44
import classNames from "classnames";

apps/page/components/post.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { PostType } from "@changes-page/supabase/types/page";
2-
import { PostTypeBadge } from "@changes-page/ui";
1+
import { PostType } from "@changespage/supabase/types/page";
2+
import { PostTypeBadge } from "@changespage/ui";
33
import classNames from "classnames";
44
import dynamic from "next/dynamic";
55
import Image from "next/image";
@@ -14,7 +14,7 @@ import { IPostPublicData } from "../lib/data";
1414
import Reactions from "./reactions";
1515

1616
const PostDateTime = dynamic(
17-
() => import("@changes-page/ui").then((mod) => mod.PostDateTime),
17+
() => import("@changespage/ui").then((mod) => mod.PostDateTime),
1818
{
1919
ssr: false,
2020
}

apps/page/components/reactions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IReactions } from "@changes-page/supabase/types/page";
1+
import { IReactions } from "@changespage/supabase/types/page";
22
import { Transition } from "@headlessui/react";
33
import classNames from "classnames";
44
import { useCallback, useEffect, useState } from "react";

apps/page/components/seo-tags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
IPage,
33
IPageSettings,
44
PageTypeToLabel,
5-
} from "@changes-page/supabase/types/page";
5+
} from "@changespage/supabase/types/page";
66
import { NextSeo } from "next-seo";
77
import Head from "next/head";
88
import { useMemo } from "react";

apps/page/components/subscribe-prompt.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { IPage, IPageSettings } from "@changes-page/supabase/types/page";
2-
import { Spinner } from "@changes-page/ui";
1+
import { IPage, IPageSettings } from "@changespage/supabase/types/page";
2+
import { Spinner } from "@changespage/ui";
33
import {
44
BellIcon,
55
CheckCircleIcon,

apps/page/lib/data.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { supabaseAdmin } from "@changes-page/supabase/admin";
2-
import { Database } from "@changes-page/supabase/types";
1+
import { supabaseAdmin } from "@changespage/supabase/admin";
2+
import { Database } from "@changespage/supabase/types";
33
import {
44
IPage,
55
IPageSettings,
66
IPost,
77
IRoadmapBoard,
88
IRoadmapColumn,
99
IRoadmapItem,
10-
} from "@changes-page/supabase/types/page";
10+
} from "@changespage/supabase/types/page";
1111
import { sanitizeCss } from "./css";
1212

1313
const PAGINATION_LIMIT = 50;
@@ -441,9 +441,37 @@ async function getRoadmapBySlug(
441441
return { board, columns, items };
442442
}
443443

444+
async function fetchPostsWithPagination(
445+
pageId: string,
446+
{ limit, offset }: { limit?: number; offset?: number }
447+
): Promise<{ posts: IPost[]; postsCount: number }> {
448+
const effectiveLimit = Math.min(limit ?? PAGINATION_LIMIT, PAGINATION_LIMIT);
449+
const effectiveOffset = offset ?? 0;
450+
451+
const {
452+
data: posts,
453+
count: postsCount,
454+
error: postsError,
455+
} = await supabaseAdmin
456+
.from("posts")
457+
.select(postSelectParams, { count: "exact" })
458+
.eq("page_id", String(pageId))
459+
.eq("status", "published")
460+
.range(effectiveOffset, effectiveOffset + effectiveLimit - 1)
461+
.order("publication_date", { ascending: false });
462+
463+
if (postsError) {
464+
console.error("Fetch post error", postsError);
465+
throw new Error("Failed to fetch posts");
466+
}
467+
468+
return { posts: (posts ?? []) as Array<IPost>, postsCount: postsCount ?? 0 };
469+
}
470+
444471
export {
445472
fetchPostById,
446473
fetchPosts,
474+
fetchPostsWithPagination,
447475
fetchRenderData,
448476
getRoadmapBySlug,
449477
PAGINATION_LIMIT,

apps/page/lib/notifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { v4 } from "uuid";
2-
import { IPageEmailSubscriber } from "@changes-page/supabase/types/page";
3-
import { supabaseAdmin } from "@changes-page/supabase/admin";
2+
import { IPageEmailSubscriber } from "@changespage/supabase/types/page";
3+
import { supabaseAdmin } from "@changespage/supabase/admin";
44

55
async function subscribeViaEmail(
66
pageId: string,

0 commit comments

Comments
 (0)