Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Oct 31, 2024
2 parents 5101797 + 92ea6e4 commit f0b4bda
Show file tree
Hide file tree
Showing 42 changed files with 3,760 additions and 410 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-cars-worry.md
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
30 changes: 16 additions & 14 deletions example/vanilla-js/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { setupFrakClient } from "./module/setupClient";
import { displayWalletStatus } from "./module/walletStatus";

// Export the setup function and config for use in other files
window.FrakSetup = { frakConfig, frakClient: null, modalShare };
window.FrakSetup = {
frakConfig,
frakClient: null,
modalShare,
modalBuilder: null,
};

document.addEventListener("DOMContentLoaded", () => {
console.log("NexusSDK", window.NexusSDK);
Expand All @@ -16,22 +21,19 @@ document.addEventListener("DOMContentLoaded", () => {
return;
}

const modalStepBuilder = window.NexusSDK.modalBuilder(frakClient, {
metadata: {
lang: "fr",
isDismissible: true,
},
login: loginModalStep,
});

window.FrakSetup.frakClient = frakClient;
window.FrakSetup.modalBuilder = modalStepBuilder;

window.NexusSDK.referralInteraction(frakClient, {
modalConfig: {
steps: {
login: loginModalStep,
openSession: {},
final: {
action: { key: "reward" },
},
},
metadata: {
lang: "fr",
isDismissible: true,
},
},
modalConfig: modalStepBuilder.reward().params,
options: {
alwaysAppendUrl: true,
},
Expand Down
15 changes: 2 additions & 13 deletions example/vanilla-js/src/module/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { loginModalStep } from "./config";

export function bindLoginButton() {
const loginButton = document.getElementById("login-button");
loginButton?.addEventListener("click", handleLogin);
Expand All @@ -19,20 +17,11 @@ async function handleLogin() {
loginButton.textContent = "Logging in...";

try {
if (!window.FrakSetup.frakClient) {
if (!window.FrakSetup.modalBuilder) {
console.error("Frak client not initialized");
return;
}
await window.NexusSDK.displayModal(window.FrakSetup.frakClient, {
metadata: {
lang: "fr",
isDismissible: true,
},
steps: {
login: loginModalStep,
openSession: {},
},
});
await window.FrakSetup.modalBuilder.display();
loginButton.textContent = "Logged In";
} catch (error) {
console.error("Login error:", error);
Expand Down
32 changes: 8 additions & 24 deletions example/vanilla-js/src/module/modalShare.ts
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();
}
4 changes: 4 additions & 0 deletions example/vanilla-js/src/types/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type {
ModalBuilder,
displayModal,
modalBuilder,
referralInteraction,
watchWalletStatus,
} from "@frak-labs/nexus-sdk/actions";
Expand All @@ -18,11 +20,13 @@ declare global {
displayModal: typeof displayModal;
referralInteraction: typeof referralInteraction;
watchWalletStatus: typeof watchWalletStatus;
modalBuilder: typeof modalBuilder;
};
FrakSetup: {
frakConfig: NexusWalletSdkConfig;
frakClient: NexusClient | null;
modalShare: () => void;
modalBuilder: ModalBuilder | null;
};
}
}
10 changes: 10 additions & 0 deletions packages/backend-elysia/drizzle/dev/0005_bumpy_odin.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Drop items that would conflict with the created index
DELETE FROM "product_oracle_purchase_item"
WHERE id NOT IN (
SELECT MIN(id)
FROM "product_oracle_purchase_item"
GROUP BY "external_id", "purchase_id"
);

-- Create the index
CREATE UNIQUE INDEX IF NOT EXISTS "unique_external_purchase_item_id" ON "product_oracle_purchase_item" USING btree ("external_id","purchase_id");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DO $$ BEGIN
CREATE TYPE "public"."product_oracle_plateform" AS ENUM('shopify', 'woocommerce', 'custom');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "product_oracle" ADD COLUMN "plateform" "product_oracle_plateform" DEFAULT 'shopify' NOT NULL;--> statement-breakpoint
ALTER TABLE "product_oracle_purchase_item" ADD COLUMN "image_url" varchar;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "product_oracle" RENAME COLUMN "plateform" TO "platform";
Loading

0 comments on commit f0b4bda

Please sign in to comment.