-
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.
Merge pull request #74 from readme-experts/ts-migrate
feat: Migrate client to Typescript
- Loading branch information
Showing
63 changed files
with
639 additions
and
372 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 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 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,22 @@ | ||
import { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { AuthStoreError } from '../../slices/types/Auth/AuthState'; | ||
import { thunkErrorWrapper } from '../../utils/thunkErrorWrapper'; | ||
import { RecipeModel } from '../../../services/models/RecipeModel'; | ||
|
||
export const addFavoriteRecipe = createAppAsyncThunk<RecipeModel, | ||
{ userId: number, recipe: RecipeModel }, | ||
{ rejectValue: AuthStoreError }>( | ||
'account/addFavoriteRecipe', | ||
async ({ userId, recipe }, thunkAPI) => { | ||
if (!thunkAPI.extra.userService.token) { | ||
thunkAPI.extra.userService.setToken(thunkAPI.getState().account.token); | ||
} | ||
const thunk = thunkErrorWrapper( | ||
thunkAPI.extra.userService.addFavoriteRecipe, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.userService | ||
); | ||
await thunk(userId, recipe.id); | ||
return recipe; | ||
}, | ||
); |
16 changes: 0 additions & 16 deletions
16
src/client/src/app/actions/account/deleteFavoriteRecipe.js
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/client/src/app/actions/account/deleteFavoriteRecipe.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,22 @@ | ||
import { AuthStoreError } from '../../slices/types/Auth/AuthState'; | ||
import { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { thunkErrorWrapper } from '../../utils/thunkErrorWrapper'; | ||
import { RecipeModel } from '../../../services/models/RecipeModel'; | ||
|
||
export const deleteFavoriteRecipe = createAppAsyncThunk<RecipeModel, | ||
{ recipe : RecipeModel }, | ||
{ rejectValue: AuthStoreError }>( | ||
'account/deleteFavoriteRecipe', | ||
async ({ recipe }, thunkAPI) => { | ||
if (!thunkAPI.extra.userService.token) { | ||
thunkAPI.extra.userService.setToken(thunkAPI.getState().account.token); | ||
} | ||
const thunk = thunkErrorWrapper( | ||
thunkAPI.extra.userService.deleteFavoriteRecipe, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.userService | ||
); | ||
await thunk(recipe.id); | ||
return recipe; | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
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 { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { RecipeModel } from '../../../services/models/RecipeModel'; | ||
import { AuthStoreError } from '../../slices/types/Auth/AuthState'; | ||
import { thunkErrorWrapper } from '../../utils/thunkErrorWrapper'; | ||
|
||
export const loadFavoriteRecipes = createAppAsyncThunk<RecipeModel[], | ||
null, | ||
{ rejectValue: AuthStoreError }>( | ||
'account/loadUserFavorites', | ||
async (_, thunkAPI) => { | ||
if (!thunkAPI.extra.userService.token) { | ||
thunkAPI.extra.userService.setToken(thunkAPI.getState().account.token); | ||
} | ||
const thunk = thunkErrorWrapper( | ||
thunkAPI.extra.userService.getFavoriteRecipes, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.userService | ||
); | ||
return await thunk(); | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
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 { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { AuthStoreError } from '../../slices/types/Auth/AuthState'; | ||
import { AuthFulfilled } from '../../slices/types/Auth/AuthFulfilled'; | ||
import { UserDTO } from '../../../services/DTO/UserDTO'; | ||
import { thunkErrorWrapper } from '../../utils/thunkErrorWrapper'; | ||
|
||
export const loginUser = createAppAsyncThunk<AuthFulfilled, | ||
UserDTO, | ||
{ rejectValue: AuthStoreError }>( | ||
'account/login', | ||
async ({ email, password }: UserDTO, thunkAPI) => { | ||
const thunk = thunkErrorWrapper( | ||
thunkAPI.extra.authService.login, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.authService | ||
); | ||
return await thunk(email, password); | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { AuthFulfilled } from '../../slices/types/Auth/AuthFulfilled'; | ||
import { UserDTO } from '../../../services/DTO/UserDTO'; | ||
import { AuthStoreError } from '../../slices/types/Auth/AuthState'; | ||
|
||
export const registerUser = createAppAsyncThunk<AuthFulfilled, | ||
UserDTO, | ||
{ rejectValue: AuthStoreError }>( | ||
'account/register', | ||
async ({ username, password }, thunkAPI) => { | ||
const thunk = thunkAPI.extra.thunkErrorWrapper( | ||
thunkAPI.extra.authService.register, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.authService | ||
); | ||
return await thunk(username, password); | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
import { RecipeModel } from '../../../services/models/RecipeModel'; | ||
import { createAppAsyncThunk } from '../../utils/createAppAsyncThunk'; | ||
import { RecipeStoreError } from '../../slices/types/Recipe/RecipeState'; | ||
import { thunkErrorWrapper } from '../../utils/thunkErrorWrapper'; | ||
|
||
export const loadRecipes = createAppAsyncThunk<RecipeModel[], | ||
string, | ||
{ rejectValue: RecipeStoreError }>( | ||
'recipes/loadRecipes', | ||
async (queryString: string, thunkAPI) => { | ||
if (!thunkAPI.extra.recipeService.token) { | ||
thunkAPI.extra.recipeService.setToken(thunkAPI.getState().account.token); | ||
} | ||
const thunk = thunkErrorWrapper( | ||
thunkAPI.extra.recipeService.getRecipesByName, | ||
thunkAPI.rejectWithValue, | ||
thunkAPI.extra.recipeService | ||
); | ||
const params = new URLSearchParams({ recipeName: queryString }); | ||
return await thunk(params); | ||
}, | ||
); |
Oops, something went wrong.