-
-
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
13 changed files
with
661 additions
and
12 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
32 changes: 32 additions & 0 deletions
32
packages/api/router/organization/query.forOrganizationTable.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,32 @@ | ||
import { prisma } from '@weareinreach/db' | ||
import { type TRPCHandlerParams } from '~api/types/handler' | ||
|
||
import { type TForOrganizationTableSchema } from './query.forOrganizationTable.schema' | ||
|
||
export const forOrganizationTable = async ({ input }: TRPCHandlerParams<TForOrganizationTableSchema>) => { | ||
const results = await prisma.organization.findMany({ | ||
where: input, | ||
select: { | ||
id: true, | ||
name: true, | ||
slug: true, | ||
lastVerified: true, | ||
updatedAt: true, | ||
createdAt: true, | ||
published: true, | ||
deleted: true, | ||
locations: { | ||
select: { | ||
id: true, | ||
name: true, | ||
updatedAt: true, | ||
createdAt: true, | ||
published: true, | ||
deleted: true, | ||
}, | ||
}, | ||
}, | ||
orderBy: [{ deleted: 'desc' }, { name: 'asc' }], | ||
}) | ||
return results | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/api/router/organization/query.forOrganizationTable.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' | ||
|
||
export const ZForOrganizationTableSchema = z | ||
.object({ | ||
published: z.boolean(), | ||
deleted: z.boolean(), | ||
}) | ||
.partial() | ||
.optional() | ||
export type TForOrganizationTableSchema = z.infer<typeof ZForOrganizationTableSchema> |
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
19 changes: 19 additions & 0 deletions
19
packages/ui/components/data-portal/OrganizationTable.stories.tsx
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,19 @@ | ||
import { type Meta, type StoryObj } from '@storybook/react' | ||
|
||
import { organization } from '~ui/mockData/organization' | ||
|
||
import { OrganizationTable } from './OrganizationTable' | ||
|
||
export default { | ||
title: 'Data Portal/Tables/Organizations', | ||
component: OrganizationTable, | ||
parameters: { | ||
layoutWrapper: 'centeredFullscreen', | ||
msw: [organization.forOrganizationTable], | ||
rqDevtools: true, | ||
}, | ||
} satisfies Meta<typeof OrganizationTable> | ||
|
||
type StoryDef = StoryObj<typeof OrganizationTable> | ||
|
||
export const Default = {} satisfies StoryDef |
Oops, something went wrong.