-
Notifications
You must be signed in to change notification settings - Fork 0
[APP] Add Expo Router formSheet modal for typical dish details #353
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
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c67e397
feat(310): update docs and icons
timothyrusso 73db352
feat(310): use clerk profile image
timothyrusso 8bae8fd
feat(310): use clerk user name
timothyrusso 08df106
feat(310): update clerk library
timothyrusso d9ba224
feat(310): add new image provider
timothyrusso f802c3e
feat(310): add new food properties
timothyrusso d2539af
feat(310): increase food category keywords
timothyrusso a12f94c
feat(310): update food fallback image
timothyrusso 7c30d02
feat(310): add typical dishes new modal
timothyrusso 08950a9
feat(310): remove old modals
timothyrusso e433d1e
feat(310): add modal header
timothyrusso f270464
feat(310): add location to the modal header
timothyrusso 0fb992a
feat(310): move dish list into the modal
timothyrusso 322afc3
feat(310): style the dish list
timothyrusso ca81c7f
feat(310): use proper key labels for dishes
timothyrusso 7f96fa2
feat(310): style the button for the dishes
timothyrusso 2a6e895
feat(310): style the android top border modal
timothyrusso 96db286
feat(310): type properly the form sheet options
timothyrusso 703b332
fix(310): lint errors
timothyrusso 19c19c9
fix(310): lint errors
timothyrusso ea04769
fix(310): guard for nested fields
timothyrusso 4624103
fix(310): truncate long location names in TypicalDishesModalHeader
timothyrusso 788ddba
fix(310): use searchTerm as stable key in TypicalDishesList
timothyrusso 40ef180
fix(310): use endsWith for image extension check in WikimediaDishImag…
timothyrusso 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
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
7 changes: 7 additions & 0 deletions
7
app/(main)/(authenticated)/create-trip/typical-dishes-modal.tsx
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { TypicalDishesModalPage } from '@/features/trips/pages'; | ||
|
|
||
| const TypicalDishesModal = () => { | ||
| return <TypicalDishesModalPage />; | ||
| }; | ||
|
|
||
| export default TypicalDishesModal; |
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
58 changes: 0 additions & 58 deletions
58
features/auth/ui/components/ResetPasswordModal/ResetPasswordModal.logic.ts
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
features/auth/ui/components/ResetPasswordModal/ResetPasswordModal.tsx
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
features/core/images/data/dtos/WikimediaSearchResponseDTO.ts
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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| export type WikimediaExtMetadataDTO = { | ||
| Restrictions?: { value: string }; | ||
| DeletionReason?: { value: string }; | ||
| }; | ||
|
|
||
| export type WikimediaImageInfoDTO = { | ||
| thumburl: string; | ||
| width: number; | ||
| height: number; | ||
| extmetadata?: WikimediaExtMetadataDTO; | ||
| }; | ||
|
|
||
| export type WikimediaCategoryDTO = { | ||
| title: string; | ||
| }; | ||
|
|
||
| export type WikimediaPageDTO = { | ||
| pageid: number; | ||
| title: string; | ||
| categories?: WikimediaCategoryDTO[]; | ||
| imageinfo?: WikimediaImageInfoDTO[]; | ||
| }; | ||
|
|
||
| export type WikimediaSearchResponseDTO = { | ||
| query?: { | ||
| pages?: Record<string, WikimediaPageDTO>; | ||
| }; | ||
| }; |
78 changes: 78 additions & 0 deletions
78
features/core/images/data/repositories/WikimediaDishImageRepository.ts
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 |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import type { Result } from '@/features/core/error'; | ||
| import { ok } from '@/features/core/error'; | ||
| import type { IHttpClient } from '@/features/core/http'; | ||
| import { HTTP_TYPES } from '@/features/core/http'; | ||
| import type { | ||
| WikimediaPageDTO, | ||
| WikimediaSearchResponseDTO, | ||
| } from '@/features/core/images/data/dtos/WikimediaSearchResponseDTO'; | ||
| import type { ImageFetchOptions } from '@/features/core/images/domain/entities/ImageFetchOptions'; | ||
| import type { ImageResult } from '@/features/core/images/domain/entities/ImageResult'; | ||
| import { FOOD_CATEGORY_KEYWORDS } from '@/features/core/images/domain/entities/foodCategoryKeywords'; | ||
| import type { IImageRepository } from '@/features/core/images/domain/entities/repositories/IImageRepository'; | ||
| import { inject, injectable } from 'inversify'; | ||
|
|
||
| const BASE_URL = 'https://commons.wikimedia.org/w/api.php'; | ||
| const USER_AGENT = 'HolidAI/1.0 (https://github.com/timothyrusso/holidai)'; | ||
| const ALLOWED_IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png'] as const; | ||
| const MIN_IMAGE_DIMENSION_PX = 400; | ||
|
|
||
| @injectable() | ||
| export class WikimediaDishImageRepository implements IImageRepository { | ||
| constructor(@inject(HTTP_TYPES.HttpClient) private readonly http: IHttpClient) {} | ||
|
|
||
| async getImage(dish: string, options?: ImageFetchOptions): Promise<Result<ImageResult | null>> { | ||
| const urlWidth = options?.maxWidthPx ?? 800; | ||
| const params = new URLSearchParams({ | ||
| action: 'query', | ||
| generator: 'search', | ||
| gsrsearch: `${dish} food haswbstatement:P180`, | ||
| gsrnamespace: '6', | ||
| gsrlimit: '20', | ||
| gsrsort: 'relevance', | ||
| prop: 'imageinfo|categories', | ||
| iiprop: 'url|dimensions|extmetadata', | ||
| cllimit: '50', | ||
| iiurlwidth: String(urlWidth), | ||
| iimetadataversion: 'latest', | ||
| format: 'json', | ||
| origin: '*', | ||
| }); | ||
|
|
||
| const result = await this.http.get<WikimediaSearchResponseDTO>(`${BASE_URL}?${params.toString()}`, { | ||
| headers: { 'User-Agent': USER_AGENT }, | ||
| }); | ||
|
|
||
| if (!result.success) return result; | ||
|
|
||
| const pages = Object.values(result.data.query?.pages ?? {}); | ||
| const info = pages.find(p => this.isUsableImage(p, dish))?.imageinfo?.[0] ?? null; | ||
|
|
||
| if (!info) return ok(null); | ||
| return ok({ url: info.thumburl }); | ||
| } | ||
|
|
||
| private isUsableImage(page: WikimediaPageDTO, dish: string): boolean { | ||
| const info = page.imageinfo?.[0]; | ||
| if (!info?.thumburl) return false; | ||
| if (info.width < MIN_IMAGE_DIMENSION_PX && info.height < MIN_IMAGE_DIMENSION_PX) return false; | ||
|
timothyrusso marked this conversation as resolved.
timothyrusso marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
| if (!this.isAllowedImageExtension(info.thumburl)) return false; | ||
| if (info.extmetadata?.Restrictions?.value) return false; | ||
| if (!this.hasFoodCategory(page, dish)) return false; | ||
| return true; | ||
| } | ||
|
|
||
| private isAllowedImageExtension(url: string): boolean { | ||
| const lower = url.toLowerCase(); | ||
| return ALLOWED_IMAGE_EXTENSIONS.some(ext => lower.endsWith(ext)); | ||
| } | ||
|
|
||
| private hasFoodCategory(page: WikimediaPageDTO, dish: string): boolean { | ||
| if (!page.categories?.length) return false; | ||
| const lowerDish = dish.toLowerCase(); | ||
| return page.categories.some(cat => { | ||
| const lowerCat = cat.title.toLowerCase(); | ||
| return lowerCat.includes(lowerDish) || FOOD_CATEGORY_KEYWORDS.some(kw => lowerCat.includes(kw)); | ||
| }); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.