-
Notifications
You must be signed in to change notification settings - Fork 0
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
20 changed files
with
1,710 additions
and
1,485 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
fragment BioRiskFields on BioRisk { | ||
code | ||
enabled | ||
} |
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,5 @@ | ||
mutation AddBioRisk($code: String!) { | ||
addBioRisk(code: $code) { | ||
...BioRiskFields | ||
} | ||
} |
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,5 @@ | ||
mutation SetBioRiskEnabled($code: String!, $enabled: Boolean!) { | ||
setBioRiskEnabled(code: $code, enabled: $enabled) { | ||
...BioRiskFields | ||
} | ||
} |
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,5 @@ | ||
query GetBioRisks($includeDisabled: Boolean) { | ||
bioRisks(includeDisabled: $includeDisabled) { | ||
...BioRiskFields | ||
} | ||
} |
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 |
---|---|---|
|
@@ -27,4 +27,7 @@ query GetRegistrationInfo { | |
slotRegions { | ||
name | ||
} | ||
bioRisks { | ||
code | ||
} | ||
} |
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,9 @@ | ||
import { Factory } from 'fishery'; | ||
import { BioRisk } from '../../types/sdk'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
export default Factory.define<BioRisk>(({ params, sequence }) => ({ | ||
__typename: 'BioRisk', | ||
code: faker.lorem.word() + sequence, | ||
enabled: params.enabled ?? true | ||
})); |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { graphql, HttpResponse } from 'msw'; | ||
import { | ||
AddBioRiskMutation, | ||
AddBioRiskMutationVariables, | ||
GetBioRisksQuery, | ||
GetBioRisksQueryVariables, | ||
SetBioRiskEnabledMutation, | ||
SetBioRiskEnabledMutationVariables | ||
} from '../../types/sdk'; | ||
import { isEnabled } from '../../lib/helpers'; | ||
import BioRiskRepository from '../repositories/bioRiskRepository'; | ||
import bioRiskRepository from '../repositories/bioRiskRepository'; | ||
import bioRiskFactory from '../../lib/factories/bioRiskFactory'; | ||
|
||
const bioRiskHandler = [ | ||
graphql.mutation<AddBioRiskMutation, AddBioRiskMutationVariables>('AddBioRisk', ({ variables }) => { | ||
const bioRisk = bioRiskFactory.build({ | ||
code: variables.code | ||
}); | ||
bioRiskRepository.save(bioRisk); | ||
return HttpResponse.json({ data: { addBioRisk: bioRisk } }, { status: 200 }); | ||
}), | ||
|
||
graphql.mutation<SetBioRiskEnabledMutation, SetBioRiskEnabledMutationVariables>( | ||
'SetBioRiskEnabled', | ||
({ variables }) => { | ||
const comment = bioRiskRepository.find('code', variables.code); | ||
if (comment) { | ||
comment.enabled = variables.enabled; | ||
bioRiskRepository.save(comment); | ||
return HttpResponse.json({ data: { setBioRiskEnabled: comment } }, { status: 200 }); | ||
} else { | ||
return HttpResponse.json( | ||
{ errors: [{ message: `Could not find comment: "${variables.code}"` }] }, | ||
{ status: 404 } | ||
); | ||
} | ||
} | ||
), | ||
|
||
graphql.query<GetBioRisksQuery, GetBioRisksQueryVariables>('GetBioRisks', ({ variables }) => { | ||
return HttpResponse.json( | ||
{ | ||
data: { | ||
bioRisks: BioRiskRepository.findAll().filter((bioRisk) => variables.includeDisabled || isEnabled(bioRisk)) | ||
} | ||
}, | ||
{ status: 200 } | ||
); | ||
}) | ||
]; | ||
|
||
export default bioRiskHandler; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { BioRisk } from '../../types/sdk'; | ||
import { createSessionStorageRepository } from './index'; | ||
import bioRiskFactory from '../../lib/factories/bioRiskFactory'; | ||
|
||
const seeds: Array<BioRisk> = bioRiskFactory.buildList(5); | ||
seeds.push(bioRiskFactory.build({ enabled: false })); | ||
seeds.push(bioRiskFactory.build({ code: 'bioRisk1' })); | ||
|
||
const bioRiskRepository = createSessionStorageRepository('BIORISKS', 'code', seeds); | ||
|
||
export default bioRiskRepository; |
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.