-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: created shopper common * feat: updated react shopper hooks to use common elements from shopper common * chore: changeset * fix: import was using local path * chore: changeset * chore: updated examples
- Loading branch information
Showing
58 changed files
with
303 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@elasticpath/react-shopper-hooks": minor | ||
"@elasticpath/shopper-common": patch | ||
--- | ||
|
||
- created shopper common package for common utilities and types | ||
- updated react shopper hooks to use common elements from shopper common |
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 @@ | ||
--- | ||
"@elasticpath/d2c-schematics": patch | ||
--- | ||
|
||
import was using local path |
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
6 changes: 4 additions & 2 deletions
6
packages/react-shopper-hooks/lib/cart/types/cart-reducer-types.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
29 changes: 18 additions & 11 deletions
29
packages/react-shopper-hooks/lib/payment-gateway-register/use-payment-gateway.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,34 +1,41 @@ | ||
import { useContext } from "react"; | ||
import { PGRContext } from "./payment-gateway-provider"; | ||
import { useContext } from "react" | ||
import { PGRContext } from "./payment-gateway-provider" | ||
import { | ||
PGRAction, | ||
PGRState, | ||
ResolvePaymentFunction, | ||
SupportedGateway, | ||
} from "./types/payment-gateway-reducer-types"; | ||
} from "./types/payment-gateway-reducer-types" | ||
|
||
export function usePaymentGateway() { | ||
const context = useContext(PGRContext); | ||
export function usePaymentGateway(): { | ||
registerGateway: ( | ||
resolvePayment: ResolvePaymentFunction, | ||
type: SupportedGateway, | ||
) => void | ||
state: PGRState | ||
} { | ||
const context = useContext(PGRContext) | ||
|
||
if (context === undefined) { | ||
throw new Error("usePaymentGateway must be used within a PGRProvider"); | ||
throw new Error("usePaymentGateway must be used within a PGRProvider") | ||
} | ||
|
||
const { state, dispatch } = context; | ||
const { state, dispatch } = context | ||
|
||
return { | ||
registerGateway: _registerGateway(dispatch), | ||
state, | ||
}; | ||
} | ||
} | ||
|
||
function _registerGateway(dispatch: (action: PGRAction) => void) { | ||
return ( | ||
resolvePayment: ResolvePaymentFunction, | ||
type: SupportedGateway | ||
type: SupportedGateway, | ||
): void => { | ||
dispatch({ | ||
type: "update-payment-gateway-register", | ||
payload: { type, resolvePayment }, | ||
}); | ||
}; | ||
}) | ||
} | ||
} |
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,6 +1,4 @@ | ||
export * from "./bundle-provider" | ||
export * from "./use-bundle-hook" | ||
export * from "./util/create-bundle-configure-validator" | ||
export * from "./use-bundle-component-options-hook" | ||
export * from "./bundle.types" | ||
export * from "./use-bundle-component-hook" |
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.