-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Feat/preview post #418
Open
yurimutti
wants to merge
30
commits into
gitroomhq:main
Choose a base branch
from
yurimutti:feat/preview-post
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/preview post #418
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
45125b6
feat: creating preview route
yurimutti 155a3c6
feat: create preview page
yurimutti f1aff37
refactor: move error to same 404 component
yurimutti f3b5461
chore: remove undefined folder
yurimutti 2e308de
Merge branch 'main' into feat/preview-post
yurimutti 121bc43
fix: code scanning
yurimutti 1124562
Merge branch 'feat/preview-post' of github.com:yurimutti/postiz-app i…
yurimutti dbd57da
Merge branch 'main' into feat/preview-post
yurimutti e97c4c3
fix: eslint errors
yurimutti 9a6ac0c
refactor: remove logs
yurimutti e9cfd02
Merge branch 'main' into feat/preview-post
yurimutti 79d3a77
Merge branch 'main' into feat/preview-post
yurimutti ec2ba2e
Merge branch 'main' into feat/preview-post
yurimutti bf6e9fb
Merge branch 'main' into feat/preview-post
yurimutti 6bc51ba
Merge branch 'main' into feat/preview-post
yurimutti 03e321c
Merge branch 'main' into feat/preview-post
yurimutti d82d8b5
chore: exhaustive deps on preview fetch
yurimutti 288e145
refactor: moving data posts to variable
yurimutti f5a3aa3
Merge branch 'main' into feat/preview-post
yurimutti 9633ff9
refactor: add posts length validation
yurimutti 64880a8
Merge branch 'feat/preview-post' of github.com:yurimutti/postiz-app i…
yurimutti e151339
Merge branch 'main' into feat/preview-post
yurimutti 9933506
Merge branch 'main' into feat/preview-post
yurimutti 9714bc9
Merge branch 'main' into feat/preview-post
yurimutti 5eb129f
Merge branch 'main' into feat/preview-post
yurimutti 77bc611
Merge branch 'main' into feat/preview-post
yurimutti 2549de4
refactor: add new props
yurimutti 7ed62db
Merge branch 'main' into feat/preview-post
yurimutti d164960
Merge branch 'main' into feat/preview-post
egelhaus 40aa262
Merge branch 'main' into feat/preview-post
yurimutti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Preview } from "@gitroom/frontend/components/preview/preview"; | ||
import { isGeneralServerSide } from "@gitroom/helpers/utils/is.general.server.side"; | ||
import { Metadata } from "next"; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export const metadata: Metadata = { | ||
title: `${isGeneralServerSide() ? 'Postiz' : 'Gitroom'} Preview`, | ||
description: 'Make a preview link for your posts.', | ||
} | ||
|
||
export default async function Index({ params }: { params: { id: string } }) { | ||
return ( | ||
<Preview id={params.id} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use client'; | ||
|
||
import { GeneralPreviewComponent } from '@gitroom/frontend/components/launches/general.preview.component'; | ||
import { IntegrationContext } from '@gitroom/frontend/components/launches/helpers/use.integration'; | ||
import dayjs from 'dayjs'; | ||
import { useCallback } from 'react'; | ||
import useSWR from 'swr'; | ||
import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; | ||
import { LoadingComponent } from '../layout/loading'; | ||
|
||
interface PreviewProps { | ||
id: string; | ||
} | ||
|
||
export const Preview = ({ id }: PreviewProps) => { | ||
const fetch = useFetch(); | ||
|
||
const getPostsMarketplace = useCallback(async () => { | ||
return (await fetch(`/posts/${id}`)).json(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [id]); | ||
yurimutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { data, isLoading, error } = useSWR( | ||
`/posts/${id}`, | ||
getPostsMarketplace | ||
); | ||
|
||
if (isLoading) return <LoadingComponent />; | ||
|
||
if (!data?.posts || error) | ||
return ( | ||
<main className="flex mx-auto"> | ||
<h1> | ||
{!data?.posts ? 'No post founded.' : 'Oops! Something went wrong.'}{' '} | ||
</h1> | ||
</main> | ||
); | ||
|
||
const post = data?.posts?.[0]; | ||
if (!post) return null; | ||
|
||
return ( | ||
<IntegrationContext.Provider | ||
value={{ | ||
date: dayjs(), | ||
integration: post.integration, | ||
value: [ | ||
{ | ||
content: post.content, | ||
id: post.id, | ||
image: post.image, | ||
}, | ||
], | ||
}} | ||
> | ||
<div className="flex mx-auto"> | ||
<GeneralPreviewComponent /> | ||
</div> | ||
</IntegrationContext.Provider> | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / ESLint
verifies the list of dependencies for Hooks like useEffect and similar Warning