Skip to content

Commit

Permalink
Add Dashboard page (Uploads table), create a reusable TableBuilder (#51)
Browse files Browse the repository at this point in the history
* feature/3 create Dashboard page and Uploads table, add mock data for uploads array

* feature/3 add CRUD pages for Uploads

* feature/CPF-3 display Bootstrap table with Upload data, remove previous hardcoded table

* feature/CPF-3 add sorting to columns

* feature/CPF-3 move column helper functions into a separate file, clean up Uploads table, add Bootstrap sorting icons

* feature/3 replace bootstrap icons for sort, WIP filter

* feature/CPF-3 separate TableBuilder headers and columns into their own components, cleanup

* feature/CPF-3 add resetColumnFilters to reset button, add conditional styling if no filter is present

* feature/CPF-3 extract latest valid and invalid validation for upload, create a date converter util, disable sorting for Validation column

* feature/3 add useCallback to prevent useEffect() hook from triggering too many times, delete duplicate DebouncedInput, fix eslint errors in api/src

* feature/3 update logic around upload validations
  • Loading branch information
Vikariusu authored Dec 15, 2023
1 parent d1c4265 commit 5a2dde3
Show file tree
Hide file tree
Showing 39 changed files with 49,833 additions and 3,816 deletions.
1 change: 1 addition & 0 deletions api/src/services/agencies/agencies.scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, agency } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.agencyCreateArgs>({
Expand Down
25 changes: 12 additions & 13 deletions api/src/services/agencies/agencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ export const deleteAgency: MutationResolvers['deleteAgency'] = ({ id }) => {
})
}

export const agenciesByOrganization: QueryResolvers['agenciesByOrganization'] = async ({
organizationId,
}) => {
try {
const agencies = await db.agency.findMany({
where: { organizationId },
})
return agencies || [] // Return an empty array if null is received
} catch (error) {
console.error(error)
// Handle the error appropriately; maybe log it and return an empty array
return []
export const agenciesByOrganization: QueryResolvers['agenciesByOrganization'] =
async ({ organizationId }) => {
try {
const agencies = await db.agency.findMany({
where: { organizationId },
})
return agencies || [] // Return an empty array if null is received
} catch (error) {
console.error(error)
// Handle the error appropriately; maybe log it and return an empty array
return []
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, ExpenditureCategory } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.ExpenditureCategoryCreateArgs>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, InputTemplate } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.InputTemplateCreateArgs>({
Expand Down
1 change: 1 addition & 0 deletions api/src/services/organizations/organizations.scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, Organization } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.OrganizationCreateArgs>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, OutputTemplate } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.OutputTemplateCreateArgs>({
Expand Down
1 change: 1 addition & 0 deletions api/src/services/projects/projects.scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, Project } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.ProjectCreateArgs>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, ReportingPeriod } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.ReportingPeriodCreateArgs>({
Expand Down
1 change: 1 addition & 0 deletions api/src/services/roles/roles.scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, Role } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.RoleCreateArgs>({
Expand Down
83 changes: 0 additions & 83 deletions api/src/services/uploadValidations/uploadValidations.test.ts

This file was deleted.

40 changes: 20 additions & 20 deletions api/src/services/uploads/uploads.scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const standard = defineScenario<Prisma.UploadCreateArgs>({
one: {
data: {
filename: 'String',
updatedAt: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-10T04:48:04.896Z',
uploadedBy: {
create: {
email: 'String',
updatedAt: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-10T04:48:04.896Z',
organization: { create: { name: 'String' } },
},
},
Expand All @@ -20,23 +20,23 @@ export const standard = defineScenario<Prisma.UploadCreateArgs>({
reportingPeriod: {
create: {
name: 'String',
startDate: '2023-12-08T21:03:09.638Z',
endDate: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-08T21:03:09.638Z',
startDate: '2023-12-10T04:48:04.896Z',
endDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
inputTemplate: {
create: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-08T21:03:09.638Z',
effectiveDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
outputTemplate: {
create: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-08T21:03:09.638Z',
effectiveDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
},
Expand All @@ -45,19 +45,19 @@ export const standard = defineScenario<Prisma.UploadCreateArgs>({
create: {
name: 'String',
code: 'String',
updatedAt: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
},
},
two: {
data: {
filename: 'String',
updatedAt: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-10T04:48:04.896Z',
uploadedBy: {
create: {
email: 'String',
updatedAt: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-10T04:48:04.896Z',
organization: { create: { name: 'String' } },
},
},
Expand All @@ -66,23 +66,23 @@ export const standard = defineScenario<Prisma.UploadCreateArgs>({
reportingPeriod: {
create: {
name: 'String',
startDate: '2023-12-08T21:03:09.638Z',
endDate: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-08T21:03:09.638Z',
startDate: '2023-12-10T04:48:04.896Z',
endDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
inputTemplate: {
create: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-08T21:03:09.638Z',
updatedAt: '2023-12-08T21:03:09.638Z',
effectiveDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
outputTemplate: {
create: {
name: 'String',
version: 'String',
effectiveDate: '2023-12-08T21:03:09.639Z',
updatedAt: '2023-12-08T21:03:09.639Z',
effectiveDate: '2023-12-10T04:48:04.896Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
},
Expand All @@ -91,7 +91,7 @@ export const standard = defineScenario<Prisma.UploadCreateArgs>({
create: {
name: 'String',
code: 'String',
updatedAt: '2023-12-08T21:03:09.639Z',
updatedAt: '2023-12-10T04:48:04.896Z',
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/uploads/uploads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('uploads', () => {
organizationId: scenario.upload.two.organizationId,
reportingPeriodId: scenario.upload.two.reportingPeriodId,
expenditureCategoryId: scenario.upload.two.expenditureCategoryId,
updatedAt: '2023-12-08T21:03:09.551Z',
updatedAt: '2023-12-10T04:48:04.888Z',
},
})

Expand All @@ -51,7 +51,7 @@ describe('uploads', () => {
expect(result.expenditureCategoryId).toEqual(
scenario.upload.two.expenditureCategoryId
)
expect(result.updatedAt).toEqual(new Date('2023-12-08T21:03:09.551Z'))
expect(result.updatedAt).toEqual(new Date('2023-12-10T04:48:04.888Z'))
})

scenario('updates a upload', async (scenario: StandardScenario) => {
Expand Down
1 change: 1 addition & 0 deletions api/src/services/users/users.scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma, User } from '@prisma/client'

import type { ScenarioData } from '@redwoodjs/testing/api'

export const standard = defineScenario<Prisma.UserCreateArgs>({
Expand Down
Loading

0 comments on commit 5a2dde3

Please sign in to comment.