-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* email to location linking dropdown menu * rollback & block t3-oss/[email protected] - bug * allow unpublished for elevated users * skip loading org specific i18n * phone to location linking dropdown * set published default to "true" on new item * audit log routes * api route handlers * generated data * consolidate api queries * Website add or link * SocialMedia add or link * update mock data * update/replace deps * set "moduleResolution" to 'Bundler' for 3rd party packages added export defs for @weareinreach/auth --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3d745f8
commit 708456b
Showing
72 changed files
with
1,723 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/api/router/orgEmail/mutation.locationLink.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { getAuditedClient } from '@weareinreach/db' | ||
import { handleError } from '~api/lib/errorHandler' | ||
import { type TRPCHandlerParams } from '~api/types/handler' | ||
|
||
import { type TLocationLinkSchema } from './mutation.locationLink.schema' | ||
|
||
export const locationLink = async ({ ctx, input }: TRPCHandlerParams<TLocationLinkSchema, 'protected'>) => { | ||
try { | ||
const prisma = getAuditedClient(ctx.actorId) | ||
const { action, orgEmailId, orgLocationId } = input | ||
|
||
switch (action) { | ||
case 'link': { | ||
const result = await prisma.orgLocationEmail.create({ | ||
data: { | ||
orgEmailId, | ||
orgLocationId, | ||
active: true, | ||
}, | ||
}) | ||
return result | ||
} | ||
case 'unlink': { | ||
const result = await prisma.orgLocationEmail.delete({ | ||
where: { | ||
orgEmailId_orgLocationId: { | ||
orgEmailId, | ||
orgLocationId, | ||
}, | ||
}, | ||
}) | ||
return result | ||
} | ||
} | ||
} catch (error) { | ||
handleError(error) | ||
} | ||
} | ||
export default locationLink |
10 changes: 10 additions & 0 deletions
10
packages/api/router/orgEmail/mutation.locationLink.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from 'zod' | ||
|
||
import { prefixedId } from '~api/schemas/idPrefix' | ||
|
||
export const ZLocationLinkSchema = z.object({ | ||
orgEmailId: prefixedId('orgEmail'), | ||
orgLocationId: prefixedId('orgLocation'), | ||
action: z.enum(['link', 'unlink']), | ||
}) | ||
export type TLocationLinkSchema = z.infer<typeof ZLocationLinkSchema> |
34 changes: 34 additions & 0 deletions
34
packages/api/router/orgEmail/query.getLinkOptions.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { prisma } from '@weareinreach/db' | ||
import { handleError } from '~api/lib/errorHandler' | ||
import { type TRPCHandlerParams } from '~api/types/handler' | ||
|
||
import { type TGetLinkOptionsSchema } from './query.getLinkOptions.schema' | ||
|
||
export const getLinkOptions = async ({ input }: TRPCHandlerParams<TGetLinkOptionsSchema>) => { | ||
try { | ||
const { slug, locationId } = input | ||
const result = await prisma.orgEmail.findMany({ | ||
where: { | ||
organization: { some: { organization: { slug } } }, | ||
locations: { every: { orgLocationId: { not: locationId } } }, | ||
}, | ||
select: { | ||
id: true, | ||
firstName: true, | ||
lastName: true, | ||
email: true, | ||
published: true, | ||
deleted: true, | ||
description: { select: { tsKey: { select: { text: true } } } }, | ||
}, | ||
}) | ||
const transformed = result.map(({ description, ...record }) => ({ | ||
...record, | ||
description: description ? description.tsKey.text : null, | ||
})) | ||
return transformed | ||
} catch (error) { | ||
handleError(error) | ||
} | ||
} | ||
export default getLinkOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from 'zod' | ||
|
||
import { prefixedId } from '~api/schemas/idPrefix' | ||
|
||
export const ZGetLinkOptionsSchema = z.object({ slug: z.string(), locationId: prefixedId('orgLocation') }) | ||
export type TGetLinkOptionsSchema = z.infer<typeof ZGetLinkOptionsSchema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// codegen:start {preset: barrel, include: ./*.schema.ts} | ||
export * from './mutation.create.schema' | ||
export * from './mutation.locationLink.schema' | ||
export * from './mutation.update.schema' | ||
export * from './mutation.upsertMany.schema' | ||
export * from './query.forContactInfo.schema' | ||
export * from './query.forContactInfoEdit.schema' | ||
export * from './query.forEditDrawer.schema' | ||
export * from './query.get.schema' | ||
export * from './query.getLinkOptions.schema' | ||
// codegen:end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.