feat(frontend): Clean-up schemas, remove dead code, move types
This commit is contained in:
27
legalconsenthub/types/auth.ts
Normal file
27
legalconsenthub/types/auth.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { RouteLocationRaw } from '#vue-router'
|
||||
import type { useAuth } from '~/composables/useAuth'
|
||||
|
||||
export interface RuntimeAuthConfig {
|
||||
redirectUserTo: RouteLocationRaw | string
|
||||
redirectGuestTo: RouteLocationRaw | string
|
||||
}
|
||||
|
||||
// Types can be found here: https://github.com/better-auth/better-auth/blob/3f574ec70bb15c155a78673d42c5e25f7376ced3/packages/better-auth/src/plugins/organization/routes/crud-invites.ts#L531
|
||||
type Client = ReturnType<typeof useAuth>['client']
|
||||
export type Session = Client['$Infer']['Session']
|
||||
export type User = Session['user']
|
||||
export type ActiveOrganization = Client['$Infer']['ActiveOrganization']
|
||||
export type Organization = Client['$Infer']['Organization']
|
||||
export type Invitation = Client['$Infer']['Invitation']
|
||||
export type Member = Client['$Infer']['Member']
|
||||
export type ListMembersOptions = Parameters<Client['organization']['listMembers']>[0]
|
||||
export type ListMembersResponse = Awaited<ReturnType<Client['organization']['listMembers']>>
|
||||
export type ListMembersQuery = NonNullable<ListMembersOptions>['query']
|
||||
// Extended invitation type with additional organization and inviter details
|
||||
export type CustomInvitation =
|
||||
| (Invitation & {
|
||||
organizationName: string
|
||||
organizationSlug: string
|
||||
inviterEmail: string
|
||||
})
|
||||
| null
|
||||
22
legalconsenthub/types/schemas.ts
Normal file
22
legalconsenthub/types/schemas.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as z from 'zod'
|
||||
|
||||
export const signUpSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
email: z.string().email('Invalid email'),
|
||||
password: z.string().min(8, 'Must be at least 8 characters')
|
||||
})
|
||||
|
||||
export const signInSchema = z.object({
|
||||
email: z.string().email('Invalid email'),
|
||||
password: z.string().min(8, 'Must be at least 8 characters')
|
||||
})
|
||||
|
||||
export const organizationSchema = z.object({
|
||||
name: z.string().min(2, 'Too short'),
|
||||
slug: z.string().min(2, 'Too short'),
|
||||
logo: z.string().optional()
|
||||
})
|
||||
|
||||
export type SignUpSchema = z.output<typeof signUpSchema>
|
||||
export type SignInSchema = z.output<typeof signInSchema>
|
||||
export type OrganizationSchema = z.output<typeof organizationSchema>
|
||||
Reference in New Issue
Block a user