-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/sdk-completion' into dev
- Loading branch information
Showing
12 changed files
with
297 additions
and
90 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,5 @@ | ||
--- | ||
"@frak-labs/nexus-sdk": patch | ||
--- | ||
|
||
Add a `modalBuilder` to ease modal creation |
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,29 +1,13 @@ | ||
import { loginModalStep } from "./config"; | ||
|
||
export function modalShare() { | ||
const finalAction = { | ||
key: "sharing", | ||
options: { | ||
popupTitle: "Share this article with your friends", | ||
text: "Discover this awesome article", | ||
link: typeof window !== "undefined" ? window.location.href : "", | ||
}, | ||
} as const; | ||
if (!window.FrakSetup.frakClient) { | ||
if (!window.FrakSetup.modalBuilder) { | ||
console.error("Frak client not initialized"); | ||
return; | ||
} | ||
window.NexusSDK.displayModal(window.FrakSetup.frakClient, { | ||
metadata: { | ||
lang: "fr", | ||
isDismissible: true, | ||
}, | ||
steps: { | ||
login: loginModalStep, | ||
openSession: {}, | ||
final: { | ||
action: finalAction, | ||
}, | ||
}, | ||
}); | ||
window.FrakSetup.modalBuilder | ||
.sharing({ | ||
popupTitle: "Share this article with your friends", | ||
text: "Discover this awesome article", | ||
link: typeof window !== "undefined" ? window.location.href : "", | ||
}) | ||
.display(); | ||
} |
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,31 @@ | ||
/** | ||
* Function used to track the status of a purchase | ||
*/ | ||
export async function trackPurchaseStatus(args: { | ||
customerId: string | number; | ||
orderId: string | number; | ||
token: string; | ||
}) { | ||
if (typeof window === "undefined") { | ||
console.warn("[Frak] No window found, can't track purchase"); | ||
return; | ||
} | ||
const interactionToken = window.sessionStorage.getItem( | ||
"frak-wallet-interaction-token" | ||
); | ||
if (!interactionToken) { | ||
console.warn("[Frak] No frak session found, skipping purchase check"); | ||
return; | ||
} | ||
|
||
// Submit the listening request | ||
await fetch("https://backend.frak.id/interactions/listenForPurchase", { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"x-wallet-sdk-auth": interactionToken, | ||
}, | ||
body: JSON.stringify(args), | ||
}); | ||
} |
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.