hyhy
hyhy
Explore posts from servers
TTCTheo's Typesafe Cult
Created by hyhy on 9/25/2024 in #questions
Sending emails from a NextJS app
No description
4 replies
TTCTheo's Typesafe Cult
Created by hyhy on 1/18/2024 in #questions
Using Pusher with app router
Hey all, I worked on a project that used Pusher with the page router, following https://github.com/pingdotgg/zapdos/blob/main/src/pages/index.tsx#L398 as an example - I was wondering if anyone had tried using this on an app router application? I was hoping that I could just stick the Pusher part of the application in a "use client" component and it would work properly, but I'm getting all sorts of errors. Does anyone have any examples of how this might work in practise? I've pushed up my branch to https://github.com/hyhydev/Scout/tree/add-pusher if anyone has time to take a look, see src/utils/pusher, src/server/common/pusher and src/components/pusher/pusherWrapper.tsx for use Thank you
2 replies
TTCTheo's Typesafe Cult
Created by hyhy on 12/30/2023 in #questions
Calling trpc mutations on client components with app router
Hello, looking for some help learning app router, any advice greatly appreciated I'm getting an error trying to call a mutation from a client component - my aim is to collect some values with a form in a shadcn dialog (so useState required) Setting up the mutations for create and edit:
import { api } from "~/trpc/react";
export function EpisodeForm({ id }: EpisodeFormProps) {
const [open, setOpen] = useState(false);

const utils = api.useUtils();
const createEpisode = api.episode.create.useMutation({
onSuccess: () => utils.episode.invalidate(),
});
const updateEpisode = api.episode.update.useMutation({
onSuccess: () => utils.episode.invalidate(),
});
...
import { api } from "~/trpc/react";
export function EpisodeForm({ id }: EpisodeFormProps) {
const [open, setOpen] = useState(false);

const utils = api.useUtils();
const createEpisode = api.episode.create.useMutation({
onSuccess: () => utils.episode.invalidate(),
});
const updateEpisode = api.episode.update.useMutation({
onSuccess: () => utils.episode.invalidate(),
});
...
Mutating onSubmit function:
async function onSubmit() {
await form.trigger();
const errors = Object.keys(form.formState.errors);
if (errors.length > 0) {
throw new Error("Form has errors");
}
if (!!id) {
updateEpisode.mutate({
id,
...form.getValues(),
});
} else {
createEpisode.mutate({
...form.getValues(),
});
}
form.reset();
}
async function onSubmit() {
await form.trigger();
const errors = Object.keys(form.formState.errors);
if (errors.length > 0) {
throw new Error("Form has errors");
}
if (!!id) {
updateEpisode.mutate({
id,
...form.getValues(),
});
} else {
createEpisode.mutate({
...form.getValues(),
});
}
form.reset();
}
Specific error is in the screenshot, I assume I'm just doing the client component trpc pattern wrong, but not really sure what a correct call would look like
21 replies
TTCTheo's Typesafe Cult
Created by hyhy on 12/15/2023 in #questions
Drizzle Foreign Key Constraints are not allowed
Can anyone lend me a hand with understanding this error message? I've got some relations in my schema that are causing the following error on db:push to planetscale:
Error: VT10001: foreign key constraints are not allowed
at PromiseConnection.query (/home/hyhy/dev/modulation/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/hyhy/dev/modulation/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_UNKNOWN_ERROR',
errno: 1105,
sql: 'ALTER TABLE `modulation_album` ADD CONSTRAINT `modulation_album_artist_id_modulation_artist_id_fk` FOREIGN KEY (`artist_id`) REFERENCES `modulation_artist`(`id`) ON DELETE no action ON UPDATE no action;',
sqlState: 'HY000',
sqlMessage: 'VT10001: foreign key constraints are not allowed'
}
Error: VT10001: foreign key constraints are not allowed
at PromiseConnection.query (/home/hyhy/dev/modulation/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/hyhy/dev/modulation/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_UNKNOWN_ERROR',
errno: 1105,
sql: 'ALTER TABLE `modulation_album` ADD CONSTRAINT `modulation_album_artist_id_modulation_artist_id_fk` FOREIGN KEY (`artist_id`) REFERENCES `modulation_artist`(`id`) ON DELETE no action ON UPDATE no action;',
sqlState: 'HY000',
sqlMessage: 'VT10001: foreign key constraints are not allowed'
}
Using the stock drizzle config:
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["modulation_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
driver: "mysql2",
dbCredentials: {
connectionString: env.DATABASE_URL,
},
tablesFilter: ["modulation_*"],
} satisfies Config;
9 replies
TTCTheo's Typesafe Cult
Created by hyhy on 11/1/2023 in #questions
"inArray requires at least 1 value" error deleting files with uploadthing
No description
13 replies
TTCTheo's Typesafe Cult
Created by hyhy on 10/31/2023 in #questions
ShadCn Dialog - running code onClose
Hey, wondering if anyone can help me to understand how this might work - I've got a dialog that contains a form. I've got a close dialog button in the dialog that runs some code, however if the user closes the dialog by clicking outside it, the code isn't run. How might I configure the dialog to run this code when the form is closed by clicking outside?
21 replies
TTCTheo's Typesafe Cult
Created by hyhy on 10/30/2023 in #questions
Deleting files with UTApi, unauthorized
No description
6 replies
TTCTheo's Typesafe Cult
Created by hyhy on 10/23/2023 in #questions
What pattern should I use to access Session in client component
No description
26 replies
TTCTheo's Typesafe Cult
Created by hyhy on 9/20/2023 in #questions
Refreshing NextAuth Discord provider user details
No description
15 replies
TTCTheo's Typesafe Cult
Created by hyhy on 8/11/2023 in #questions
Linking NextAuth Discord provider to Discord user calling a slash command
I've got an application that allows users to sign in using the NextAuth Discord provider. I'm creating a Discord bot with a slash command that, when called, will create a chat room on my application and then reply to the user with a link (basically just a prisma create, return object id). My issue is that the user needs to be assigned the room owner, so that they can only have 1 active room. Is it possible to do this? I was hoping to just find the user by email address but this isn't returned by the Discord API. It looks like the user's name doesn't update in the db if they change it.
9 replies
RRailway
Created by hyhy on 7/31/2023 in #✋|help
How can I put a spend limit on my hobby account?
I've signed up for a hobby account and want to put a limit on how much I can spend monthly. I can see an option to receive alerts when I go over a limit, but can't see where the limit is. Any help appreciated thank you
12 replies
RRailway
Created by hyhy on 7/19/2023 in #✋|help
Request to Soketi container hanging - not connecting properly?
32 replies
TTCTheo's Typesafe Cult
Created by hyhy on 5/23/2023 in #questions
Understanding sockets with t3, looking for tutorials
Has anyone produced any guides for implementing websockets with t3? I'm aware of the zapdos repo and socketi but looking for something more step by step to help me understand how it fits together. My app flow would be - User A hosts a room which generates a code/URL, names themself - User B joins the room with the code/URL (and the room is now full), names themself - User A starts the room - A random user is selected, and both users are informed of the outcome Thanks
2 replies
TTCTheo's Typesafe Cult
Created by hyhy on 3/10/2023 in #questions
Posting to a (secret) webhook best practise
4 replies
TTCTheo's Typesafe Cult
Created by hyhy on 2/24/2023 in #questions
Discord/Slack page embeds not working
4 replies
TTCTheo's Typesafe Cult
Created by hyhy on 12/15/2022 in #questions
Discord OAuth error OAuthCallback
3 replies