-
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.
* Move add edit note to feature folder * Moved MealsList to widgets * Moved notes helpers to entities * Moved DeleteNote to features * Refactored module public api exports * Moved CategorySelect and useCategorySelect to entities * Moved note form data type to features * Moved useAppSelector and useAppDispatch to store.ts * Removed usePopover * Moved utils to shared/lib * Moved types to shared/types * Moved hooks to shared/hooks * Moved config to shared/config * Moved components to shared/components * Moved api to shared/api * Reorganized app folder * Fixed app folder case sensitivity issue * Removed default exports * Moved src/testing to tests * Moved src/test-utils to tests * Moved setupTests.ts to tests * Renamed AutocompleteOptionType to AutocompleteOption
- Loading branch information
Showing
210 changed files
with
702 additions
and
900 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
src/frontend/src/App.test.tsx → src/frontend/src/app/Root/Root.test.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
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,8 @@ | ||
import { type PropsWithChildren, type FC } from 'react'; | ||
import { RouterProvider } from 'react-router-dom'; | ||
import { createAppRouter } from '../router'; | ||
import { RootLoader } from './RootLoader'; | ||
|
||
export const Root: FC<PropsWithChildren> = ({ children }) => ( | ||
<RouterProvider router={createAppRouter(children)} fallbackElement={<RootLoader />} /> | ||
); |
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 @@ | ||
export * from './Root'; |
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,24 @@ | ||
import { CssBaseline, StyledEngineProvider, ThemeProvider } from '@mui/material'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers'; | ||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; | ||
import { type PropsWithChildren, type FC } from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { type Store } from 'redux'; | ||
import { theme } from './theme'; | ||
|
||
interface Props { | ||
store: Store; | ||
} | ||
|
||
export const RootProvider: FC<PropsWithChildren<Props>> = ({ children, store }) => ( | ||
<StyledEngineProvider injectFirst> | ||
<ThemeProvider theme={theme}> | ||
<LocalizationProvider dateAdapter={AdapterDateFns}> | ||
<Provider store={store}> | ||
<CssBaseline /> | ||
{children} | ||
</Provider> | ||
</LocalizationProvider> | ||
</ThemeProvider> | ||
</StyledEngineProvider> | ||
); |
2 changes: 1 addition & 1 deletion
2
src/frontend/src/googleAnalytics.ts → src/frontend/src/app/googleAnalytics.ts
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
.../features/categories/api/categoriesApi.ts → .../src/entities/category/api/categoryApi.ts
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
File renamed without changes.
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,2 @@ | ||
export * from './categoryApi'; | ||
export * from './contracts'; |
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 @@ | ||
export * from './api'; | ||
export * as categoryLib from './lib'; | ||
export * as categoryModel from './model'; | ||
export * from './ui'; |
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 @@ | ||
export * from './useCategorySelectData'; |
16 changes: 16 additions & 0 deletions
16
src/frontend/src/entities/category/lib/useCategorySelectData.ts
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,16 @@ | ||
import { type SelectOption } from '@/shared/types'; | ||
import { categoryApi } from '../api'; | ||
|
||
export interface CategorySelectData { | ||
data: SelectOption[]; | ||
isLoading: boolean; | ||
} | ||
|
||
export const useCategorySelectData = (): CategorySelectData => { | ||
const query = categoryApi.useGetCategorySelectOptionsQuery(); | ||
|
||
return { | ||
data: query.data ?? [], | ||
isLoading: query.isLoading, | ||
}; | ||
}; |
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 @@ | ||
export interface Category { | ||
id: number; | ||
name: string; | ||
countProducts: number; | ||
} |
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 @@ | ||
export * from './CategorySelect'; |
2 changes: 1 addition & 1 deletion
2
...ntend/src/features/notes/api/contracts.ts → ...ontend/src/entities/note/api/contracts.ts
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
2 changes: 1 addition & 1 deletion
2
src/frontend/src/features/notes/api/index.ts → src/frontend/src/entities/note/api/index.ts
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './contracts'; | ||
export * from './notesApi'; | ||
export * from './noteApi'; |
16 changes: 10 additions & 6 deletions
16
...ontend/src/features/notes/api/notesApi.ts → ...frontend/src/entities/note/api/noteApi.ts
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,3 @@ | ||
export * from './api'; | ||
export * as noteModel from './model'; | ||
export * as noteLib from './lib'; |
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,19 @@ | ||
import { type NoteItem, type MealType } from '../model'; | ||
|
||
const assignNoteToGroup = ( | ||
groups: Map<MealType, NoteItem[]>, | ||
note: NoteItem, | ||
): Map<MealType, NoteItem[]> => { | ||
const notes = groups.get(note.mealType); | ||
|
||
if (notes) { | ||
notes.push(note); | ||
} else { | ||
groups.set(note.mealType, [note]); | ||
} | ||
|
||
return groups; | ||
}; | ||
|
||
export const groupByMealType = (notes: NoteItem[]): Map<MealType, NoteItem[]> => | ||
notes.reduce(assignNoteToGroup, new Map<MealType, NoteItem[]>()); |
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,3 @@ | ||
export * from './useNotes'; | ||
export * from './groupByMealType'; | ||
export * from './mealsHelpers'; |
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,21 @@ | ||
import { MealType } from '../model'; | ||
|
||
const AVAILABLE_MEALS: Map<MealType, string> = new Map<MealType, string>([ | ||
[MealType.Breakfast, 'Breakfast'], | ||
[MealType.SecondBreakfast, 'Second breakfast'], | ||
[MealType.Lunch, 'Lunch'], | ||
[MealType.AfternoonSnack, 'Afternoon snack'], | ||
[MealType.Dinner, 'Dinner'], | ||
]); | ||
|
||
export const getMealTypes = (): MealType[] => Array.from(AVAILABLE_MEALS.keys()); | ||
|
||
export const getMealName = (mealType: MealType): string => { | ||
const mealName = AVAILABLE_MEALS.get(mealType); | ||
|
||
if (!mealName) { | ||
throw new Error(`Meal type = '${mealType}' doesn't exist`); | ||
} | ||
|
||
return mealName; | ||
}; |
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,18 @@ | ||
export enum MealType { | ||
Breakfast = 1, | ||
SecondBreakfast = 2, | ||
Lunch = 3, | ||
AfternoonSnack = 4, | ||
Dinner = 5, | ||
} | ||
|
||
export interface NoteItem { | ||
id: number; | ||
mealType: MealType; | ||
displayOrder: number; | ||
productId: number; | ||
productName: string; | ||
productQuantity: number; | ||
productDefaultQuantity: number; | ||
calories: number; | ||
} |
Oops, something went wrong.