Skip to content

Commit 0964043

Browse files
authored
Use updated endpoint for page feedbacks (#2548)
1 parent e9b31a5 commit 0964043

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

packages/gitbook/src/components/PageAside/PageAside.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ export function PageAside(props: {
130130
>
131131
{withPageFeedback ? (
132132
<React.Suspense fallback={null}>
133-
<PageFeedbackForm
134-
spaceId={space.id}
135-
pageId={page.id}
136-
className={tcls('mt-2')}
137-
/>
133+
<PageFeedbackForm pageId={page.id} className={tcls('mt-2')} />
138134
</React.Suspense>
139135
) : null}
140136
{customization.git.showEditLink && space.gitSync?.url && page.git ? (

packages/gitbook/src/components/PageBody/PageBody.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ export function PageBody(props: {
141141
</p>
142142
) : null}
143143
{withPageFeedback ? (
144-
<PageFeedbackForm
145-
orientation="horizontal"
146-
spaceId={space.id}
147-
pageId={page.id}
148-
/>
144+
<PageFeedbackForm orientation="horizontal" pageId={page.id} />
149145
) : null}
150146
</div>
151147
</main>

packages/gitbook/src/components/PageFeedback/PageFeedbackForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ import { postPageFeedback } from './server-actions';
1515
*/
1616
export function PageFeedbackForm(props: {
1717
orientation?: 'horizontal' | 'vertical';
18-
spaceId: string;
1918
pageId: string;
2019
className?: string;
2120
}) {
22-
const { orientation = 'vertical', spaceId, pageId, className } = props;
21+
const { orientation = 'vertical', pageId, className } = props;
2322
const languages = useLanguage();
2423
const [submitted, setSubmitted] = React.useState(false);
2524

2625
const onSubmit = async (rating: PageFeedbackRating) => {
2726
setSubmitted(true);
2827
const visitorId = await getVisitorId();
29-
await postPageFeedback({ spaceId, pageId, visitorId, rating });
28+
await postPageFeedback({ pageId, visitorId, rating });
3029
};
3130

3231
return (
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
'use server';
22

33
import { PageFeedbackRating } from '@gitbook/api';
4+
import { assert } from 'ts-essentials';
45

56
import { api } from '@/lib/api';
7+
import { getSiteContentPointer } from '@/lib/pointer';
68

79
export async function postPageFeedback(args: {
8-
spaceId: string;
910
pageId: string;
1011
visitorId: string;
1112
rating: PageFeedbackRating;
1213
}) {
13-
await api().spaces.createPageFeedback(args.spaceId, args.pageId, args.visitorId, {
14-
rating: args.rating,
15-
});
14+
const { organizationId, siteId, siteSpaceId } = getSiteContentPointer();
15+
16+
assert(
17+
siteSpaceId,
18+
`No siteSpaceId in pointer. organizationId: ${organizationId}, siteId: ${siteId}, pageId: ${args.pageId}`,
19+
);
20+
21+
await api().orgs.createSitesPageFeedback(
22+
organizationId,
23+
siteId,
24+
siteSpaceId,
25+
args.pageId,
26+
args.visitorId,
27+
{
28+
rating: args.rating,
29+
},
30+
);
1631
}

0 commit comments

Comments
 (0)