-
Notifications
You must be signed in to change notification settings - Fork 5
Core 1079 port adoption and interest pages to ts #2763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
RoyEJohnson
merged 7 commits into
main
from
core-1079-port-adoption-and-interest-pages-to-ts
Aug 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f3e67ad
Adoption & Interest pages
RoyEJohnson e545c02
General page
RoyEJohnson 71cbd61
Cover partners page filter-remover
RoyEJohnson b64da58
General page test coverage
RoyEJohnson 20c0da6
adoption and interest tests
RoyEJohnson 8e3f53e
Make role-selector test less flaky
RoyEJohnson 1d92257
Prettier
RoyEJohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Adoption & Interest pages
- Loading branch information
commit f3e67ad16fcf02ec29bacd5766cf4bdb6a14de1c
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,14 +11,18 @@ import {useAfterSubmit} from '~/components/book-selector/after-form-submit'; | |
| import BookSelector, { | ||
| useSelectedBooks | ||
| } from '~/components/book-selector/book-selector'; | ||
| import {SalesforceBook} from '~/helpers/books'; | ||
| import HowUsing from './how-using/how-using'; | ||
| import useSalesforceContext from '~/contexts/salesforce'; | ||
| import useFormTarget from '~/components/form-target/form-target'; | ||
| import TrackingParameters from '~/components/tracking-parameters/tracking-parameters'; | ||
| import {useIntl} from 'react-intl'; | ||
| import './adoption.scss'; | ||
|
|
||
| function BookSelectorPage({selectedBooksRef, year}) { | ||
| function BookSelectorPage({selectedBooksRef, year}: { | ||
| selectedBooksRef: React.MutableRefObject<SalesforceBook[]>; | ||
| year?: string; | ||
| }) { | ||
| const [selectedBooks, toggleBook] = useSelectedBooks(); | ||
| const bookList = React.useMemo( | ||
| () => selectedBooks.map((b) => b.value.replace(/ *\[.*/, '')).join('; '), | ||
|
|
@@ -27,7 +31,7 @@ function BookSelectorPage({selectedBooksRef, year}) { | |
| const {formatMessage} = useIntl(); | ||
| const instructions = formatMessage({id: 'adoption.instructions'}); | ||
| const includeFilter = React.useCallback( | ||
| (b) => !b.comingSoon, | ||
| (b: SalesforceBook) => !b.comingSoon, | ||
| [] | ||
| ); | ||
|
|
||
|
|
@@ -36,10 +40,9 @@ function BookSelectorPage({selectedBooksRef, year}) { | |
| <React.Fragment> | ||
| <BookSelector | ||
| prompt={formatMessage({id: 'adoption.book-prompt'})} | ||
| required | ||
| selectedBooks={selectedBooks} | ||
| toggleBook={toggleBook} | ||
| limit="5" | ||
| limit={5} | ||
| additionalInstructions={instructions} | ||
| includeFilter={includeFilter} | ||
| /> | ||
|
|
@@ -53,39 +56,37 @@ function BookSelectorPage({selectedBooksRef, year}) { | |
| ); | ||
| } | ||
|
|
||
| function FacultyForm({position, onPageChange}) { | ||
| const selectedBooksRef = useRef(); | ||
| function FacultyForm({position, onPageChange}: { | ||
| position: string; | ||
| onPageChange: (page: number) => void; | ||
| }) { | ||
| const selectedBooksRef = useRef<SalesforceBook[]>([]); | ||
| const afterSubmit = useAfterSubmit(selectedBooksRef); | ||
| const {onSubmit, submitting, FormTarget} = useFormTarget(afterSubmit); | ||
| const {adoptionUrl} = useSalesforceContext(); | ||
| const validatePage = React.useCallback( | ||
| (page) => { | ||
| if (page === 1 && position === 'Student') { | ||
| return false; | ||
| } | ||
| (page: number) => { | ||
| if (page === 2 && selectedBooksRef.current.length < 1) { | ||
| return false; | ||
| } | ||
| return true; | ||
| }, | ||
| [position] | ||
| [] | ||
| ); | ||
| const doSubmit = React.useCallback( | ||
| (form) => { | ||
| if (selectedBooksRef.current?.length > 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't get here with no selected books. |
||
| form.submit(); | ||
| onSubmit(); | ||
| } | ||
| (form: HTMLFormElement) => { | ||
| form.submit(); | ||
| onSubmit(); | ||
| }, | ||
| [onSubmit] | ||
| ); | ||
| const {search} = useLocation(); | ||
| const selectedYear = new window.URLSearchParams(search).get('year') ?? undefined; | ||
| const [copyOfYear, setCopyOfYear] = React.useState(); | ||
| const [copyOfYear, setCopyOfYear] = React.useState<string>(); | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| <FormTarget submitting={submitting} /> | ||
| <FormTarget /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. submitting isn't handled with a parameter anymore. |
||
| <MultiPageForm | ||
| validatePage={validatePage} action={adoptionUrl} | ||
| onPageChange={onPageChange} onSubmit={doSubmit} | ||
|
|
@@ -96,7 +97,7 @@ function FacultyForm({position, onPageChange}) { | |
| <input type="hidden" name="position" value={position} /> | ||
| <input type="hidden" name="role" value="Instructor" /> | ||
| <input type="hidden" name="lead_source" value="Adoption Form" /> | ||
| <input type="hidden" name="process_adoptions" value={true} /> | ||
| <input type="hidden" name="process_adoptions" value="true" /> | ||
| <div className="year-selector-container"> | ||
| <YearSelector selectedYear={selectedYear} onValueUpdate={setCopyOfYear} /> | ||
| </div> | ||
|
|
@@ -111,11 +112,11 @@ function FacultyForm({position, onPageChange}) { | |
| export default function AdoptionForm() { | ||
| const [selectedRole, setSelectedRole] = useState(''); | ||
| const [hideRoleSelector, setHideRoleSelector] = useState(false); | ||
| const ref = useRef(); | ||
| const ref = useRef<HTMLDivElement>(null); | ||
| const onPageChange = React.useCallback( | ||
| (page) => { | ||
| (page: number) => { | ||
| setHideRoleSelector(page > 1); | ||
| ref.current.scrollIntoView(); | ||
| ref.current?.scrollIntoView(); | ||
| }, | ||
| [] | ||
| ); | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Student processing can't get here