Skip to content

Commit

Permalink
feat: connect questions to video
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhil56x committed Sep 27, 2024
1 parent fb97511 commit 4ed5c36
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
13 changes: 5 additions & 8 deletions src/components/NewPostDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const NewPostDialog = () => {
setVideoId('');
setVideoTitle('');
router.push(`/question/${data.slug}`);
setTags([]);
setTags([]);
handleOnCloseClick();
},
onError: (error) => {
Expand Down Expand Up @@ -96,19 +96,16 @@ export const NewPostDialog = () => {
event.preventDefault();
const formData = new FormData(formRef.current as HTMLFormElement);
const tag = formData.get('tags')?.toString().trim().replace(/,+$/, '');

if (tag) {
setTags((prevTags) => [
...prevTags,
tag
]);
setTags((prevTags) => [...prevTags, tag]);
}
if (tagInputRef.current) {
tagInputRef.current.value = '';
}
}
};

const removeTag = (tag: string) => {
setTags(tags.filter((t) => t !== tag));
};
Expand Down Expand Up @@ -268,4 +265,4 @@ export const NewPostDialog = () => {
</AnimatePresence>
</Modal>
);
};
};
5 changes: 4 additions & 1 deletion src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export function Sidebar({

return (
<>
<Button onClick={() => setSidebarOpen((s) => !s)} className="w-fit gap-2 xl:absolute">
<Button
onClick={() => setSidebarOpen((s) => !s)}
className="w-fit gap-2 xl:absolute"
>
{sidebarOpen ? <X className="size-5" /> : <Menu className="size-5" />}
<span>{sidebarOpen ? 'Hide Contents' : 'Show Contents'}</span>
</Button>
Expand Down
12 changes: 7 additions & 5 deletions src/components/posts/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const PostCard: React.FC<IProps> = ({

const router = useRouter();

const [isPending, startTransition] = useTransition();
const [isPending, startTransition] = useTransition();

const { execute, fieldErrors } = useAction(createAnswer, {
onSuccess: () => {
Expand Down Expand Up @@ -207,10 +207,12 @@ const PostCard: React.FC<IProps> = ({
</p>
)}
</div>
<div className="flex items-center gap-2 sm:ml-auto sm:gap-2 md:ml-0 lg:ml-auto">
<Tag name={`lecture:${post.video.id}`} />
<Tag name={`${post.video.title}`} />
</div>
{post.video && (
<div className="flex items-center gap-2 sm:ml-auto sm:gap-2 md:ml-0 lg:ml-auto">
<Tag name={`lecture:${post.video.id}`} />
<Tag name={`${post.video.title}`} />
</div>
)}
</div>

{enableReply && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/posts/form/form-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ export const FormPostInput = forwardRef<HTMLInputElement, FormInputProps>(
},
);

FormPostInput.displayName = 'FormPostInput';
FormPostInput.displayName = 'FormPostInput';

0 comments on commit 4ed5c36

Please sign in to comment.