-
Couldn't load subscription status.
- Fork 14
Bugfix: Custom icon missing from search suggestion results for RFPs #474
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,25 @@ export function getContentTypePath(contentType: ContentType): string { | |
|
|
||
| return contentType.toLowerCase(); | ||
| } | ||
|
|
||
| /** | ||
| * Maps document types from the API to content types for URL building | ||
| * @param documentType The document type from the API (e.g., 'GRANT', 'PREREGISTRATION', 'DISCUSSION') | ||
| * @returns The corresponding content type for URL building | ||
| */ | ||
| export function mapApiContentTypeToClientType( | ||
| documentType: string | ||
| ): 'paper' | 'post' | 'funding_request' | 'preregistration' { | ||
| const contentTypeMap: Record<string, 'paper' | 'post' | 'funding_request' | 'preregistration'> = { | ||
syqs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| GRANT: 'funding_request', | ||
| PREREGISTRATION: 'preregistration', | ||
| DISCUSSION: 'post', | ||
| ELN: 'post', | ||
| NOTE: 'post', | ||
| PAPER: 'paper', | ||
| QUESTION: 'post', | ||
| BOUNTY: 'post', | ||
| HYPOTHESIS: 'post', | ||
| }; | ||
| return contentTypeMap[documentType] || 'post'; | ||
|
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. I'd rather we not use post as default. We can return null as well if no appropriate match is found 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. hm.. if we switch it to null that might potentially break few things and would require a bigger refactor of the codebase to incorporate the new approach which is why it was defaulting to post in the first place. Pros:
Cons:
My recommendation is to keep the |
||
| } | ||
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.
We need to do cleanup because
funding_requestandpreregistrationmean the same thing.I feel like Nick created this function already in one of his PRs. @nicktytarenko - can you confirm?
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.
if i am not mistaken
funding_requestis the same thing asgrantin the web app world.. you can see the evidence in this historical mocked data: https://github.com/ResearchHub/web/blob/main/store/grantStore.ts#L27there was naming changes to this entity. so, it's probably still confused in the web app 🤯
actually we do not have a function to convert API contentType to the App type, we do it on a fly when we transform the work details response in the types/work.ts.
if you pull the latest
maininto this branch you will see the method for convertingWebApptypeToAPIType. it's like the opposite of thiscc @yattias