cornflour
Explore posts from serversTTCTheo's Typesafe Cult
•Created by cornflour on 3/14/2024 in #questions
Dynamic record with value type depending on key suffix
you mean if it is possible for me to change the final shape? at first i had it as nested instead of the weird suffix like this, but i think i ran into some trouble with the chart library :/ Maybe i can dig into deeper to see if it can work, but at this point i feel like its more effort than its worth since everything is working now (even if the
as "id"
and as const
are slightly annoying)
at this point i'm moreso curious about whether this can theoretically be done in TS than needing it for my actual task. I think i'll close the question for now9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 3/14/2024 in #questions
Dynamic record with value type depending on key suffix
there is no real
getId()
function, it's just an id from server response. In actuality, I needed 3 different type of key suffixes, the third one being _trend
for drawing the trendline. My code is something like this:
this is why i said I never had to put 2 _value
in 1 object at a time, since i used a for loop to add one entry to the record at a time. But i needed the as "id"
and as const
hack to add the trendline points to the list, which is annoying9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 3/14/2024 in #questions
Dynamic record with value type depending on key suffix
yeah it's rough since the id is a dynamic string, so i don't know them beforehand
but your response did allow me to get a bit farther by lying to TS:
for the code i was working at, this is sufficient because i apparently never had to put 2
_value
keys into 1 object at any time, but even then it was still a bit annoying with the as "id"
and as const
.9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 10/9/2023 in #questions
Button with 4 triangles at 4 corners
I ended up with the 4 div solution
for anyone else checking this and wanting some references, here is my code
one thing to note here is that the button color cannot have opacity with it, since the triangles have a few overlap with the main button
5 replies
TTCTheo's Typesafe Cult
•Created by Smadger on 7/11/2023 in #questions
Call TRPC from an api
this might help depending on what you need https://trpc.io/docs/server/server-side-calls
4 replies
TTCTheo's Typesafe Cult
•Created by Romain on 7/6/2023 in #questions
Do we need a fetcher like SWR with the t3 stack
trpc already wraps around tanstack query, so you don't need swr with it
6 replies
TTCTheo's Typesafe Cult
•Created by z on 6/26/2023 in #questions
NextJS "Module not found" error with "loading.tsx"?
how about cloning your repo again and try to run it from there?
13 replies
TTCTheo's Typesafe Cult
•Created by z on 6/26/2023 in #questions
NextJS "Module not found" error with "loading.tsx"?
i did have this issue too when i tried to delete a loading.tsx
but it seems to have fixed it when i deleted .next, so idk about your case
13 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 6/21/2023 in #questions
implement discord-like account switching
i'll check it out!
8 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 6/21/2023 in #questions
implement discord-like account switching
so im stuck at how to set it up such that i got the list of sessions (each having a jwt + maybe some other user info) from the accounts the user has signed in and the ability to swap between these sessions
i have only ever set up next auth to sign in and then sign out, so im kinda lost at how account switching would work
8 replies
TTCTheo's Typesafe Cult
•Created by Maj on 6/21/2023 in #questions
shadcn ui table component with dialog.
idk how it is messing up the table for you, but basically yeah you can use the
cell
props of the column in the column headers definition to say that the entries will have a dialog button at that cell
it would be sth similar to the row action
section in the shadcn data table docs: https://ui.shadcn.com/docs/components/data-table#row-actions
without knowing more about what you did and what issues you faced i cant really help in more details9 replies
TTCTheo's Typesafe Cult
•Created by Maj on 6/21/2023 in #questions
shadcn ui table component with dialog.
from my understanding, you want to make a cell in every row a button to open a dialog?
9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 6/21/2023 in #questions
implement discord-like account switching
bump
8 replies
TTCTheo's Typesafe Cult
•Created by Complexlity on 6/19/2023 in #questions
How to send cookies and headers in app dir
from my understanding, you are trying to take the header sent from the client to send to the remote server. If so, you can use the
cookies()
and headers()
methods from next/headers
to get cookies and headers respectively
related docs
https://nextjs.org/docs/app/api-reference/functions/headers#headers
https://nextjs.org/docs/app/api-reference/functions/cookies6 replies
TTCTheo's Typesafe Cult
•Created by 균어 on 6/18/2023 in #questions
How to get singular type on trpc query
try
(typeof serviceOrders.data)[number]
, i think that should work
from my understanding, your type there is an array, so to get the type of an item in the array its ArrayType[number]
9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 6/13/2023 in #questions
Websocket with Next appdir/RSC?
got it, tysm!
9 replies
TTCTheo's Typesafe Cult
•Created by cornflour on 6/13/2023 in #questions
Websocket with Next appdir/RSC?
so as far as the websocket part itself is concerned, its the same as before, and the change that the layout stuff can be server components?
9 replies
TTCTheo's Typesafe Cult
•Created by Ayato on 4/17/2023 in #questions
tRPC Mutation
The doc page for tRPC on ct3a does have a mutation example here
https://create.t3.gg/en/usage/trpc#inferring-errors
but perhaps having an actual section on mutation similar to query in that page might be a bit clearer for beginners?
i personally find the trpc doc for mutation pretty decently clear though; I didn't have trouble trying to figure that out: https://trpc.io/docs/reactjs/usemutation
7 replies
TTCTheo's Typesafe Cult
•Created by tropic on 4/20/2023 in #questions
Headless UI Stops Working when Adding addition elements to components
this div here that you have is staying on top of your nav bar, so you cant click on the nav items
a way that can fix it is to have the <header> tag have "relative z-10" to move it on top of the other one, making the button clickable again
and maybe removing the bg-white because it would look weird then
11 replies
TTCTheo's Typesafe Cult
•Created by tropic on 4/20/2023 in #questions
Headless UI Stops Working when Adding addition elements to components
is the repo private? I cannot access it
11 replies