buttons
This commit is contained in:
parent
abd7c2f073
commit
384da1e832
18 changed files with 150 additions and 116 deletions
|
@ -5,7 +5,8 @@ import { useParams } from 'react-router-dom'
|
|||
import SingleColumnLayout from '../../../layouts/SingleColumnLayout.tsx'
|
||||
import NavBar from '../../../components/NavBar.tsx'
|
||||
import { useFeedViewModel } from '../components/FeedView.ts'
|
||||
import NavLinkButton from '../../../components/NavLinkButton.tsx'
|
||||
import NavButton from '../../../components/buttons/NavButton.tsx'
|
||||
import AuthNavButtons from '../../auth/components/AuthNavButtons.tsx'
|
||||
|
||||
interface AuthorPageParams {
|
||||
postsService: PostsService
|
||||
|
@ -27,8 +28,8 @@ export default function AuthorPage({ postsService }: AuthorPageParams) {
|
|||
<SingleColumnLayout
|
||||
navbar={
|
||||
<NavBar>
|
||||
<NavLinkButton to={'/'}>home</NavLinkButton>
|
||||
<NavLinkButton to="/logout">logout</NavLinkButton>
|
||||
<NavButton to={'/'}>home</NavButton>
|
||||
<AuthNavButtons />
|
||||
</NavBar>
|
||||
}
|
||||
>
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Post } from '../posts/posts.ts'
|
|||
import { Temporal } from '@js-temporal/polyfill'
|
||||
import SingleColumnLayout from '../../../layouts/SingleColumnLayout.tsx'
|
||||
import NavBar from '../../../components/NavBar.tsx'
|
||||
import NavLinkButton from '../../../components/NavLinkButton.tsx'
|
||||
import AuthNavButtons from '../../auth/components/AuthNavButtons.tsx'
|
||||
|
||||
interface HomePageProps {
|
||||
postsService: PostsService
|
||||
|
@ -18,7 +18,6 @@ interface HomePageProps {
|
|||
|
||||
export default function HomePage({ postsService, mediaService }: HomePageProps) {
|
||||
const { user } = useUser()
|
||||
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
const fetchPosts = useCallback(
|
||||
|
@ -59,16 +58,18 @@ export default function HomePage({ postsService, mediaService }: HomePageProps)
|
|||
[mediaService, postsService, setPages, user],
|
||||
)
|
||||
|
||||
const isLoggedIn = user != null
|
||||
|
||||
return (
|
||||
<SingleColumnLayout
|
||||
navbar={
|
||||
<NavBar>
|
||||
<NavLinkButton to="/logout">logout</NavLinkButton>
|
||||
<AuthNavButtons />
|
||||
</NavBar>
|
||||
}
|
||||
>
|
||||
<main className={`w-full max-w-3xl mx-auto`}>
|
||||
<NewPostWidget onSubmit={onCreatePost} isSubmitting={isSubmitting} />
|
||||
{isLoggedIn && <NewPostWidget onSubmit={onCreatePost} isSubmitting={isSubmitting} />}
|
||||
<FeedView pages={pages} onLoadMore={loadNextPage} />
|
||||
</main>
|
||||
</SingleColumnLayout>
|
||||
|
|
|
@ -4,7 +4,12 @@ import client from '../../api/client.ts'
|
|||
export class PostsService {
|
||||
constructor() {}
|
||||
|
||||
async createNew(authorId: string, content: string, media: CreatePostMedia[]): Promise<string> {
|
||||
async createNew(
|
||||
authorId: string,
|
||||
content: string,
|
||||
media: CreatePostMedia[],
|
||||
isPublic: boolean,
|
||||
): Promise<string> {
|
||||
const response = await client.POST('/posts', {
|
||||
body: {
|
||||
authorId,
|
||||
|
@ -12,6 +17,7 @@ export class PostsService {
|
|||
media: media.map((m) => {
|
||||
return { ...m, type: null, url: m.url.toString() }
|
||||
}),
|
||||
isPublic,
|
||||
},
|
||||
credentials: 'include',
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue