mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +02:00
✨ Add spaces concept (#1776)
This commit is contained in:
parent
92a72dde60
commit
04fcc0350f
21 changed files with 389 additions and 93 deletions
38
apps/web/src/features/spaces/queries.ts
Normal file
38
apps/web/src/features/spaces/queries.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
|
||||
export async function listSpaces({ ownerId }: { ownerId: string }) {
|
||||
const spaces = await prisma.space.findMany({
|
||||
where: {
|
||||
ownerId,
|
||||
},
|
||||
});
|
||||
|
||||
return spaces;
|
||||
}
|
||||
|
||||
export async function getDefaultSpace({ ownerId }: { ownerId: string }) {
|
||||
const space = await prisma.space.findFirst({
|
||||
where: {
|
||||
ownerId,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
if (!space) {
|
||||
throw new Error(`Space with owner ID ${ownerId} not found`);
|
||||
}
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
export async function getSpace({ id }: { id: string }) {
|
||||
const space = await prisma.space.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
return space;
|
||||
}
|
|
@ -2,8 +2,16 @@ import { z } from "zod";
|
|||
|
||||
export const subscriptionCheckoutMetadataSchema = z.object({
|
||||
userId: z.string(),
|
||||
spaceId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type SubscriptionCheckoutMetadata = z.infer<
|
||||
typeof subscriptionCheckoutMetadataSchema
|
||||
>;
|
||||
|
||||
export const subscriptionMetadataSchema = z.object({
|
||||
userId: z.string(),
|
||||
spaceId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type SubscriptionMetadata = z.infer<typeof subscriptionMetadataSchema>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue