diff --git a/src/app/feed/pages/HomePage.tsx b/src/app/feed/pages/HomePage.tsx index 5ce323d..910e1db 100644 --- a/src/app/feed/pages/HomePage.tsx +++ b/src/app/feed/pages/HomePage.tsx @@ -30,7 +30,7 @@ export default function HomePage({ postsService, mediaService }: HomePageProps) const { pages, setPages, loadNextPage } = useFeedViewModel(fetchPosts) const onCreatePost = useCallback( - async (content: string, files: { file: File; width: number; height: number }[]) => { + async (content: string, files: { file: File; width: number; height: number }[], isPublic: boolean) => { setIsSubmitting(true) if (user == null) throw new Error('Not logged in') try { @@ -46,7 +46,7 @@ export default function HomePage({ postsService, mediaService }: HomePageProps) } }), ) - const postId = await postsService.createNew(user.userId, content, media) + const postId = await postsService.createNew(user.userId, content, media, isPublic) const post = new Post(postId, content, media, Temporal.Now.instant(), user.username) setPages((pages) => [[post], ...pages]) } catch (error) { diff --git a/src/components/NewPostWidget.tsx b/src/components/NewPostWidget.tsx index 41b6920..4b5668d 100644 --- a/src/components/NewPostWidget.tsx +++ b/src/components/NewPostWidget.tsx @@ -4,7 +4,11 @@ import Button from './buttons/Button.tsx' import { openFileDialog } from '../utils/openFileDialog.ts' interface NewPostWidgetProps { - onSubmit: (content: string, media: { file: File; width: number; height: number }[]) => void + onSubmit: ( + content: string, + media: { file: File; width: number; height: number }[], + isPublic: boolean, + ) => void isSubmitting?: boolean } @@ -19,6 +23,7 @@ interface Attachment { export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPostWidgetProps) { const [content, setContent] = useState('') const [attachments, setAttachments] = useState([]) + const [isPublic, setIsPublic] = useState(false) const onContentInput = (value: string) => { setContent(value) @@ -39,7 +44,7 @@ export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPos return } - onSubmit(content, attachments) + onSubmit(content, attachments, isPublic) attachments.forEach(({ objectUrl }) => URL.revokeObjectURL(objectUrl)) setContent('') @@ -85,9 +90,21 @@ export default function NewPostWidget({ onSubmit, isSubmitting = false }: NewPos )}
- +
+ + +
diff --git a/src/index.css b/src/index.css index 85710ec..43d90ff 100644 --- a/src/index.css +++ b/src/index.css @@ -87,4 +87,21 @@ html { opacity: 50%; cursor: default; } + + .checkbox { + padding: var(--spacing-2) var(--spacing-4); + background: var(--color-primary-800); + color: var(--color-white); + cursor: pointer; + border-radius: var(--radius-md); + } + + .checkbox:hover { + background: var(--color-primary-700); + } + + .checkbox:disabled { + opacity: 50%; + cursor: default; + } } \ No newline at end of file