Sharing UI: invite by email, roles, read-only viewer mode (#17)
Build image / build-and-push (push) Successful in 8s
Build image / build-and-push (push) Successful in 8s
Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #36.
This commit is contained in:
@@ -8,6 +8,9 @@ import type { UnitPref } from './units'
|
||||
|
||||
const unitPrefSchema = z.enum(['metric', 'imperial'])
|
||||
|
||||
export const gardenRoleSchema = z.enum(['owner', 'editor', 'viewer'])
|
||||
export type GardenRole = z.infer<typeof gardenRoleSchema>
|
||||
|
||||
export const gardenSchema = z.object({
|
||||
id: z.number(),
|
||||
ownerId: z.number(),
|
||||
@@ -19,9 +22,22 @@ export const gardenSchema = z.object({
|
||||
version: z.number(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
// The actor's effective role on this garden (owner/editor/viewer). Present on
|
||||
// every accessible response; optional defensively.
|
||||
myRole: gardenRoleSchema.optional(),
|
||||
})
|
||||
export type Garden = z.infer<typeof gardenSchema>
|
||||
|
||||
/** Whether a role may edit garden contents (objects/plops). Unknown → false. */
|
||||
export function canEditRole(role?: GardenRole): boolean {
|
||||
return role === 'owner' || role === 'editor'
|
||||
}
|
||||
|
||||
/** Whether a role owns the garden (may edit metadata, manage shares, delete). */
|
||||
export function isOwnerRole(role?: GardenRole): boolean {
|
||||
return role === 'owner'
|
||||
}
|
||||
|
||||
const gardensKey = ['gardens'] as const
|
||||
|
||||
export const gardensQueryOptions = queryOptions({
|
||||
|
||||
Reference in New Issue
Block a user