MCPcopy Create free account
hub / github.com/adrianhajdin/threads / PostThread

Function PostThread

components/forms/PostThread.tsx:27–80  ·  view source on GitHub ↗
({ userId }: Props)

Source from the content-addressed store, hash-verified

25}
26
27function PostThread({ userId }: Props) {
28 const router = useRouter();
29 const pathname = usePathname();
30
31 const { organization } = useOrganization();
32
33 const form = useForm<z.infer<typeof ThreadValidation>>({
34 resolver: zodResolver(ThreadValidation),
35 defaultValues: {
36 thread: "",
37 accountId: userId,
38 },
39 });
40
41 const onSubmit = async (values: z.infer<typeof ThreadValidation>) => {
42 await createThread({
43 text: values.thread,
44 author: userId,
45 communityId: organization ? organization.id : null,
46 path: pathname,
47 });
48
49 router.push("/");
50 };
51
52 return (
53 <Form {...form}>
54 <form
55 className='mt-10 flex flex-col justify-start gap-10'
56 onSubmit={form.handleSubmit(onSubmit)}
57 >
58 <FormField
59 control={form.control}
60 name='thread'
61 render={({ field }) => (
62 <FormItem className='flex w-full flex-col gap-3'>
63 <FormLabel className='text-base-semibold text-light-2'>
64 Content
65 </FormLabel>
66 <FormControl className='no-focus border border-dark-4 bg-dark-3 text-light-1'>
67 <Textarea rows={15} {...field} />
68 </FormControl>
69 <FormMessage />
70 </FormItem>
71 )}
72 />
73
74 <Button type='submit' className='bg-primary-500'>
75 Post Thread
76 </Button>
77 </form>
78 </Form>
79 );
80}
81
82export default PostThread;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…