batata
batata
TTCTheo's Typesafe Cult
Created by batata on 10/2/2023 in #questions
HTTP requests in next 13
I sending http requests in a server component and i want to inspect these requests, but they arent showing up in network tab in the browser nor in the terminal. How do i inspect them?
2 replies
TTCTheo's Typesafe Cult
Created by batata on 9/28/2023 in #questions
Filtering and search in RSC
I'm trying to implement filtering and searching in server components but its kinda slow, the way im doing it is i redirect to a new url with searchParams and then filter the data in the page.tsx which is a server component, Here's the code: thats from the child client component
const searchParams = new URLSearchParams(filtersParams);
router.replace(`/ticketing?${searchParams}`);
const searchParams = new URLSearchParams(filtersParams);
router.replace(`/ticketing?${searchParams}`);
and this is the page.tsx
{tickets.watcherTickets
.filter((ticket) => {
if (
ticket.currentStage?.stageAssignedTo !== user.userID &&
(!searchParams.type ||
ticketTemplates.find((template) => template.ticketTemplateID === ticket.ticketTemplateID)
?.templateTitle === searchParams.type) &&
(!searchParams.status || ticket.currentStage?.stageStatus === searchParams.status) &&
(!searchParams.dateFrom ||
isWithinInterval(parseISO(ticket.currentStage?.stageAssignedDate), {
start: parseISO(searchParams.dateFrom),
end: parseISO(searchParams.dateTo),
}))
) {
return true; // Include this ticket in the result
}
return false; // Exclude this ticket from the result
})
{tickets.watcherTickets
.filter((ticket) => {
if (
ticket.currentStage?.stageAssignedTo !== user.userID &&
(!searchParams.type ||
ticketTemplates.find((template) => template.ticketTemplateID === ticket.ticketTemplateID)
?.templateTitle === searchParams.type) &&
(!searchParams.status || ticket.currentStage?.stageStatus === searchParams.status) &&
(!searchParams.dateFrom ||
isWithinInterval(parseISO(ticket.currentStage?.stageAssignedDate), {
start: parseISO(searchParams.dateFrom),
end: parseISO(searchParams.dateTo),
}))
) {
return true; // Include this ticket in the result
}
return false; // Exclude this ticket from the result
})
is there another way to do it? maybe my internet is slow so its taking couple of seconds to go to the new url
1 replies
TTCTheo's Typesafe Cult
Created by batata on 8/21/2023 in #questions
next 13 cookies
No description
2 replies
TTCTheo's Typesafe Cult
Created by batata on 7/8/2023 in #questions
Fetching only once
so i have an authToken being stored in the local storage and i want to send it in a POST request each time the user opens the site to check if its still valid, but how do i make the POST request only fire once when the website first loads, that way i know if the user is authenticated or not and dont have to fetch it again while they are using the app. Im using next 13 with the app dir
4 replies
TTCTheo's Typesafe Cult
Created by batata on 2/26/2023 in #questions
Next Image
2 replies
TTCTheo's Typesafe Cult
Created by batata on 2/16/2023 in #questions
Next Image Height
14 replies
TTCTheo's Typesafe Cult
Created by batata on 2/11/2023 in #questions
Deployment on AWS
Hello, I want to deploy my t3 app with a postgres db on aws using the free tier. Is dockerizing the project and using ECS the easiest option?
9 replies
TTCTheo's Typesafe Cult
Created by batata on 2/4/2023 in #questions
tRPC in getServerSideProps
this is the code im writing in the getServerSideProps
export const getServerSideProps = async (context: any) => {
const session = await getSession(context)

const { id: shopId } = context.query

const shop = trpc.shops.getById.useQuery(shopId)

if (!shop) {
return {
redirect: {
permanent: false,
destination: `api/auth/signin`,
},
}
}
export const getServerSideProps = async (context: any) => {
const session = await getSession(context)

const { id: shopId } = context.query

const shop = trpc.shops.getById.useQuery(shopId)

if (!shop) {
return {
redirect: {
permanent: false,
destination: `api/auth/signin`,
},
}
}
javascript getting this error "TypeError: Cannot read properties of null (reading 'useContext')" I enabled ssr in the utils/trpc.ts file, still same error
9 replies
TTCTheo's Typesafe Cult
Created by batata on 2/3/2023 in #questions
trpc useQuery fetch on demand
const [query, setQuery] = useState<string>('')
const [suggestions, setSuggestions] = useState<Shop[] | null>()

const { error, data, refetch } = trpc.shops.getByName.useQuery(query)

useEffect(() => {
const getData = setTimeout(() => {
refetch()
setSuggestions(data)
}, 500)
return () => clearTimeout(getData)
}, [query])
const [query, setQuery] = useState<string>('')
const [suggestions, setSuggestions] = useState<Shop[] | null>()

const { error, data, refetch } = trpc.shops.getByName.useQuery(query)

useEffect(() => {
const getData = setTimeout(() => {
refetch()
setSuggestions(data)
}, 500)
return () => clearTimeout(getData)
}, [query])
javascript so in this code the useQuery is firing everytime query changes, i dont want that, i just want to fetch the data in the getdata function. Is there a way to do it?
3 replies
TTCTheo's Typesafe Cult
Created by batata on 1/22/2023 in #questions
Wait for useQuery result
const favShop = trpc.favorite.getById.useQuery({
userId: session.data?.user?.id,
shopId: coffeeShop.id,
})

const [favorite, setFavorite] = useState(
favShop.data?.length !== 0 && favShop.data !== undefined ? true : false
)
const favShop = trpc.favorite.getById.useQuery({
userId: session.data?.user?.id,
shopId: coffeeShop.id,
})

const [favorite, setFavorite] = useState(
favShop.data?.length !== 0 && favShop.data !== undefined ? true : false
)
so im checking on load if the current shop is a favourite shop or not, but the favShop is undefined at load then you get the result, since i cant use async await on it, how do i wait for the result so i can use it in the useState
19 replies