@katajere/recap 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RecapStory.d.ts.map +1 -1
- package/dist/RecapStory.js +20 -1
- package/dist/StoryProgress.d.ts.map +1 -1
- package/dist/StoryProgress.js +0 -3
- package/dist/data/mock.js +2 -2
- package/dist/index.css +6 -1
- package/dist/store/auth.d.ts +40 -0
- package/dist/store/auth.d.ts.map +1 -0
- package/dist/store/auth.js +40 -0
- package/dist/utils/Helpers.d.ts +7 -0
- package/dist/utils/Helpers.d.ts.map +1 -0
- package/dist/utils/Helpers.js +21 -0
- package/dist/utils/RecapApi.d.ts +3 -0
- package/dist/utils/RecapApi.d.ts.map +1 -0
- package/dist/utils/RecapApi.js +34 -0
- package/dist/utils/Services/AuthServices.d.ts +11 -0
- package/dist/utils/Services/AuthServices.d.ts.map +1 -0
- package/dist/utils/Services/AuthServices.js +13 -0
- package/package.json +10 -2
- package/src/App.tsx +32 -24
- package/src/LoginScreen.tsx +90 -24
- package/src/OtpScreen.tsx +97 -25
- package/src/RecapStory.tsx +21 -1
- package/src/StoryProgress.tsx +0 -3
- package/src/data/mock.ts +2 -2
- package/src/index.css +6 -1
- package/src/store/auth.tsx +72 -0
- package/src/store/data.tsx +59 -0
- package/src/utils/Helpers.tsx +25 -0
- package/src/utils/RecapApi.tsx +38 -0
- package/src/utils/Services/AuthServices.tsx +15 -0
package/dist/RecapStory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecapStory.d.ts","sourceRoot":"","sources":["../src/RecapStory.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAuB,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,kBAAkB,CAAC;AAK1B,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"RecapStory.d.ts","sourceRoot":"","sources":["../src/RecapStory.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAuB,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,kBAAkB,CAAC;AAK1B,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,eAAe,2CA+YjD;AAED,eAAe,UAAU,CAAC"}
|
package/dist/RecapStory.js
CHANGED
|
@@ -27,11 +27,30 @@ const recapMusic = "https://katajereassets.blob.core.windows.net/recap-videos/re
|
|
|
27
27
|
function RecapStory({ recapData }) {
|
|
28
28
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
29
29
|
const durations = recapData.slideDurations || defaultDurations;
|
|
30
|
-
|
|
30
|
+
// Start paused when in video generation mode - orchestrator will unpause via window.__RECAP_START__
|
|
31
|
+
const [isPaused, setIsPaused] = useState(recapData.isVideo === true);
|
|
31
32
|
const [isShareVisible, setIsShareVisible] = useState(false);
|
|
32
33
|
const holdTimerRef = useRef(null);
|
|
33
34
|
const isHoldingRef = useRef(false);
|
|
34
35
|
const slidesContainerRef = useRef(null);
|
|
36
|
+
// Expose global start function for video generation orchestrator
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (recapData.isVideo) {
|
|
39
|
+
// Expose function to start the story (used by Puppeteer after recording starts)
|
|
40
|
+
window.__RECAP_START__ = () => {
|
|
41
|
+
setIsPaused(false);
|
|
42
|
+
};
|
|
43
|
+
// Also add a ready flag so orchestrator knows the component is mounted
|
|
44
|
+
window.__RECAP_READY__ = true;
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
// Cleanup global functions
|
|
48
|
+
if (recapData.isVideo) {
|
|
49
|
+
delete window.__RECAP_START__;
|
|
50
|
+
delete window.__RECAP_READY__;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, [recapData.isVideo]);
|
|
35
54
|
// Cleanup on unmount to prevent memory leaks
|
|
36
55
|
React.useEffect(() => {
|
|
37
56
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryProgress.d.ts","sourceRoot":"","sources":["../src/StoryProgress.tsx"],"names":[],"mappings":"AACA,OAAO,qBAAqB,CAAC;AAE7B,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,iBAAS,aAAa,CAAC,EACrB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"StoryProgress.d.ts","sourceRoot":"","sources":["../src/StoryProgress.tsx"],"names":[],"mappings":"AACA,OAAO,qBAAqB,CAAC;AAE7B,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,iBAAS,aAAa,CAAC,EACrB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE,kBAAkB,2CAyGpB;AAED,eAAe,aAAa,CAAC"}
|
package/dist/StoryProgress.js
CHANGED
|
@@ -36,9 +36,6 @@ function StoryProgress({ total, active, duration, onComplete, onBarClick, hideBo
|
|
|
36
36
|
// Resume from paused progress
|
|
37
37
|
startTimeRef.current = performance.now();
|
|
38
38
|
const startProgress = pausedProgressRef.current;
|
|
39
|
-
if (startProgress >= 1) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
39
|
if (startProgress >= 1) {
|
|
43
40
|
setProgress(1);
|
|
44
41
|
onCompleteRef.current();
|
package/dist/data/mock.js
CHANGED
|
@@ -53,8 +53,8 @@ export const mockRecapData = {
|
|
|
53
53
|
],
|
|
54
54
|
businessCategory: BUSINESS_CATEGORIES.THRIVING,
|
|
55
55
|
busiestMonth: "Oct",
|
|
56
|
-
videoUrl: "https://katajereassets.blob.core.windows.net/
|
|
57
|
-
downloadUrl: "https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/
|
|
56
|
+
videoUrl: "https://katajereassets.blob.core.windows.net/recap-videos/recap_4e5f6a7b-8c9d-0e1f-2a3b-4c5d6e7f8a9b_738c9226abe1a8f1a07263948a2d175e.mp4",
|
|
57
|
+
downloadUrl: "https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/recap-videos/recap_4e5f6a7b-8c9d-0e1f-2a3b-4c5d6e7f8a9b_738c9226abe1a8f1a07263948a2d175e.mp4",
|
|
58
58
|
isVideo: false,
|
|
59
59
|
websiteLink: "https://vendor.huxxle.com",
|
|
60
60
|
websiteVisits: 123400,
|
package/dist/index.css
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/* Google Fonts import for Lora - must be first for priority loading */
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap');
|
|
3
|
+
@import 'tailwindcss';
|
|
1
4
|
body {
|
|
2
5
|
margin: 0;
|
|
3
|
-
|
|
6
|
+
/* Lora as primary, with emoji font fallbacks for cross-platform emoji support */
|
|
7
|
+
font-family: 'Lora', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
|
|
8
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
9
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
10
|
sans-serif;
|
|
6
11
|
-webkit-font-smoothing: antialiased;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type AuthState = {
|
|
2
|
+
token: string;
|
|
3
|
+
business: {
|
|
4
|
+
business_name: string;
|
|
5
|
+
business_image: string;
|
|
6
|
+
business_type: string;
|
|
7
|
+
business_phone: string;
|
|
8
|
+
business_website: string;
|
|
9
|
+
business_address: string;
|
|
10
|
+
business_city: string;
|
|
11
|
+
business_state: string;
|
|
12
|
+
business_zip_code: string;
|
|
13
|
+
subdomain: string;
|
|
14
|
+
website_status: string;
|
|
15
|
+
website_status_by_admin: string;
|
|
16
|
+
social_facebook: string;
|
|
17
|
+
social_instagram: string;
|
|
18
|
+
social_twitter: string;
|
|
19
|
+
social_tiktok: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type AuthActions = {
|
|
23
|
+
updateToken: (token: string) => void;
|
|
24
|
+
updateBusiness: (businessData: AuthState["business"]) => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const useAuthStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AuthState & AuthActions>, "setState" | "persist"> & {
|
|
27
|
+
setState(partial: (AuthState & AuthActions) | Partial<AuthState & AuthActions> | ((state: AuthState & AuthActions) => (AuthState & AuthActions) | Partial<AuthState & AuthActions>), replace?: false | undefined): unknown;
|
|
28
|
+
setState(state: (AuthState & AuthActions) | ((state: AuthState & AuthActions) => AuthState & AuthActions), replace: true): unknown;
|
|
29
|
+
persist: {
|
|
30
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AuthState & AuthActions, unknown, unknown>>) => void;
|
|
31
|
+
clearStorage: () => void;
|
|
32
|
+
rehydrate: () => Promise<void> | void;
|
|
33
|
+
hasHydrated: () => boolean;
|
|
34
|
+
onHydrate: (fn: (state: AuthState & AuthActions) => void) => () => void;
|
|
35
|
+
onFinishHydration: (fn: (state: AuthState & AuthActions) => void) => () => void;
|
|
36
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AuthState & AuthActions, unknown, unknown>>;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/store/auth.tsx"],"names":[],"mappings":"AAGA,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,uBAAuB,EAAE,MAAM,CAAC;QAChC,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AACF,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC/D,CAAC;AAuBF,eAAO,MAAM,YAAY;;;;;;;;;;;;EAqBxB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { persist, createJSONStorage } from "zustand/middleware";
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
const initialState = {
|
|
4
|
+
token: "",
|
|
5
|
+
business: {
|
|
6
|
+
business_name: "",
|
|
7
|
+
business_image: "",
|
|
8
|
+
business_type: "",
|
|
9
|
+
business_phone: "",
|
|
10
|
+
business_website: "",
|
|
11
|
+
business_address: "",
|
|
12
|
+
business_city: "",
|
|
13
|
+
business_state: "",
|
|
14
|
+
business_zip_code: "",
|
|
15
|
+
subdomain: "",
|
|
16
|
+
website_status: "",
|
|
17
|
+
website_status_by_admin: "",
|
|
18
|
+
social_facebook: "",
|
|
19
|
+
social_instagram: "",
|
|
20
|
+
social_tiktok: "",
|
|
21
|
+
social_twitter: "",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const useAuthStore = create()(persist((set) => ({
|
|
25
|
+
...initialState,
|
|
26
|
+
updateToken: (token) => set(() => ({ token })),
|
|
27
|
+
clearToken: () => {
|
|
28
|
+
set(() => ({
|
|
29
|
+
token: "",
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
updateBusiness: (businessData) => {
|
|
33
|
+
set(() => ({
|
|
34
|
+
business: businessData,
|
|
35
|
+
}));
|
|
36
|
+
},
|
|
37
|
+
}), {
|
|
38
|
+
name: "auth-storage",
|
|
39
|
+
storage: createJSONStorage(() => localStorage),
|
|
40
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../src/utils/Helpers.tsx"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,YAYzC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jwtDecode } from "jwt-decode";
|
|
2
|
+
/**
|
|
3
|
+
* Validate if the token is valid or has expired
|
|
4
|
+
* @param token the jwt token
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export const isTokenValid = (token) => {
|
|
8
|
+
try {
|
|
9
|
+
if (!token)
|
|
10
|
+
return false;
|
|
11
|
+
const decoded = jwtDecode(token);
|
|
12
|
+
if (Date.now() >= decoded.exp * 1000) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error("Token decoding failed:", error);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecapApi.d.ts","sourceRoot":"","sources":["../../src/utils/RecapApi.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,QAAQ,qCA8Bb,CAAC;AACF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { isTokenValid } from "./Helpers";
|
|
4
|
+
import { useAuthStore } from "../store/auth";
|
|
5
|
+
const RecapApi = () => {
|
|
6
|
+
let headers = {};
|
|
7
|
+
const token = useAuthStore.getState().token ||
|
|
8
|
+
(() => {
|
|
9
|
+
const userAuthStore = localStorage.getItem("auth-storage");
|
|
10
|
+
if (userAuthStore) {
|
|
11
|
+
const parsedAuthStore = JSON.parse(userAuthStore);
|
|
12
|
+
return parsedAuthStore.token;
|
|
13
|
+
}
|
|
14
|
+
return null; // Return null if token is not found in either store or localStorage
|
|
15
|
+
})();
|
|
16
|
+
if (token) {
|
|
17
|
+
if (!isTokenValid(token)) {
|
|
18
|
+
sessionStorage.removeItem("auth-storage");
|
|
19
|
+
localStorage.removeItem("auth-storage"); // Also clear from local storage
|
|
20
|
+
window.location.href = "/";
|
|
21
|
+
}
|
|
22
|
+
headers = {
|
|
23
|
+
Authorization: `Bearer ${token}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const baseURL = import.meta.env.VITE_REACT_APP_KATAJERE_BASE_URL || "";
|
|
27
|
+
const axiosInstance = axios.create({
|
|
28
|
+
baseURL,
|
|
29
|
+
timeout: 60000, // Default timeout (will be overridden by interceptor)
|
|
30
|
+
headers,
|
|
31
|
+
});
|
|
32
|
+
return axiosInstance;
|
|
33
|
+
};
|
|
34
|
+
export default RecapApi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const AuthService: {
|
|
2
|
+
login: (payload: {
|
|
3
|
+
email: string;
|
|
4
|
+
}) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
5
|
+
verifyOtp: (payload: {
|
|
6
|
+
email: string;
|
|
7
|
+
otp: string;
|
|
8
|
+
}) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
9
|
+
recapData: () => Promise<any>;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=AuthServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthServices.d.ts","sourceRoot":"","sources":["../../../src/utils/Services/AuthServices.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;qBACC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;yBAGb;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;;CAQ1D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import RecapApi from "../RecapApi";
|
|
2
|
+
export const AuthService = {
|
|
3
|
+
login: async (payload) => {
|
|
4
|
+
return await RecapApi().post("/auth/login", payload);
|
|
5
|
+
},
|
|
6
|
+
verifyOtp: async (payload) => {
|
|
7
|
+
return await RecapApi().post("/auth/verify-otp", payload);
|
|
8
|
+
},
|
|
9
|
+
recapData: async () => {
|
|
10
|
+
const data = await RecapApi().get("/recap");
|
|
11
|
+
return data.data;
|
|
12
|
+
}
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katajere/recap",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Vendor Year in Review Experience - Recap your business metrics for 2025",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -51,10 +51,18 @@
|
|
|
51
51
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
55
|
+
"@tanstack/react-query": "^5.90.12",
|
|
56
|
+
"axios": "^1.13.2",
|
|
54
57
|
"framer-motion": "^12.0.0",
|
|
55
58
|
"html2canvas": "^1.4.1",
|
|
59
|
+
"jwt-decode": "^4.0.0",
|
|
56
60
|
"react": "^18.0.0 || ^19.0.0",
|
|
57
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
61
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
62
|
+
"react-hook-form": "^7.68.0",
|
|
63
|
+
"react-hot-toast": "^2.6.0",
|
|
64
|
+
"tailwindcss": "^4.1.18",
|
|
65
|
+
"zustand": "^5.0.9"
|
|
58
66
|
},
|
|
59
67
|
"devDependencies": {
|
|
60
68
|
"@types/node": "^24.10.1",
|
package/src/App.tsx
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { AnimatePresence } from
|
|
3
|
-
import LoginScreen from
|
|
4
|
-
import OtpScreen from
|
|
5
|
-
import RecapStory from
|
|
6
|
-
import { AUTH_STEPS, AuthStep } from
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { AnimatePresence } from "framer-motion";
|
|
3
|
+
import LoginScreen from "./LoginScreen";
|
|
4
|
+
import OtpScreen from "./OtpScreen";
|
|
5
|
+
import RecapStory from "./RecapStory";
|
|
6
|
+
import { AUTH_STEPS, AuthStep } from "./types";
|
|
7
|
+
import "./App.css";
|
|
8
|
+
import { useRecapDataStore } from "./store/data";
|
|
9
|
+
import { useAuthStore } from "./store/auth";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Main App component
|
|
12
13
|
* Manages auth state machine: login → otp → recap
|
|
13
14
|
*/
|
|
14
15
|
function App() {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
16
|
+
const recapData = useRecapDataStore((state) => state.recapData);
|
|
17
|
+
const token = useAuthStore((state) => state.token);
|
|
18
|
+
|
|
19
|
+
const [authStep, setAuthStep] = useState<AuthStep>(
|
|
20
|
+
token ? AUTH_STEPS.RECAP : AUTH_STEPS.LOGIN
|
|
21
|
+
);
|
|
22
|
+
const [identifier, setIdentifier] = useState<string>("");
|
|
23
|
+
|
|
24
|
+
// Skip to recap if token becomes available
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (token) {
|
|
27
|
+
setAuthStep(AUTH_STEPS.RECAP);
|
|
28
|
+
}
|
|
29
|
+
}, [token]);
|
|
17
30
|
|
|
18
31
|
// Handle login submission
|
|
19
32
|
const handleLogin = (value: string) => {
|
|
@@ -24,45 +37,40 @@ function App() {
|
|
|
24
37
|
// Handle OTP submission
|
|
25
38
|
const handleOtpSubmit = (otp: string) => {
|
|
26
39
|
// In production, verify OTP with backend here
|
|
27
|
-
console.log(
|
|
40
|
+
console.log("OTP submitted:", otp);
|
|
41
|
+
|
|
28
42
|
setAuthStep(AUTH_STEPS.RECAP);
|
|
29
43
|
};
|
|
30
44
|
|
|
31
45
|
// Handle back from OTP to login
|
|
32
46
|
const handleBackToLogin = () => {
|
|
33
47
|
setAuthStep(AUTH_STEPS.LOGIN);
|
|
34
|
-
setIdentifier(
|
|
48
|
+
setIdentifier("");
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
return (
|
|
38
52
|
<div className="app">
|
|
39
53
|
{/* Desktop backdrop blur */}
|
|
40
54
|
<div className="app__backdrop" />
|
|
41
|
-
|
|
55
|
+
|
|
42
56
|
{/* Story shell (390x844 phone frame) */}
|
|
43
57
|
<div className="app__shell">
|
|
44
58
|
<AnimatePresence mode="wait">
|
|
45
59
|
{authStep === AUTH_STEPS.LOGIN && (
|
|
46
|
-
<LoginScreen
|
|
47
|
-
key="login"
|
|
48
|
-
onSubmit={handleLogin}
|
|
49
|
-
/>
|
|
60
|
+
<LoginScreen key="login" onSubmit={handleLogin} />
|
|
50
61
|
)}
|
|
51
|
-
|
|
62
|
+
|
|
52
63
|
{authStep === AUTH_STEPS.OTP && (
|
|
53
|
-
<OtpScreen
|
|
64
|
+
<OtpScreen
|
|
54
65
|
key="otp"
|
|
55
66
|
identifier={identifier}
|
|
56
67
|
onSubmit={handleOtpSubmit}
|
|
57
68
|
onBack={handleBackToLogin}
|
|
58
69
|
/>
|
|
59
70
|
)}
|
|
60
|
-
|
|
71
|
+
|
|
61
72
|
{authStep === AUTH_STEPS.RECAP && (
|
|
62
|
-
<RecapStory
|
|
63
|
-
key="recap"
|
|
64
|
-
recapData={mockRecapData}
|
|
65
|
-
/>
|
|
73
|
+
<RecapStory key="recap" recapData={recapData} />
|
|
66
74
|
)}
|
|
67
75
|
</AnimatePresence>
|
|
68
76
|
</div>
|
package/src/LoginScreen.tsx
CHANGED
|
@@ -1,24 +1,59 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { motion } from
|
|
3
|
-
import { scaleIn, slideUp } from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
import { scaleIn, slideUp } from "./utils";
|
|
4
|
+
import { Controller, useForm, SubmitHandler } from "react-hook-form";
|
|
5
|
+
import Header from "./components/Header";
|
|
6
|
+
import "./LoginScreen.css";
|
|
7
|
+
import { useMutation } from "@tanstack/react-query";
|
|
8
|
+
import { AuthService } from "./utils/Services/AuthServices";
|
|
9
|
+
import toast from "react-hot-toast";
|
|
6
10
|
|
|
7
11
|
interface LoginScreenProps {
|
|
8
12
|
onSubmit: (identifier: string) => void;
|
|
9
13
|
}
|
|
14
|
+
type LoginProps = {
|
|
15
|
+
email: string;
|
|
16
|
+
};
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* LoginScreen - Landing/login page with animations
|
|
13
20
|
*/
|
|
14
21
|
function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
15
|
-
const [identifier, setIdentifier] = useState(
|
|
22
|
+
// const [identifier, setIdentifier] = useState("");
|
|
23
|
+
const {
|
|
24
|
+
formState: { errors },
|
|
25
|
+
handleSubmit,
|
|
26
|
+
control,
|
|
27
|
+
watch,
|
|
28
|
+
} = useForm<LoginProps>({
|
|
29
|
+
mode: "onChange",
|
|
30
|
+
});
|
|
31
|
+
const emailValue = watch("email");
|
|
32
|
+
const mutationLogin = useMutation({
|
|
33
|
+
mutationFn: (data: LoginProps) => AuthService.login(data),
|
|
34
|
+
});
|
|
35
|
+
// const handleSubmit = (e: React.FormEvent) => {
|
|
36
|
+
// e.preventDefault();
|
|
37
|
+
// if (identifier.trim()) {
|
|
38
|
+
// onSubmit(identifier);
|
|
39
|
+
// }
|
|
40
|
+
// };
|
|
41
|
+
const onSubmitForm: SubmitHandler<LoginProps> = (data) => {
|
|
42
|
+
const LoginData = {
|
|
43
|
+
...data,
|
|
44
|
+
};
|
|
45
|
+
mutationLogin.mutate(LoginData, {
|
|
46
|
+
onSuccess: async (response) => {
|
|
47
|
+
toast.success(response?.data?.message);
|
|
16
48
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
49
|
+
onSubmit(data.email);
|
|
50
|
+
},
|
|
51
|
+
onError: (error: any) => {
|
|
52
|
+
toast.error(
|
|
53
|
+
error?.response ? error?.response?.data?.error : error?.message
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
22
57
|
};
|
|
23
58
|
|
|
24
59
|
return (
|
|
@@ -29,7 +64,7 @@ function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
|
29
64
|
</div>
|
|
30
65
|
|
|
31
66
|
{/* Middle hero section */}
|
|
32
|
-
<motion.div
|
|
67
|
+
<motion.div
|
|
33
68
|
className="login-screen__hero"
|
|
34
69
|
variants={scaleIn}
|
|
35
70
|
initial="initial"
|
|
@@ -40,27 +75,58 @@ function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
|
40
75
|
</motion.div>
|
|
41
76
|
|
|
42
77
|
{/* Bottom form section */}
|
|
43
|
-
<motion.form
|
|
78
|
+
<motion.form
|
|
44
79
|
className="login-screen__form"
|
|
45
|
-
onSubmit={handleSubmit}
|
|
80
|
+
onSubmit={handleSubmit(onSubmitForm)}
|
|
46
81
|
variants={slideUp}
|
|
47
82
|
initial="initial"
|
|
48
83
|
animate="animate"
|
|
49
84
|
>
|
|
50
85
|
<div className="form-group">
|
|
51
|
-
<label htmlFor="identifier" className="form-label">
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
<label htmlFor="identifier" className="form-label">
|
|
87
|
+
Email or Phone Number
|
|
88
|
+
</label>
|
|
89
|
+
<Controller
|
|
90
|
+
name="email"
|
|
91
|
+
rules={{
|
|
92
|
+
required: "email address is required",
|
|
93
|
+
pattern: {
|
|
94
|
+
value:
|
|
95
|
+
/^([\w-.]+@([\w-]+\.)+[\w-]{2,4}|(\+?\d{1,3}[- ]?)?\d{10})$/,
|
|
96
|
+
message: "Invalid email format",
|
|
97
|
+
},
|
|
98
|
+
}}
|
|
99
|
+
control={control}
|
|
100
|
+
render={({ field }) => (
|
|
101
|
+
<>
|
|
102
|
+
<input
|
|
103
|
+
type="text"
|
|
104
|
+
id="identifier"
|
|
105
|
+
required
|
|
106
|
+
placeholder="Enter your email or phone number"
|
|
107
|
+
className="form-input"
|
|
108
|
+
{...field}
|
|
109
|
+
/>
|
|
110
|
+
{errors.email && (
|
|
111
|
+
<span className="text-red-500 text-xs font-sora">
|
|
112
|
+
{errors.email.message}
|
|
113
|
+
</span>
|
|
114
|
+
)}
|
|
115
|
+
</>
|
|
116
|
+
)}
|
|
59
117
|
/>
|
|
60
118
|
</div>
|
|
61
119
|
|
|
62
|
-
<button
|
|
63
|
-
|
|
120
|
+
<button
|
|
121
|
+
type="submit"
|
|
122
|
+
disabled={!emailValue?.trim() || mutationLogin.isPending}
|
|
123
|
+
className={`btn-primary ${
|
|
124
|
+
!emailValue?.trim() || mutationLogin.isPending
|
|
125
|
+
? "opacity-50 cursor-not-allowed"
|
|
126
|
+
: ""
|
|
127
|
+
}`}
|
|
128
|
+
>
|
|
129
|
+
{mutationLogin.isPending ? "Logging in..." : "Log in"}
|
|
64
130
|
</button>
|
|
65
131
|
</motion.form>
|
|
66
132
|
</div>
|
package/src/OtpScreen.tsx
CHANGED
|
@@ -1,31 +1,86 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from
|
|
2
|
-
import { motion } from
|
|
3
|
-
import { delayedFadeIn } from
|
|
4
|
-
import Header from
|
|
5
|
-
import
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
import { delayedFadeIn } from "./utils";
|
|
4
|
+
import Header from "./components/Header";
|
|
5
|
+
import "./OtpScreen.css";
|
|
6
|
+
import toast from "react-hot-toast";
|
|
7
|
+
import { useAuthStore } from "./store/auth";
|
|
8
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
9
|
+
import { AuthService } from "./utils/Services/AuthServices";
|
|
10
|
+
import { useRecapDataStore } from "./store/data";
|
|
6
11
|
|
|
7
12
|
interface OtpScreenProps {
|
|
8
13
|
identifier: string;
|
|
9
14
|
onSubmit: (otp: string) => void;
|
|
10
15
|
onBack: () => void;
|
|
11
16
|
}
|
|
17
|
+
type VerifyOTPProps = {
|
|
18
|
+
email: string;
|
|
19
|
+
otp: string;
|
|
20
|
+
};
|
|
12
21
|
|
|
13
22
|
/**
|
|
14
23
|
* OtpScreen - OTP verification with 6 input boxes
|
|
15
24
|
*/
|
|
16
25
|
function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
17
|
-
const [otp, setOtp] = useState<string[]>([
|
|
26
|
+
const [otp, setOtp] = useState<string[]>(["", "", "", "", "", ""]);
|
|
18
27
|
const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
|
|
28
|
+
const token = useAuthStore((state) => state.token);
|
|
29
|
+
const updateToken = useAuthStore((state) => state.updateToken);
|
|
30
|
+
const updateBusiness = useAuthStore((state) => state.updateBusiness);
|
|
31
|
+
const updateRecapData = useRecapDataStore((state) => state.updateRecapData);
|
|
19
32
|
|
|
20
33
|
useEffect(() => {
|
|
21
34
|
// Focus first input on mount
|
|
22
35
|
inputRefs.current[0]?.focus();
|
|
23
36
|
}, []);
|
|
24
37
|
|
|
38
|
+
const { data: recapInfo } = useQuery({
|
|
39
|
+
queryKey: ['recap'],
|
|
40
|
+
queryFn: () => AuthService.recapData(),
|
|
41
|
+
enabled: !!token,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (recapInfo) {
|
|
46
|
+
updateRecapData(recapInfo?.recapData);
|
|
47
|
+
console.log("Recap data fetched and stored:", recapInfo?.recapData);
|
|
48
|
+
}
|
|
49
|
+
}, [recapInfo, updateRecapData]);
|
|
50
|
+
|
|
51
|
+
const mutationVerifyOtp = useMutation({
|
|
52
|
+
mutationFn: (data: VerifyOTPProps) => AuthService.verifyOtp(data),
|
|
53
|
+
});
|
|
54
|
+
const submitOtp = (e: React.FormEvent<HTMLFormElement>) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
const enteredOtp = otp.join("");
|
|
57
|
+
console.log("OTP submitted:", enteredOtp);
|
|
58
|
+
|
|
59
|
+
const verifyData: VerifyOTPProps = {
|
|
60
|
+
email: identifier,
|
|
61
|
+
otp: enteredOtp,
|
|
62
|
+
};
|
|
63
|
+
mutationVerifyOtp.mutate(verifyData, {
|
|
64
|
+
onSuccess: async (response) => {
|
|
65
|
+
console.log("OTP verified successfully:", response);
|
|
66
|
+
toast.success(response?.data?.message);
|
|
67
|
+
onSubmit(enteredOtp);
|
|
68
|
+
// Stop confetti after 5 seconds
|
|
69
|
+
updateToken(response.data.token);
|
|
70
|
+
updateBusiness(response.data.business);
|
|
71
|
+
|
|
72
|
+
},
|
|
73
|
+
onError: (error: any) => {
|
|
74
|
+
toast.error(
|
|
75
|
+
error?.response ? error?.response?.data?.error : error?.message
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
};
|
|
25
80
|
const handleChange = (index: number, value: string) => {
|
|
26
81
|
// Only accept single digit
|
|
27
82
|
if (value.length > 1) return;
|
|
28
|
-
|
|
83
|
+
|
|
29
84
|
const newOtp = [...otp];
|
|
30
85
|
newOtp[index] = value;
|
|
31
86
|
setOtp(newOtp);
|
|
@@ -36,20 +91,23 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
36
91
|
}
|
|
37
92
|
};
|
|
38
93
|
|
|
39
|
-
const handleKeyDown = (
|
|
94
|
+
const handleKeyDown = (
|
|
95
|
+
index: number,
|
|
96
|
+
e: React.KeyboardEvent<HTMLInputElement>
|
|
97
|
+
) => {
|
|
40
98
|
// Handle backspace
|
|
41
|
-
if (e.key ===
|
|
99
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
42
100
|
inputRefs.current[index - 1]?.focus();
|
|
43
101
|
}
|
|
44
102
|
};
|
|
45
103
|
|
|
46
|
-
const handleSubmit = (e: React.FormEvent) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
104
|
+
// const handleSubmit = (e: React.FormEvent) => {
|
|
105
|
+
// e.preventDefault();
|
|
106
|
+
// const otpValue = otp.join('');
|
|
107
|
+
// if (otpValue.length === 6) {
|
|
108
|
+
// onSubmit(otpValue);
|
|
109
|
+
// }
|
|
110
|
+
// };
|
|
53
111
|
|
|
54
112
|
return (
|
|
55
113
|
<div className="otp-screen">
|
|
@@ -59,32 +117,38 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
59
117
|
</div>
|
|
60
118
|
|
|
61
119
|
{/* Middle hero section */}
|
|
62
|
-
<motion.div
|
|
120
|
+
<motion.div
|
|
63
121
|
className="otp-screen__hero"
|
|
64
122
|
variants={delayedFadeIn(0.2)}
|
|
65
123
|
initial="initial"
|
|
66
124
|
animate="animate"
|
|
67
125
|
>
|
|
68
126
|
<h1 className="otp-screen__title">Recap</h1>
|
|
69
|
-
<p className="otp-screen__subtitle">
|
|
127
|
+
<p className="otp-screen__subtitle">
|
|
128
|
+
Check your email or WhatsApp and enter the 6-digit OTP below
|
|
129
|
+
</p>
|
|
70
130
|
</motion.div>
|
|
71
131
|
|
|
72
132
|
{/* Bottom form section */}
|
|
73
|
-
<motion.form
|
|
133
|
+
<motion.form
|
|
74
134
|
className="login-screen__form"
|
|
75
|
-
onSubmit={
|
|
135
|
+
onSubmit={submitOtp}
|
|
76
136
|
variants={delayedFadeIn(0.4)}
|
|
77
137
|
initial="initial"
|
|
78
138
|
animate="animate"
|
|
79
139
|
>
|
|
80
140
|
<div className="form-group">
|
|
81
|
-
<label htmlFor="otp-input-0" className="form-label">
|
|
141
|
+
<label htmlFor="otp-input-0" className="form-label">
|
|
142
|
+
Enter OTP
|
|
143
|
+
</label>
|
|
82
144
|
<div className="otp-inputs">
|
|
83
145
|
{otp.map((digit, index) => (
|
|
84
146
|
<input
|
|
85
147
|
key={index}
|
|
86
|
-
id={index === 0 ?
|
|
87
|
-
ref={el => {
|
|
148
|
+
id={index === 0 ? "otp-input-0" : undefined}
|
|
149
|
+
ref={(el) => {
|
|
150
|
+
inputRefs.current[index] = el;
|
|
151
|
+
}}
|
|
88
152
|
type="text"
|
|
89
153
|
inputMode="numeric"
|
|
90
154
|
pattern="[0-9]*"
|
|
@@ -98,8 +162,16 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
98
162
|
</div>
|
|
99
163
|
</div>
|
|
100
164
|
|
|
101
|
-
<button
|
|
102
|
-
|
|
165
|
+
<button
|
|
166
|
+
type="submit"
|
|
167
|
+
disabled={otp.join("").length !== 6 || mutationVerifyOtp.isPending}
|
|
168
|
+
className={`btn-primary ${
|
|
169
|
+
otp.join("").length !== 6 || mutationVerifyOtp.isPending
|
|
170
|
+
? "opacity-50 cursor-not-allowed"
|
|
171
|
+
: ""
|
|
172
|
+
}`}
|
|
173
|
+
>
|
|
174
|
+
{mutationVerifyOtp.isPending ? "Verifying..." : "Verify OTP"}
|
|
103
175
|
</button>
|
|
104
176
|
</motion.form>
|
|
105
177
|
</div>
|
package/src/RecapStory.tsx
CHANGED
|
@@ -32,12 +32,32 @@ interface RecapStoryProps {
|
|
|
32
32
|
function RecapStory({ recapData }: RecapStoryProps) {
|
|
33
33
|
const [activeIndex, setActiveIndex] = useState<number>(0);
|
|
34
34
|
const durations = recapData.slideDurations || defaultDurations;
|
|
35
|
-
|
|
35
|
+
// Start paused when in video generation mode - orchestrator will unpause via window.__RECAP_START__
|
|
36
|
+
const [isPaused, setIsPaused] = useState<boolean>(recapData.isVideo === true);
|
|
36
37
|
const [isShareVisible, setIsShareVisible] = useState<boolean>(false);
|
|
37
38
|
const holdTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
38
39
|
const isHoldingRef = useRef<boolean>(false);
|
|
39
40
|
const slidesContainerRef = useRef<HTMLDivElement>(null);
|
|
40
41
|
|
|
42
|
+
// Expose global start function for video generation orchestrator
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (recapData.isVideo) {
|
|
45
|
+
// Expose function to start the story (used by Puppeteer after recording starts)
|
|
46
|
+
(window as unknown as { __RECAP_START__?: () => void }).__RECAP_START__ = () => {
|
|
47
|
+
setIsPaused(false);
|
|
48
|
+
};
|
|
49
|
+
// Also add a ready flag so orchestrator knows the component is mounted
|
|
50
|
+
(window as unknown as { __RECAP_READY__?: boolean }).__RECAP_READY__ = true;
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
// Cleanup global functions
|
|
54
|
+
if (recapData.isVideo) {
|
|
55
|
+
delete (window as unknown as { __RECAP_START__?: () => void }).__RECAP_START__;
|
|
56
|
+
delete (window as unknown as { __RECAP_READY__?: boolean }).__RECAP_READY__;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, [recapData.isVideo]);
|
|
60
|
+
|
|
41
61
|
// Cleanup on unmount to prevent memory leaks
|
|
42
62
|
React.useEffect(() => {
|
|
43
63
|
return () => {
|
package/src/StoryProgress.tsx
CHANGED
|
@@ -58,9 +58,6 @@ function StoryProgress({
|
|
|
58
58
|
// Resume from paused progress
|
|
59
59
|
startTimeRef.current = performance.now();
|
|
60
60
|
const startProgress = pausedProgressRef.current;
|
|
61
|
-
if (startProgress >= 1) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
61
|
if (startProgress >= 1) {
|
|
65
62
|
setProgress(1);
|
|
66
63
|
onCompleteRef.current();
|
package/src/data/mock.ts
CHANGED
|
@@ -61,9 +61,9 @@ export const mockRecapData: RecapData = {
|
|
|
61
61
|
businessCategory: BUSINESS_CATEGORIES.THRIVING,
|
|
62
62
|
busiestMonth: "Oct",
|
|
63
63
|
videoUrl:
|
|
64
|
-
"https://katajereassets.blob.core.windows.net/
|
|
64
|
+
"https://katajereassets.blob.core.windows.net/recap-videos/recap_4e5f6a7b-8c9d-0e1f-2a3b-4c5d6e7f8a9b_738c9226abe1a8f1a07263948a2d175e.mp4",
|
|
65
65
|
downloadUrl:
|
|
66
|
-
"https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/
|
|
66
|
+
"https://api.huxxle.com/api/download?fileUrl=https://katajereassets.blob.core.windows.net/recap-videos/recap_4e5f6a7b-8c9d-0e1f-2a3b-4c5d6e7f8a9b_738c9226abe1a8f1a07263948a2d175e.mp4",
|
|
67
67
|
isVideo: false,
|
|
68
68
|
websiteLink: "https://vendor.huxxle.com",
|
|
69
69
|
websiteVisits: 123400,
|
package/src/index.css
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/* Google Fonts import for Lora - must be first for priority loading */
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap');
|
|
3
|
+
@import 'tailwindcss';
|
|
1
4
|
body {
|
|
2
5
|
margin: 0;
|
|
3
|
-
|
|
6
|
+
/* Lora as primary, with emoji font fallbacks for cross-platform emoji support */
|
|
7
|
+
font-family: 'Lora', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
|
|
8
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
9
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
10
|
sans-serif;
|
|
6
11
|
-webkit-font-smoothing: antialiased;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { persist, createJSONStorage } from "zustand/middleware";
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
|
|
4
|
+
type AuthState = {
|
|
5
|
+
token: string;
|
|
6
|
+
business: {
|
|
7
|
+
business_name: string;
|
|
8
|
+
business_image: string;
|
|
9
|
+
business_type: string;
|
|
10
|
+
business_phone: string;
|
|
11
|
+
business_website: string;
|
|
12
|
+
business_address: string;
|
|
13
|
+
business_city: string;
|
|
14
|
+
business_state: string;
|
|
15
|
+
business_zip_code: string;
|
|
16
|
+
subdomain: string;
|
|
17
|
+
website_status: string;
|
|
18
|
+
website_status_by_admin: string;
|
|
19
|
+
social_facebook: string;
|
|
20
|
+
social_instagram: string;
|
|
21
|
+
social_twitter: string;
|
|
22
|
+
social_tiktok: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type AuthActions = {
|
|
26
|
+
updateToken: (token: string) => void;
|
|
27
|
+
updateBusiness: (businessData: AuthState["business"]) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const initialState: AuthState = {
|
|
31
|
+
token: "",
|
|
32
|
+
business: {
|
|
33
|
+
business_name: "",
|
|
34
|
+
business_image: "",
|
|
35
|
+
business_type: "",
|
|
36
|
+
business_phone: "",
|
|
37
|
+
business_website: "",
|
|
38
|
+
business_address: "",
|
|
39
|
+
business_city: "",
|
|
40
|
+
business_state: "",
|
|
41
|
+
business_zip_code: "",
|
|
42
|
+
subdomain: "",
|
|
43
|
+
website_status: "",
|
|
44
|
+
website_status_by_admin: "",
|
|
45
|
+
social_facebook: "",
|
|
46
|
+
social_instagram: "",
|
|
47
|
+
social_tiktok: "",
|
|
48
|
+
social_twitter: "",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const useAuthStore = create<AuthState & AuthActions>()(
|
|
52
|
+
persist(
|
|
53
|
+
(set) => ({
|
|
54
|
+
...initialState,
|
|
55
|
+
updateToken: (token: string) => set(() => ({ token })),
|
|
56
|
+
clearToken: () => {
|
|
57
|
+
set(() => ({
|
|
58
|
+
token: "",
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
updateBusiness: (businessData: AuthState["business"]) => {
|
|
62
|
+
set(() => ({
|
|
63
|
+
business: businessData,
|
|
64
|
+
}));
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
{
|
|
68
|
+
name: "auth-storage",
|
|
69
|
+
storage: createJSONStorage(() => localStorage),
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { persist, createJSONStorage } from "zustand/middleware";
|
|
3
|
+
import { RecapData, BUSINESS_CATEGORIES } from "../types";
|
|
4
|
+
|
|
5
|
+
type RecapDataState = {
|
|
6
|
+
recapData: RecapData;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type RecapDataActions = {
|
|
10
|
+
updateRecapData: (data: Partial<RecapData>) => void;
|
|
11
|
+
setRecapData: (data: RecapData) => void;
|
|
12
|
+
resetRecapData: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const initialState: RecapDataState = {
|
|
16
|
+
recapData: {
|
|
17
|
+
businessName: "",
|
|
18
|
+
days: 0,
|
|
19
|
+
streak: 0,
|
|
20
|
+
revenue: 0,
|
|
21
|
+
orders: 0,
|
|
22
|
+
firstTimeBuyers: 0,
|
|
23
|
+
repeatBuyers: 0,
|
|
24
|
+
topCustomerName: "",
|
|
25
|
+
currency: "",
|
|
26
|
+
year: 0,
|
|
27
|
+
introHeadline: "",
|
|
28
|
+
introSubtitle: "",
|
|
29
|
+
topProducts: [],
|
|
30
|
+
productImages: [],
|
|
31
|
+
businessCategory: BUSINESS_CATEGORIES.THRIVING,
|
|
32
|
+
busiestMonth: "",
|
|
33
|
+
videoUrl: "",
|
|
34
|
+
downloadUrl: "",
|
|
35
|
+
isVideo: false,
|
|
36
|
+
websiteLink: "",
|
|
37
|
+
websiteVisits: 0,
|
|
38
|
+
mostViewedProduct: "",
|
|
39
|
+
mostViewedProductCount: 0,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const useRecapDataStore = create<RecapDataState & RecapDataActions>()(
|
|
44
|
+
persist(
|
|
45
|
+
(set) => ({
|
|
46
|
+
...initialState,
|
|
47
|
+
updateRecapData: (data) =>
|
|
48
|
+
set((state) => ({
|
|
49
|
+
recapData: { ...state.recapData, ...data },
|
|
50
|
+
})),
|
|
51
|
+
setRecapData: (data) => set({ recapData: data }),
|
|
52
|
+
resetRecapData: () => set({ ...initialState }),
|
|
53
|
+
}),
|
|
54
|
+
{
|
|
55
|
+
name: "recap-data-storage",
|
|
56
|
+
storage: createJSONStorage(() => localStorage),
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jwtDecode } from "jwt-decode";
|
|
2
|
+
|
|
3
|
+
interface MyToken {
|
|
4
|
+
name: string;
|
|
5
|
+
exp: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validate if the token is valid or has expired
|
|
10
|
+
* @param token the jwt token
|
|
11
|
+
* @returns boolean
|
|
12
|
+
*/
|
|
13
|
+
export const isTokenValid = (token: string) => {
|
|
14
|
+
try {
|
|
15
|
+
if (!token) return false;
|
|
16
|
+
const decoded = jwtDecode<MyToken>(token);
|
|
17
|
+
if (Date.now() >= decoded.exp * 1000) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error("Token decoding failed:", error);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { isTokenValid } from "./Helpers";
|
|
5
|
+
import { useAuthStore } from "../store/auth";
|
|
6
|
+
|
|
7
|
+
const RecapApi = () => {
|
|
8
|
+
let headers = {};
|
|
9
|
+
const token =
|
|
10
|
+
useAuthStore.getState().token ||
|
|
11
|
+
(() => {
|
|
12
|
+
const userAuthStore = localStorage.getItem("auth-storage");
|
|
13
|
+
if (userAuthStore) {
|
|
14
|
+
const parsedAuthStore = JSON.parse(userAuthStore);
|
|
15
|
+
return parsedAuthStore.token;
|
|
16
|
+
}
|
|
17
|
+
return null; // Return null if token is not found in either store or localStorage
|
|
18
|
+
})();
|
|
19
|
+
if (token) {
|
|
20
|
+
if (!isTokenValid(token)) {
|
|
21
|
+
sessionStorage.removeItem("auth-storage");
|
|
22
|
+
localStorage.removeItem("auth-storage"); // Also clear from local storage
|
|
23
|
+
window.location.href = "/";
|
|
24
|
+
}
|
|
25
|
+
headers = {
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const baseURL = import.meta.env.VITE_REACT_APP_KATAJERE_BASE_URL || "";
|
|
31
|
+
const axiosInstance = axios.create({
|
|
32
|
+
baseURL,
|
|
33
|
+
timeout: 60000, // Default timeout (will be overridden by interceptor)
|
|
34
|
+
headers,
|
|
35
|
+
});
|
|
36
|
+
return axiosInstance;
|
|
37
|
+
};
|
|
38
|
+
export default RecapApi;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import RecapApi from "../RecapApi";
|
|
2
|
+
|
|
3
|
+
export const AuthService = {
|
|
4
|
+
login: async (payload: { email: string }) => {
|
|
5
|
+
return await RecapApi().post("/auth/login", payload);
|
|
6
|
+
},
|
|
7
|
+
verifyOtp: async (payload: { email: string; otp: string }) => {
|
|
8
|
+
return await RecapApi().post("/auth/verify-otp", payload);
|
|
9
|
+
},
|
|
10
|
+
recapData: async () => {
|
|
11
|
+
const data = await RecapApi().get("/recap");
|
|
12
|
+
return data.data
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
};
|