thevalorised
thevalorised
TTCTheo's Typesafe Cult
Created by lecookie on 8/11/2023 in #questions
Not get duplicates
I'm not really sure what you want. Please reword your question to be more clear. You might also wanna check upsert. https://www.prisma.io/docs/concepts/components/prisma-client/crud#update-or-create-records
3 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 8/2/2023 in #questions
Host T3 app on a VPS
Well it was more work than necessary and I've probably left a whole lot security vulnerabilities but I managed to host it. Wondering if docker was necessary
6 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 8/2/2023 in #questions
Host T3 app on a VPS
Following t3 docs crashes at docker build at collecting page info.
6 replies
TTCTheo's Typesafe Cult
Created by lil_bixbyte on 7/28/2023 in #questions
T3 Stack Tutorial - Posts won't retain
We might need to see the implementation of the router that calls posts.getAll and how it is called on the frontend but it can simply be a db mismatch issue. Make sure you have your schema file right, sync the db and generate types with npx prisma db push, and check if data actually exists on db with npx prisma studio
98 replies
TTCTheo's Typesafe Cult
Created by maskmonarch on 7/26/2023 in #questions
React not updating the attribute for an HTML element
I jerry rigged a small test using a code I yanked from stackoverflow. Seems to be working fine in prod as well, at least on my machine. Hope it helps.
import { useEffect, useState } from "react";

export default function Home() {
const size = useWindowSize();
return (
<main className="flex text-white font-semibold text-3xl min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c]">
{size.width > 1200 ? ("Search Items") : ("Search")}
</main>
);
}

function useWindowSize() {
const [windowSize, setWindowSize] = useState<{ width: number; height: number }>({
width: 0,
height: 0,
});
useEffect(() => {
function handleResize() {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
}
window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);
return windowSize;
}
import { useEffect, useState } from "react";

export default function Home() {
const size = useWindowSize();
return (
<main className="flex text-white font-semibold text-3xl min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c]">
{size.width > 1200 ? ("Search Items") : ("Search")}
</main>
);
}

function useWindowSize() {
const [windowSize, setWindowSize] = useState<{ width: number; height: number }>({
width: 0,
height: 0,
});
useEffect(() => {
function handleResize() {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
}
window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);
return windowSize;
}
25 replies
TTCTheo's Typesafe Cult
Created by Daniel K on 7/25/2023 in #questions
Where to store pictures? Gallery Page
I don't know what you are using vite with but if react: https://www.npmjs.com/package/@uploadthing/react
9 replies
TTCTheo's Typesafe Cult
Created by Daniel K on 7/25/2023 in #questions
Where to store pictures? Gallery Page
There is two part to its api. Signing and uploading. Signing is optional but recommended for security and it is an api point you create. Rest is just a http post request. It gives you the option to either use their own pre-built widgets or you can handle all of the file operations and call the api yourself. I have a backend for signing but upload happens on client side.
9 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/25/2023 in #questions
SQL vs NO-SQL
Data is structured, typical search, little to none experince with nsoql
9 replies
TTCTheo's Typesafe Cult
Created by Daniel K on 7/25/2023 in #questions
Where to store pictures? Gallery Page
I recently used cloudinary for such an application since I was well below free tier quota and it got some helper components for next. You just need to look up how to create a signing api and then you can just upload it and store the image id / url in a db.
9 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/19/2023 in #questions
How to wait for useState to finish before setting useRef value?
They are different forms but that's a neat feature
11 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/19/2023 in #questions
How to wait for useState to finish before setting useRef value?
I thought js was deep copying strings when we did that. I have no idea where I got that notion. That's good to know
11 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/19/2023 in #questions
How to wait for useState to finish before setting useRef value?
That's what I feared. I wished there was a way to avoid copying more memory. Thank you @Vincent !
11 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/17/2023 in #questions
Fetching Data on the Server
Follow up question if any body knows a way. Since I use this on a nav bar it is imported across many pages. Can I store and revalidate this date on server and use it in my nav bar component without having to use getStaticProps in every page that nav bar is imported?
8 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/17/2023 in #questions
Fetching Data on the Server
Thanks @uwucup that is exactly what I wanted combined with revalidation on mutate.
8 replies
TTCTheo's Typesafe Cult
Created by machina on 7/17/2023 in #questions
Best sources for UI inspiration?
I mostly use dribbble.com
5 replies
TTCTheo's Typesafe Cult
Created by Luc Ledo on 7/17/2023 in #questions
Intercepting Modal Cause Jump To Bottom Of Page
Router may be causing a reload. Try shallow routing. Syntax should be
router.push("link", undefined, {shallow: true})
router.push("link", undefined, {shallow: true})
4 replies
TTCTheo's Typesafe Cult
Created by bakdaddy on 7/12/2023 in #questions
TS Unchecked Indexed Access
since res[i] is an object you can create another reference to it and check it with an if statement like
const refToInner = res[i];
if(refToInner) {
refToInner[0] = i;
}
const refToInner = res[i];
if(refToInner) {
refToInner[0] = i;
}
But I would recommend just pushing the values to the array instead of setting the items.
const res: number[][] = [];
for (let i = 0; i < 10; ++i){
res.push([i])
}
const res: number[][] = [];
for (let i = 0; i < 10; ++i){
res.push([i])
}
5 replies
TTCTheo's Typesafe Cult
Created by thevalorised on 7/10/2023 in #questions
Prisma not creating entries in the given order
Thank you!
6 replies
TTCTheo's Typesafe Cult
Created by utdev on 6/4/2023 in #questions
useMutation param syntax
You might need to get a
const stateUpdater = api.realEstate.updateState.useMutation();
const stateUpdater = api.realEstate.updateState.useMutation();
to work with hook calls in react
6 replies
TTCTheo's Typesafe Cult
Created by utdev on 6/4/2023 in #questions
useMutation param syntax
api.realEstate.updateState.useMutation().mutate({ /* parameters */ })
api.realEstate.updateState.useMutation().mutate({ /* parameters */ })
6 replies