-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASAP-497 Manuscript Eligibility (#4330)
- Loading branch information
Showing
27 changed files
with
998 additions
and
85 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
apps/crn-frontend/src/network/teams/EligibilityReasonProvider.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,32 @@ | ||
import React, { createContext, useState } from 'react'; | ||
|
||
type EligibilityReasonContextData = { | ||
eligibilityReasons: Set<string>; | ||
setEligibilityReasons: (newEligibilityReason: Set<string>) => void; | ||
}; | ||
|
||
export const EligibilityReasonContext = | ||
createContext<EligibilityReasonContextData>( | ||
{} as EligibilityReasonContextData, | ||
); | ||
|
||
export const EligibilityReasonProvider = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
const [eligibilityReasons, setEligibilityReasons] = useState<Set<string>>( | ||
new Set(), | ||
); | ||
|
||
return ( | ||
<EligibilityReasonContext.Provider | ||
value={{ | ||
eligibilityReasons, | ||
setEligibilityReasons, | ||
}} | ||
> | ||
{children} | ||
</EligibilityReasonContext.Provider> | ||
); | ||
}; |
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
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,5 @@ | ||
import { useContext } from 'react'; | ||
|
||
import { EligibilityReasonContext } from './EligibilityReasonProvider'; | ||
|
||
export const useEligibilityReason = () => useContext(EligibilityReasonContext); |
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
34 changes: 34 additions & 0 deletions
34
packages/contentful/migrations/crn/manuscripts/20240711172003-add-eligibility-field.js
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,34 @@ | ||
module.exports.description = 'Create eligibility field'; | ||
|
||
module.exports.up = (migration) => { | ||
const manuscripts = migration.editContentType('manuscripts'); | ||
|
||
manuscripts | ||
.createField('eligibilityReasons') | ||
.name('Eligibility Reasons') | ||
.type('Array') | ||
.localized(false) | ||
.required(false) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false) | ||
.items({ | ||
type: 'Symbol', | ||
validations: [ | ||
{ | ||
in: ['projects', 'method-or-resource', 'pivot', 'leadership'], | ||
}, | ||
], | ||
}); | ||
manuscripts.changeFieldControl( | ||
'eligibilityReasons', | ||
'builtin', | ||
'checkbox', | ||
{}, | ||
); | ||
}; | ||
|
||
module.exports.down = (migration) => { | ||
const manuscripts = migration.editContentType('manuscripts'); | ||
manuscripts.deleteField('eligibilityReasons'); | ||
}; |
Oops, something went wrong.