Vimes
Vimes
TTCTheo's Typesafe Cult
Created by SharpieMaster on 9/25/2023 in #questions
t3 app router when?
Just chime in, I decided to create a new project in NextJS app router with react server components It would have been done a long time ago if I just went the pages route instead, the amount of weird app-router bugs that require way to much time to debug is way too large
24 replies
TTCTheo's Typesafe Cult
Created by Vimes on 3/15/2023 in #questions
Zod with types from Supabase type gen
hmmm too bad, I'll just type it out by hand 🙂
3 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/23/2023 in #questions
Recommendations for auth setup
Not very sensitive data behind login, but only certain customers should see certain data. Supabase seems sweet because I can also use it for other stuff should the need arise (whatever I can use postgres and file storage for)
9 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/23/2023 in #questions
Recommendations for auth setup
I'm aware. right now I'm considering the free tier supabase, shuts down after one week of inactivity (which could happen during holidays) but github actions cron jobs seems to fix that
9 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/23/2023 in #questions
Recommendations for auth setup
It seems easier. But I also want a custom login screen (not possible with Auth0 at least) and the ability to easily programatically add data to users. Supabase seems simple enough to self host, haven't looked too much into firebase. oath2 providers could be an option, but only business will log inn and they expect email + password login
9 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
Was just a carpenter having a smoke 🙃 Your solution worked @Geezer, thanks!
type Props = {
audit: Audit;
};

type Audit = {
content: {
descendants: { items: ContentProps[] };
id: string;
level: number;
name: string;
};
};
export const getServerSideProps: GetServerSideProps = async (params) => {
const audit = (await getAudit(
`/granskninger/${params.query.slug as string}`
)) as Audit;
return {
props: { audit },
};
};
type Props = {
audit: Audit;
};

type Audit = {
content: {
descendants: { items: ContentProps[] };
id: string;
level: number;
name: string;
};
};
export const getServerSideProps: GetServerSideProps = async (params) => {
const audit = (await getAudit(
`/granskninger/${params.query.slug as string}`
)) as Audit;
return {
props: { audit },
};
};
So I say audit = waiting for something sent as string -> this await returns the data that fits Audit props. still weird how I couldn't use just Props directly, but it probably makes sense somehow
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
fire alarm going, be back in not too long
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
TS not happy with audit as it's own thing. Currently chewing through geezers suggestion, allot to take inn
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
how would audit: Audit work? Should I copy the props type to a different Audit type? @Geezer Give a few seconds/minutes to understand your code 🙂
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
it will be a TS function once I become better at this TS thing
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
it is the data I'm using, but I am also very stupid so I may be wrong. Full file:
import { NextPage, GetServerSideProps } from "next";
import { ContentProps } from "../../../ts/auditTypes";
import Layout from "../../../components/Layout";
import { getAudit } from "../../api/auth/fetchData";
import AuditRenderer from "../../../audit/auditRenderer";
type Props = {
audit: {
content: {
descendants: { items: ContentProps[]; };
id: string;
level: number;
name: string;

};
};
};



const Kundeportal: NextPage<Props> = ({ audit }) => {
const { name } = audit.content;
console.log("Audit er", audit);
return (
<Layout>
<div className="container mx-auto px-4">
<h1>{name}</h1>
<AuditRenderer content={audit.content.descendants} />
</div>
</Layout>
);
};

export const getServerSideProps: GetServerSideProps = async (params) => {


const audit: Props = await getAudit(`/granskninger/${params.query.slug}`);
return {
props: { audit }
};
};

export default Kundeportal;
import { NextPage, GetServerSideProps } from "next";
import { ContentProps } from "../../../ts/auditTypes";
import Layout from "../../../components/Layout";
import { getAudit } from "../../api/auth/fetchData";
import AuditRenderer from "../../../audit/auditRenderer";
type Props = {
audit: {
content: {
descendants: { items: ContentProps[]; };
id: string;
level: number;
name: string;

};
};
};



const Kundeportal: NextPage<Props> = ({ audit }) => {
const { name } = audit.content;
console.log("Audit er", audit);
return (
<Layout>
<div className="container mx-auto px-4">
<h1>{name}</h1>
<AuditRenderer content={audit.content.descendants} />
</div>
</Layout>
);
};

export const getServerSideProps: GetServerSideProps = async (params) => {


const audit: Props = await getAudit(`/granskninger/${params.query.slug}`);
return {
props: { audit }
};
};

export default Kundeportal;
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
What I find so weird is that the nextjs docs don't set any types on the await in their examples
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/22/2023 in #questions
Type of return from await
Tried to do " const audit= await getAudit(/granskninger/${params.query.slug}) as Props;"but got the same error, also tried const audit: Props = await getAudit(/granskninger/${params.query.slug});
25 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/21/2023 in #questions
Types for an object passed as props
I solved this, solution was to make ContentProps an array (object? )
type PureContentProps = {
content: {
descendants: {
items: ContentProps[];
}
}
}
type PureContentProps = {
content: {
descendants: {
items: ContentProps[];
}
}
}
2 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/21/2023 in #questions
Typescript with array data from shitty CMS
Thanks! This solved my issue and made me ...a bit better at TS 🙂
8 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/21/2023 in #questions
Typescript with array data from shitty CMS
Would something like this be the "correct" way? Seems a bit reduntant
const AuditConditionalRenderer = ({ allContent }: {allContent: ContentProps}) => {
const AuditConditionalRenderer = ({ allContent }: {allContent: ContentProps}) => {
8 replies
TTCTheo's Typesafe Cult
Created by Vimes on 2/21/2023 in #questions
Typescript with array data from shitty CMS
Sounds like something I would do. Code works and renders in front end. I did destructuring to save one level of "drilling" for props in child components. How should I use typescript with the desctured prop? 🤔 Or should I not do desctruturing here? Same error with
const AuditConditionalRenderer = ({ allContent }: ContentProps)
const AuditConditionalRenderer = ({ allContent }: ContentProps)
8 replies
TTCTheo's Typesafe Cult
Created by joshborseth on 12/1/2022 in #questions
Tech Stack Question
I built a site using Sanity for someone a while ago. Built a set of re-usable components and made a sort of site builder out of them (check out sanity kitchen sink example to see this). The client can use the blocks to create pages however they want, and the can change the colors of blocks and theme colors. Hosting on free tier and works great, but they need React knowlege to make new blocks. They are how ever very happy with Sanity and don’t miss WP at all. Also heard good things about Umbraco Heartcore, but it dosent let you change much
15 replies
TTCTheo's Typesafe Cult
Created by Vimes on 11/30/2022 in #questions
When to use Zod?
Don't confuse me with someone who knows what they are talking about. To me it just seemed like I needed more stuff in my code with things that are one-liners to type in TS. More stuff = more stuff to maintain/read
28 replies
TTCTheo's Typesafe Cult
Created by Vimes on 11/30/2022 in #questions
When to use Zod?
I've probably seen it. but even he mostly used it for API data or user input. Seems more verbose for simple components that take a string or a few strings as inputs
28 replies