Skip to content

Commit

Permalink
release: 2024-06-28b (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jun 28, 2024
2 parents 61b89bc + c1bae34 commit f5de73a
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/api/router/location/mutation.create.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod'

import { PrismaEnums } from '@weareinreach/db'
import * as PrismaEnums from '@weareinreach/db/enums'
import { prefixedId } from '~api/schemas/idPrefix'

export const ZCreateSchema = z.object({
Expand Down
3 changes: 2 additions & 1 deletion packages/api/router/location/mutation.update.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from 'zod'

import { Geometry, Prisma, PrismaEnums } from '@weareinreach/db'
import { Geometry, Prisma } from '@weareinreach/db'
import * as PrismaEnums from '@weareinreach/db/enums'
import { allAttributes } from '@weareinreach/db/generated/allAttributes'
import { prefixedId } from '~api/schemas/idPrefix'

Expand Down
60 changes: 60 additions & 0 deletions packages/db/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export enum AddressVisibility {
FULL = 'FULL',
PARTIAL = 'PARTIAL',
HIDDEN = 'HIDDEN',
}

export enum AttributeRender {
COMMUNITY = 'COMMUNITY',
SERVICE = 'SERVICE',
LEADER = 'LEADER',
ATTRIBUTE = 'ATTRIBUTE',
LIST = 'LIST',
}

export enum AttributeAttachment {
ORGANIZATION = 'ORGANIZATION',
LOCATION = 'LOCATION',
SERVICE = 'SERVICE',
USER = 'USER',
}

export enum FilterType {
INCLUDE = 'INCLUDE',
EXCLUDE = 'EXCLUDE',
}

export enum SourceType {
EXTERNAL = 'EXTERNAL',
ORGANIZATION = 'ORGANIZATION',
SYSTEM = 'SYSTEM',
USER = 'USER',
}

export enum LocationAlertLevel {
INFO_PRIMARY = 'INFO_PRIMARY',
WARN_PRIMARY = 'WARN_PRIMARY',
CRITICAL_PRIMARY = 'CRITICAL_PRIMARY',
INFO_SECONDARY = 'INFO_SECONDARY',
WARN_SECONDARY = 'WARN_SECONDARY',
CRITICAL_SECONDARY = 'CRITICAL_SECONDARY',
}

export enum InterpolationOptions {
PLURAL = 'PLURAL',
ORDINAL = 'ORDINAL',
CONTEXT = 'CONTEXT',
}

export enum VisibilitySetting {
NONE = 'NONE',
LOGGED_IN = 'LOGGED_IN',
PROVIDER = 'PROVIDER',
PUBLIC = 'PUBLIC',
}

export enum AuditTrailOperation {
INSERT = 'INSERT',
UPDATE = 'UPDATE',
DELETE = 'DELETE',
}
3 changes: 2 additions & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clean:zod": "rm -rf ./zod-schemas/* || true",
"db:dataMigrate": "pnpm with-env tsx ./prisma/dataMigrationRunner.ts",
"db:deploy": "pnpm with-env prisma migrate deploy",
"db:generate": "pnpm clean:zod && pnpm with-env prisma generate --generator client && prisma -v",
"db:generate": "pnpm clean:zod && pnpm with-env prisma generate --generator client --generator enum && prisma -v",
"db:generate:aws": "pnpm with-env prisma generate --generator aws",
"db:generate:kysely": "pnpm with-env kysely-codegen || true",
"db:migrate": "pnpm with-env prisma migrate dev",
Expand Down Expand Up @@ -105,6 +105,7 @@
"pretty-ms": "9.0.0",
"prisma": "5.16.1",
"prisma-dbml-generator": "0.12.0",
"prisma-generator-ts-enums": "1.1.0",
"prisma-query-inspector": "1.4.4",
"prisma-query-log": "3.2.0",
"slugify": "1.6.6",
Expand Down
5 changes: 5 additions & 0 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ generator aws {
binaryTargets = ["linux-arm64-openssl-3.0.x"]
}

generator enum {
provider = "node node_modules/prisma-generator-ts-enums" // specify the path to this generator here
output = "../enums/index.ts" // optionally, you can specify an output filename here -- default is ./types/enums.d.ts
}

// generator zod {
// provider = "zod-prisma-types"
// output = "../zod-schemas"
Expand Down
14 changes: 8 additions & 6 deletions packages/ui/components/data-portal/AddressDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { z } from 'zod'

import { type ApiOutput } from '@weareinreach/api'
import { boolOrNull, transformNullString } from '@weareinreach/api/schemas/common'
import * as PrismaEnums from '@weareinreach/db/enums'
import { Breadcrumb } from '~ui/components/core/Breadcrumb'
import { Button } from '~ui/components/core/Button'
import { isExternal, Link } from '~ui/components/core/Link'
Expand Down Expand Up @@ -92,7 +93,7 @@ const FormSchema = z.object({
deleted: z.coerce.boolean(),
countryId: z.string().nullable(),
govDistId: z.string().nullable(),
addressVisibility: z.enum(['FULL', 'PARTIAL', 'HIDDEN']).default('FULL'),
addressVisibility: z.nativeEnum(PrismaEnums.AddressVisibility),
accessible: z
.object({
supplementId: z.string(),
Expand Down Expand Up @@ -160,10 +161,10 @@ const CountryItem = forwardRef<HTMLDivElement, CountryItem>(({ label, flag, ...p
})
CountryItem.displayName = 'CountryItem'

const addressVisibilityOptions: Record<'value' | 'label', string>[] = [
{ value: 'FULL', label: 'Show full address' },
{ value: 'PARTIAL', label: 'Show city & state/province' },
{ value: 'HIDDEN', label: 'Hide address' },
const addressVisibilityOptions: { value: PrismaEnums.AddressVisibility; label: string }[] = [
{ value: PrismaEnums.AddressVisibility.FULL, label: 'Show full address' },
{ value: PrismaEnums.AddressVisibility.PARTIAL, label: 'Show city & state/province' },
{ value: PrismaEnums.AddressVisibility.HIDDEN, label: 'Hide address' },
]

const _AddressDrawer = forwardRef<HTMLButtonElement, AddressDrawerProps>(({ locationId, ...props }, ref) => {
Expand Down Expand Up @@ -196,6 +197,7 @@ const _AddressDrawer = forwardRef<HTMLButtonElement, AddressDrawerProps>(({ loca
})
useEffect(() => {
if (data && !isLoading) {
// @ts-expect-error TODO: Wtf?
form.setValues(data)
form.resetDirty()
setIsSaved(false)
Expand Down Expand Up @@ -471,7 +473,7 @@ const _AddressDrawer = forwardRef<HTMLButtonElement, AddressDrawerProps>(({ loca
<Select
label='Address visibility'
data={addressVisibilityOptions}
defaultValue='FULL'
defaultValue={PrismaEnums.AddressVisibility.FULL}
{...form.getInputProps('data.addressVisibility')}
/>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/mockData/component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaEnums } from '@weareinreach/db'
import * as PrismaEnums from '@weareinreach/db/enums'
import { getTRPCMock, type MockHandlerObject } from '~ui/lib/getTrpcMock'

export const component = {
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/mockData/fieldOpt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { z } from 'zod'

import { type ApiOutput } from '@weareinreach/api'
import { type $Enums } from '@weareinreach/db'
import { getTRPCMock, type MockAPIHandler, type MockHandlerObject } from '~ui/lib/getTrpcMock'

import type * as $Enums from '@weareinreach/db/enums'

const queryAttributeCategories: MockAPIHandler<'fieldOpt', 'attributeCategories'> = async (query) => {
const attributeCategories = (await import('./json/fieldOpt.attributeCategories.json')).default
if (Array.isArray(query)) {
Expand Down
93 changes: 93 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5de73a

Please sign in to comment.