-
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.
building out cart update endpoint with edge cases • typing enhancements
- Loading branch information
1 parent
60f0479
commit 2aa2e7f
Showing
22 changed files
with
184 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
export const errFormatResponseUtil = (err) => { | ||
return { message: err?.statusText, status: err?.status }; | ||
return { message: err?.message, statusText: err?.statusText, status: err?.status }; | ||
}; | ||
|
||
export const errFormat500ResponseUtil = () => { | ||
return { statusText: 'The server was unable to complete your request.', status: 500 }; | ||
return { | ||
message: 'The server was unable to complete your request.', | ||
statusText: '', | ||
status: 500, | ||
}; | ||
}; |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
.cartContent { | ||
padding: 15px; | ||
height: calc(100% - 60px); | ||
overflow-x: scroll; | ||
} | ||
|
||
.middleRow { | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import UiCartModal from './cart.modal'; | ||
import UiCartModal from './cart.modal.view'; | ||
|
||
export { UiCartModal }; |
37 changes: 37 additions & 0 deletions
37
libs/features/src/lib/cart/cart.modal/use.cart.modal.logic.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,37 @@ | ||
import { useGetCart, useUpdateCart } from '@pokemon-pet-shop/services'; | ||
import { CartDataApi, GenericNonReturnType } from '@pokemon-pet-shop/typing'; | ||
|
||
interface UseCartModalReturn { | ||
data: CartDataApi; | ||
onHandleRemoveFromCart: GenericNonReturnType; | ||
onHandleAddToCart: GenericNonReturnType; | ||
} | ||
|
||
const useCartModalLogic = (): UseCartModalReturn => { | ||
const { data } = useGetCart(); | ||
const updateCartMutation = useUpdateCart(); | ||
|
||
const handleAddToCart = (id: string) => { | ||
updateCartMutation.mutate({ | ||
id, | ||
addToCart: true, | ||
removeFromCart: false, | ||
}); | ||
}; | ||
|
||
const handleRemoveFromCart = (id: string) => { | ||
updateCartMutation.mutate({ | ||
id, | ||
addToCart: false, | ||
removeFromCart: true, | ||
}); | ||
}; | ||
|
||
return { | ||
data, | ||
onHandleRemoveFromCart: handleRemoveFromCart, | ||
onHandleAddToCart: handleAddToCart, | ||
}; | ||
}; | ||
|
||
export default useCartModalLogic; |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface CartApiPayload { | ||
id: string; | ||
addToCart?: boolean; | ||
removeFromCart?: boolean; | ||
} | ||
|
||
export interface CartDataContentApi { | ||
id: string; | ||
name: string; | ||
price: number; | ||
quantity: number; | ||
image: string; | ||
isLegendary: boolean; | ||
isMythical: boolean; | ||
} | ||
|
||
export interface CartDataApi { | ||
data: CartDataContentApi[]; | ||
counter: number; | ||
total: 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
Oops, something went wrong.