-
-
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.
feat(data-portal): organization table (#718)
# Pull Request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Issue Number: IN-854 ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Other information PR-URL: #718 Co-authored-by: Joe Karow <[email protected]>
- Loading branch information
Showing
14 changed files
with
667 additions
and
18 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.