0:00 So to render the profile tabs, let's scroll down, and in the same 0:04 div where we have the profile header, let's go ahead and now 0:07 introduce the profile tabs component. 0:12 This will then need to be supplied all of the props we expect. 0:15 So let's start with the user posts. 0:17 So let's go ahead and wire this up to use our posts router 0:21 query to fetch our posts. Now, one thing with our 0:25 existing posts query, if we check our back end 0:28 and look inside of the 0:29 posts router, well, our find all method for 0:33 fetching posts, currently, it doesn't take in any 0:36 input to filter by certain properties, like in this case, 0:40 the user ID. 0:43 So in order to enhance this, let's go ahead and update our 0:46 post schema 0:48 in our tRPC package. We'll create a 0:52 new 0:53 find all posts schema, 0:56 and this will be a new Zod object where we can supply, in 1:00 this case, for example, the user ID, which in our application we 1:04 know is a string value. So let's set this as 1:08 a string. We'll also set this as optional because 1:12 the user 1:12 doesn't have to supply a filter. But now if they do, we can go 1:16 back to the post router and update find all to take 1:20 in an optional input, which will be 1:23 our find all post schema. 1:26 And now at this point, we can 1:29 pull this off with our typical input decorator and get the 1:33 find all 1:36 posts schema. 1:38 Now, if we also 1:40 want a type for this, we can add it to our 1:44 tRPC schema and export the type find all 1:48 post schema 1:50 and change it to find all post input and use our 1:54 pattern of inferring using Zod to infer the 1:58 type from the 2:00 schema we have. 2:02 Now we can use this type find all post input.
The rest of the transcript is for members.
Sign in