-
-
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.
- Loading branch information
Showing
35 changed files
with
2,695 additions
and
2,124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,30 @@ | ||
import { z } from 'zod' | ||
|
||
import { createGeoFields, Prisma } from '@weareinreach/db' | ||
import { prefixedId } from '~api/schemas/idPrefix' | ||
import { createManyRequired } from '~api/schemas/nestedOps' | ||
|
||
export const ZCreateSchema = z | ||
.object({ | ||
orgId: prefixedId('organization'), | ||
id: prefixedId('orgLocation').optional(), | ||
name: z.string().optional(), | ||
street1: z.string(), | ||
street2: z.string().optional(), | ||
city: z.string(), | ||
postCode: z.string().optional(), | ||
primary: z.boolean().optional(), | ||
govDistId: z.string(), | ||
countryId: z.string(), | ||
longitude: z.number(), | ||
latitude: z.number(), | ||
published: z.boolean().default(false), | ||
emails: z | ||
.object({ orgEmailId: prefixedId('orgEmail') }) | ||
.array() | ||
.optional(), | ||
phones: z | ||
.object({ phoneId: prefixedId('orgPhone') }) | ||
.array() | ||
.optional(), | ||
services: z | ||
.object({ serviceId: prefixedId('orgService') }) | ||
.array() | ||
.optional(), | ||
}) | ||
.transform((data) => { | ||
const { emails, phones, services, ...dataTo } = data | ||
const serviceLinks = ( | ||
!services | ||
? undefined | ||
: createManyRequired( | ||
services.map(({ serviceId }) => { | ||
return { serviceId } | ||
}) | ||
) | ||
) satisfies Prisma.OrgLocationServiceCreateNestedManyWithoutLocationInput | undefined | ||
|
||
const emailLinks = ( | ||
!emails | ||
? undefined | ||
: createManyRequired( | ||
emails.map(({ orgEmailId }) => { | ||
return { orgEmailId } | ||
}) | ||
) | ||
) satisfies Prisma.OrgLocationEmailCreateNestedManyWithoutLocationInput | undefined | ||
const phoneLinks = ( | ||
!phones | ||
? undefined | ||
: createManyRequired( | ||
phones.map(({ phoneId }) => { | ||
return { phoneId } | ||
}) | ||
) | ||
) satisfies Prisma.OrgLocationPhoneCreateNestedManyWithoutLocationInput | undefined | ||
|
||
return Prisma.validator<Prisma.OrgLocationCreateArgs>()({ | ||
data: { | ||
...dataTo, | ||
...createGeoFields({ longitude: dataTo.longitude, latitude: dataTo.latitude }), | ||
emails: emailLinks, | ||
phones: phoneLinks, | ||
services: serviceLinks, | ||
}, | ||
export const ZCreateSchema = z.object({ | ||
orgId: prefixedId('organization'), | ||
id: prefixedId('orgLocation').optional(), | ||
name: z.string(), | ||
address: z | ||
.object({ | ||
street1: z.string(), | ||
street2: z.string().optional(), | ||
city: z.string(), | ||
postCode: z.string().optional(), | ||
govDistId: z.string(), | ||
longitude: z.number(), | ||
latitude: z.number(), | ||
countryId: z.string(), | ||
}) | ||
}) | ||
.partial() | ||
.required({ countryId: true }), | ||
primary: z.boolean().optional(), | ||
notVisitable: z.boolean().default(false), | ||
published: z.boolean().default(false), | ||
emails: prefixedId('orgEmail').array().optional(), | ||
phones: prefixedId('orgPhone').array().optional(), | ||
services: prefixedId('orgService').array().optional(), | ||
}) | ||
|
||
export type TCreateSchema = z.infer<typeof ZCreateSchema> |
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
Oops, something went wrong.
78aa297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
inreach-app – ./apps/app
inreach-app-git-main-weareinreach.vercel.app
inreach-app-weareinreach.vercel.app
inreach-app.vercel.app
app.inreach.org
admin.inreach.org
beta.inreach.org
www.app.inreach.org