Donny D
Donny D
Explore posts from servers
Mmalefashionadvice
Created by Donny D on 5/8/2024 in #questions-and-advice
I've got a business outing coming up in a few weeks. Can shorts be "smart casual"?
The outing is in Arizona so it's gon' be hottt
8 replies
Mmalefashionadvice
Created by Donny D on 4/19/2024 in #questions-and-advice
Suit Sizing Help Needed
Hi, I'm about to order a suit online and I'm struggling with some size related issues. When I take a measurement with a tape measure I get a chest size of a little over 46". I'm 5'7" 200 pounds, good amount of muscle but a good amount of fat too. Now according to that measurement I should look for a size 46 jacket. However, the blazer I have (which is far too wide in the shoulder) says it's a 42 regular. Other than the shoulders I think the blazer I have fits alright. But I'm really struggling with the tape measure saying 46 and the existing jacket saying 42. How can I tell which size to order? Another issue is that suit is at a final sale price and non-refundable so I don't want to get a size that's just too small, or far too large to tailor it.
10 replies
TTCTheo's Typesafe Cult
Created by Donny D on 9/29/2023 in #questions
TS, derive type from key of another type
Let's say we have this type
type DataFile = {
name: string;
id: number;
category: 'cat' | 'dog'
} | null
type DataFile = {
name: string;
id: number;
category: 'cat' | 'dog'
} | null
and elsewhere I want to have another type:
type DataDisplay = {
name: string;
id: number;
category: ...
}
type DataDisplay = {
name: string;
id: number;
category: ...
}
I want the category of DataDisplay to also be 'cat' | 'dog' but I want to know if there's a way to have it be derived from DataFile so if that changes, the DataDisplay will automatically account for that. like DataFile['category'] but that doesn't work because of the | null
8 replies
TTCTheo's Typesafe Cult
Created by Donny D on 9/11/2023 in #questions
Enum access question
If I have
export enum Options {
'bool' = 'Boolean',
'num' = 'Number'
'str' = 'String'
}
export enum Options {
'bool' = 'Boolean',
'num' = 'Number'
'str' = 'String'
}
and I want to do something like this
['bool', 'num', 'str'].map(i => console.log(Options.i))
['bool', 'num', 'str'].map(i => console.log(Options.i))
Is there a way to do this? like if I am iterating and know the values I'm iterating will be keys to the enum, is there a way to us the iteration data as the key to the enum??
5 replies
TTCTheo's Typesafe Cult
Created by Donny D on 2/1/2023 in #questions
Iterate over an array and create a new sorted object.
I'm completely brain farting. I have data coming in like
const data = [
{
name: "Eggs",
category: "Groceries",
},
{
name: "Meat",
category: "Groceries",
},
{
name: "Screwdriver",
category: "Tools",
},
...
]
const data = [
{
name: "Eggs",
category: "Groceries",
},
{
name: "Meat",
category: "Groceries",
},
{
name: "Screwdriver",
category: "Tools",
},
...
]
and I need to sort them to create an object with this shape:
const newShape = [
{
category: "Groceries",
options: [
...all the objects from the input array with the category "Groceries",
{
name: "Eggs",
value: 'eggs'
}
]
},
{
category: "Tools",
options: [
...all the objects from the input array with the category "Fools",
{
name: "Screwdriver",
value: "screwdriver"
}
]
},
...etc for each unique category value
]
const newShape = [
{
category: "Groceries",
options: [
...all the objects from the input array with the category "Groceries",
{
name: "Eggs",
value: 'eggs'
}
]
},
{
category: "Tools",
options: [
...all the objects from the input array with the category "Fools",
{
name: "Screwdriver",
value: "screwdriver"
}
]
},
...etc for each unique category value
]
And I'm struggling to think of an elegant way to do this. Any suggestions?
7 replies
TTCTheo's Typesafe Cult
Created by Donny D on 11/26/2022 in #questions
Question about implementing inline search filters
Does anybody have suggestions on implementing inline search box parameters? i.e. if you are searching issues in a github repo there's stuff like is:open author:username archived:false etc... is there any recommended reading on how to implement parsing these types of entries into the field? Do you basically just scan for 'parameter:query' and then just space-delimit it to separate the search terms from the filters/parameters?
2 replies
TTCTheo's Typesafe Cult
Created by Donny D on 11/25/2022 in #questions
Question about storing data for a substack-like clone?
I'm working on a pet project wherein users can write posts with a full markdown editor. I'm curious if anyone knows how best to store these in the backend? Do you save the content as a .md file? or save it as plain text in the DB?? Am I making sense? Basically what's the ideal way to store user-generated markdown content
8 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/24/2022 in #questions
Authorization Checking for editing data?
I was wondering if there's a general best practice to do something like this very simply in T3: Let's say you have a user profile page. You want anybody to be able to see that page, but only TAHT specific user can edit the page if they're logged in. What would be the most hassle free way to implement this?
3 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/18/2022 in #questions
change multiple attributes with 'group-hover'
If I want to do something like this with a component. i.e. make a tooltip go from hidden to absolute and the opacity from 0 to 100. how do I do this with group-hover?
2 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/15/2022 in #questions
Please help with complex form query state management mess
type EditChapterInput = {
content: string,
id: number,
title?: string
};

const EditChapter = () => {
const { control, handleSubmit, setValue } = useForm<EditChapterInput>();
const router = useRouter();
const { chapterId, storyid } = router.query;
const session = trpc.useQuery(['auth.getSession']);
const { data: story } = trpc.useQuery(['story.getByStoryId', { id: Number(storyid) }]);
const { data: chapter } = trpc.useQuery(['chapter.getById', { id: Number(chapterId) }]);
const editChapter = trpc.useMutation(['chapter.update']);

setValue('title', (chapter?.title ? chapter.title : ''));
setValue('content', (chapter?.content ? chapter.content : ''));

const onSubmit: SubmitHandler<EditChapterInput> = data => {

if (session.data && story && chapter) {
const newChapterData: EditChapterInput = {
content: data.content,
id: chapter?.id,
title: data.title
};

editChapter.mutate(newChapterData);
}
};
type EditChapterInput = {
content: string,
id: number,
title?: string
};

const EditChapter = () => {
const { control, handleSubmit, setValue } = useForm<EditChapterInput>();
const router = useRouter();
const { chapterId, storyid } = router.query;
const session = trpc.useQuery(['auth.getSession']);
const { data: story } = trpc.useQuery(['story.getByStoryId', { id: Number(storyid) }]);
const { data: chapter } = trpc.useQuery(['chapter.getById', { id: Number(chapterId) }]);
const editChapter = trpc.useMutation(['chapter.update']);

setValue('title', (chapter?.title ? chapter.title : ''));
setValue('content', (chapter?.content ? chapter.content : ''));

const onSubmit: SubmitHandler<EditChapterInput> = data => {

if (session.data && story && chapter) {
const newChapterData: EditChapterInput = {
content: data.content,
id: chapter?.id,
title: data.title
};

editChapter.mutate(newChapterData);
}
};
Ok this will be a bit of a mess. The above is the logic code of a component I'm writing to edit a given chapter of a story. In the sidebar there's a list of chapters of the story, when a user clicks a chapter I want the current form state to update with the contents of the clicked chapter. I also want it so that when a user save changes to a chapter, the form state reflects that. Currently when the users saves the value reverts to the previous value because of the setValue() calls I have. But without those calls, the form content doesn't update when a user clicks on a different chapter. I don't even know how to ask what I'm doing wrong because I'm kind of brain-fried with this right now
7 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/15/2022 in #questions
Changing URL but components re-rendering.
I'm working on an application wherein you click on various chapters of a story and it should update the form fields on the page with that chapters content. The URL is changing correctly, but the form fields are not rerendering with the new content. What do?
4 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/14/2022 in #questions
trpc.useQuery() succeeding but returning empty data?
Ive checked my db and the entries definitely exist. and the query is sending the right Id input to find a unique entry using the id. But the data object in the useQuery result is undefined
7 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/13/2022 in #questions
Creating a new record that's related to an existing record and creates new relations?
Can you use this to created multiple levels of related records? https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#connect-an-existing-record i.e. the story app I'm working on. Users create a story which should connect to their user id, and they also write a chapter which connects to the story:
const story = await prisma.story.create({
data: {
connect: {
authorId: { user.id }
},
title: "The Fjord of the Things",
description: "Defintiely NOT a derivative work",
chapters: {
create: [
{
title: "A Non-Expected Party"
content: "Froyo Shmaggins decided to throw a party."
}
]
}
}
});
const story = await prisma.story.create({
data: {
connect: {
authorId: { user.id }
},
title: "The Fjord of the Things",
description: "Defintiely NOT a derivative work",
chapters: {
create: [
{
title: "A Non-Expected Party"
content: "Froyo Shmaggins decided to throw a party."
}
]
}
}
});
I'm not at my dev machine to check right now, but does that query look like it should hook everything up correctly?
1 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/13/2022 in #questions
Little confused with tRPC and tanstack-query. plz help
I'm a little bit lost on what to do here. What things do I need to know in order to successfully send data to the backend, i.e. POST/PUT. I know it's going to use a mutation, but I'm not sure what's the best practice approach using trpc?
1 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/8/2022 in #questions
Adding next.js plugin to T3?
if I want to add a next plugin to t3 do I just add it to the arg in defineNextConfig?
7 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/8/2022 in #questions
Generating a Layout with main AND sidebar content??
How would I go about creating a <Layout /> that will allow me to pass in children to define the body content AND sidebar content? So I'm expecting each page to have the Header, provided by the Layout, and then two children. The first child will be the body content, the second will be the sidebar. Is there a way to write a Layout that will accept specific children in specific places?
23 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/7/2022 in #questions
Am I doing Prisma relations right?
4 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/6/2022 in #questions
535 Authentication failed 'Bad username password'
5 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/5/2022 in #questions
Should I start with what I know, or what I don't?
I'm building an app with t3. If I can complete it, I intend to release it to the world to use. I've done a lot of frontend, some backend stuff. But when it comes to "putting it all together" I find myself a bit stumped on where to start. Part of me wants to just build out the feature/UI stuff without any really API/backend things happening. Another part of me knows that I'm avoiding doing those things because I'm unfamiliar with them and thus they are terrifying. To be more specific, I don't know where to start with auth stuff and user registration. I'd like to have user register with their own email/pass if they want, or login with NextAuth provider if they want. How do reconcile the two so that either way the user has a unique profile on my app? Like, I don't know what to do, and I don't even really know what the right questions are to ask at this point lmao.
15 replies
TTCTheo's Typesafe Cult
Created by Donny D on 10/4/2022 in #questions
Initialized Project, just seeking clarification on next steps
I've just spun up a t3 app. It defaults to sqlite but I want to use postgres. So, I've spun up a postgres docker container and changed the .env database URL. Other than uncommenting the annotations in the prisma schema, is there anything else I need to do to migrate to the new DB properly so I can start building out my data model?
5 replies