Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dist/FlamSaasSDK.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion examples/vanilla-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ function buyCard(id) {
let orderDetails = {
productId: id,
refId: random,
logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Facebook_f_logo_%282019%29.svg/2048px-Facebook_f_logo_%282019%29.svg.png"
prefill: {
name: 'Yuvraj Singh',
email: 'support@email.com',
phone: '+91 98765 43210'
}
// logo: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Facebook_f_logo_%282019%29.svg/2048px-Facebook_f_logo_%282019%29.svg.png'
};

flam.placeOrder(orderDetails, (err, res) => {
Expand Down
4 changes: 2 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app';
//const SDK_BASE_URL = 'http://localhost:3000';
const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app';
// const SDK_BASE_URL = 'http://localhost:3000';

export const PAGES = {
main: SDK_BASE_URL,
Expand Down
1 change: 1 addition & 0 deletions src/placeOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default async function placeOrder(order_details, callback) {

// render the success UI
let url = `${PAGES.main}`;

this.callback = callback;

await this.renderWithRetry(url);
Expand Down
1 change: 1 addition & 0 deletions src/receiveMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function receiveMessage(event) {
this.sendMessage({
type: 'INITIAL_DATA_ERR',
payload: {
...this.clientData,
email:
this.order_details &&
this.order_details.prefill &&
Expand Down
4 changes: 3 additions & 1 deletion ui/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
NEXT_PUBLIC_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_SANDBOX_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_SANDBOX_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_BACKEND_AUTH_KEY=7cc88f57ac9789058ea3e42e8329d0f52ef86acb
NEXT_PUBLIC_SANDBOX_BACKEND_AUTH_KEY=7cc88f57ac9789058ea3e42e8329d0f52ef86acb
4 changes: 3 additions & 1 deletion ui/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
NEXT_PUBLIC_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_SANDBOX_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_SANDBOX_BACKEND_URL=https://api.flamapp.com/saas
NEXT_PUBLIC_BACKEND_AUTH_KEY=7cc88f57ac9789058ea3e42e8329d0f52ef86acb
NEXT_PUBLIC_SANDBOX_BACKEND_AUTH_KEY=7cc88f57ac9789058ea3e42e8329d0f52ef86acb
54 changes: 49 additions & 5 deletions ui/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import axios from 'axios';

const backend_base_URL = process.env.NEXT_PUBLIC_BACKEND_URL;
const backend_sandbox_base_URL = process.env.NEXT_PUBLIC_SANDBOX_BACKEND_URL;

const getUrl = (env: 'SANDBOX' | 'PRODUCTION') =>
env == 'PRODUCTION' ? backend_base_URL : backend_sandbox_base_URL;
env == 'PRODUCTION'
? process.env.NEXT_PUBLIC_BACKEND_URL
: process.env.NEXT_PUBLIC_SANDBOX_BACKEND_URL;

const getAuthKey = (env: 'SANDBOX' | 'PRODUCTION') =>
env == 'PRODUCTION'
? process.env.NEXT_PUBLIC_BACKEND_AUTH_KEY
: process.env.NEXT_PUBLIC_SANDBOX_BACKEND_AUTH_KEY;

export const getProductData = async ({
env = 'SANDBOX',
Expand Down Expand Up @@ -33,7 +37,7 @@ export const getSignedURL = async (
) => {
const res = await axios.post(`${getUrl(env)}/orders/v2/signed_url`, data, {
headers: {
Authorization: 'Token 7cc88f57ac9789058ea3e42e8329d0f52ef86acb'
Authorization: `Token ${getAuthKey(env)}`
}
});
return res.data;
Expand Down Expand Up @@ -90,3 +94,43 @@ export const getCLientData = async ({

return res.data;
};

export const getCreatedProductData = async ({
env = 'SANDBOX',
flamCardId
}: {
env: 'SANDBOX' | 'PRODUCTION';
flamCardId: string;
}) => {
// /api/v1/orders/flamcard?flamcard_id=bee5c2d4-20fb-4b7f-8d91-0746a5117ca7
const res = await axios.get(`${getUrl(env)}/api/v1/orders/flamcard`, {
params: {
flamcard_id: flamCardId
},
headers: {
Authorization: `Token ${getAuthKey(env)}`
}
});

return res.data;
};

export const updateCard = async ({
env = 'SANDBOX',
data
}: {
env: 'SANDBOX' | 'PRODUCTION';
data: {
flamcardId: string;
newVideoUrl: string;
};
}) => {
const res = await axios.post(`${getUrl(env)}/api/v1/videochange`, data, {
// api/v1/videochange
headers: {
Authorization: `Token ${getAuthKey(env)}`
}
});

return res;
};
65 changes: 0 additions & 65 deletions ui/components/atoms/Text.tsx

This file was deleted.

14 changes: 8 additions & 6 deletions ui/components/molecules/ProductImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function ProductImage({
setData
}: {
existingPhoto: string;
photo: any;
setData: Dispatch<SetStateAction<any>>;
photo?: any;
setData?: Dispatch<SetStateAction<any>>;
}) {
const [files, setFiles] = useState<any[]>([]);

Expand All @@ -31,10 +31,12 @@ function ProductImage({
)
);

setData((prev: any) => ({
...prev,
photo: acceptedFiles[0]
}));
if (setData) {
setData((prev: any) => ({
...prev,
photo: acceptedFiles[0]
}));
}
}
});

Expand Down
12 changes: 7 additions & 5 deletions ui/components/organisms/ModalFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ModalFooter = ({
showLaterOption: boolean;
handleSubmit: (data: any) => void;
is_deferred: boolean;
setData: Dispatch<SetStateAction<any>>;
setData?: Dispatch<SetStateAction<any>>;
}) => {
return (
<div
Expand All @@ -30,10 +30,12 @@ const ModalFooter = ({
className="flex items-baseline gap-2 cursor-pointer"
onClick={e => {
e.preventDefault();
setData((prev: any) => ({
...prev,
is_deferred: !is_deferred
}));
if (setData) {
setData((prev: any) => ({
...prev,
is_deferred: !is_deferred
}));
}
}}
>
{is_deferred ? (
Expand Down
4 changes: 2 additions & 2 deletions ui/components/organisms/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function ModalHeader({
}: {
title: string;
showPhoto: boolean;
photo: File;
setData: Dispatch<SetStateAction<any>>;
photo?: File;
setData?: Dispatch<SetStateAction<any>>;
existingPhoto: string;
clientData: {
name: string;
Expand Down
8 changes: 4 additions & 4 deletions ui/components/organisms/VideoUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { IoMdImage } from 'react-icons/io';
import DropArea from '../atoms/DropArea';

const VideoUpload = ({
is_defered,
existingVideo,
is_defered = false,
existingVideo = '',
video,
setData
}: {
is_defered: boolean;
existingVideo: string;
is_defered?: boolean;
existingVideo?: string;
video: any;
setData: Dispatch<SetStateAction<any>>;
}) => {
Expand Down
11 changes: 10 additions & 1 deletion ui/hooks/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ function useMessage(environment: 'SANDBOX' | 'PRODUCTION') {
}
}, [environment]);

const receiveMessage = (
event: ReceivedEventType,
handleMessage: (event: ReceivedEventType) => void
) => {
if (event.origin.concat('/') === parentUrl) {
handleMessage(event);
}
};

function sendMessage(message: { type: string; payload?: any }) {
parent.postMessage({ ...message, parentUrl }, parentUrl);
}

return { sendMessage, ready: Boolean(parentUrl), parentUrl };
return { sendMessage, receiveMessage, parentUrl };
}

export default useMessage;
18 changes: 18 additions & 0 deletions ui/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import FlexCenter from '../components/atoms/FlexCenter';

const NotFound = () => {
return (
<div className="h-screen w-screen bg-white">
<FlexCenter col className="gap-4">
<h1 className="text-3xl font-medium">404 | Page not found</h1>
<a href="https://saas-business.web.app/">
<button className="bg-brand_blue text-white text-sm font-bold py-2 px-16 h-min w-full rounded-lg">
Go back to main page
</button>
</a>
</FlexCenter>
</div>
);
};

export default NotFound;
Loading