@katajere/recap 2.1.3 → 2.1.4
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/index.css +1 -1
- package/dist/slides/Slide1Intro.css +29 -30
- package/dist/slides/Slide1Intro.d.ts.map +1 -1
- package/dist/slides/Slide1Intro.js +8 -2
- package/package.json +2 -10
- package/src/App.tsx +24 -32
- package/src/LoginScreen.tsx +24 -90
- package/src/OtpScreen.tsx +25 -97
- package/src/index.css +1 -1
- package/src/slides/Slide1Intro.css +29 -30
- package/src/slides/Slide1Intro.tsx +11 -3
- package/dist/store/auth.d.ts +0 -40
- package/dist/store/auth.d.ts.map +0 -1
- package/dist/store/auth.js +0 -40
- package/dist/utils/Helpers.d.ts +0 -7
- package/dist/utils/Helpers.d.ts.map +0 -1
- package/dist/utils/Helpers.js +0 -21
- package/dist/utils/RecapApi.d.ts +0 -3
- package/dist/utils/RecapApi.d.ts.map +0 -1
- package/dist/utils/RecapApi.js +0 -34
- package/dist/utils/Services/AuthServices.d.ts +0 -11
- package/dist/utils/Services/AuthServices.d.ts.map +0 -1
- package/dist/utils/Services/AuthServices.js +0 -13
- package/src/store/auth.tsx +0 -72
- package/src/store/data.tsx +0 -59
- package/src/utils/Helpers.tsx +0 -25
- package/src/utils/RecapApi.tsx +0 -38
- package/src/utils/Services/AuthServices.tsx +0 -15
package/dist/index.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Google Fonts import for Lora - must be first for priority loading */
|
|
2
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
|
-
|
|
3
|
+
|
|
4
4
|
body {
|
|
5
5
|
margin: 0;
|
|
6
6
|
/* Lora as primary, with emoji font fallbacks for cross-platform emoji support */
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
/* gap: clamp(12px, 1.9dvh, 16px); */
|
|
17
17
|
/* gap: calc(12px + env(safe-area-inset-top)); */
|
|
18
18
|
position: absolute;
|
|
19
|
-
|
|
20
|
-
left:
|
|
21
|
-
top: clamp(40px, 5.69dvh, 48px); */
|
|
19
|
+
width: 100%;
|
|
20
|
+
left: 0;
|
|
21
|
+
/* top: clamp(40px, 5.69dvh, 48px); */
|
|
22
22
|
z-index: 3;
|
|
23
23
|
overflow: visible;
|
|
24
24
|
}
|
|
@@ -53,37 +53,39 @@
|
|
|
53
53
|
align-self: stretch;
|
|
54
54
|
display: flex;
|
|
55
55
|
flex-wrap: wrap;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
padding-left: calc(16px + env(safe-area-inset-left));
|
|
57
|
+
padding-right: calc(16px + env(safe-area-inset-right));
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
width: 100%;
|
|
59
60
|
position: relative;
|
|
60
61
|
z-index: 4;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
/*
|
|
64
|
-
.slide1-intro__brand--
|
|
65
|
-
font-size: clamp(
|
|
66
|
-
line-height: 1;
|
|
64
|
+
/* Short words (<=8 chars) - larger font */
|
|
65
|
+
.slide1-intro__brand--short {
|
|
66
|
+
font-size: clamp(40px, 14vw, 72px);
|
|
67
|
+
line-height: 1.1;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/*
|
|
70
|
-
.slide1-intro__brand--
|
|
71
|
-
font-size: clamp(
|
|
72
|
-
line-height: 1;
|
|
70
|
+
/* Medium words (9-14 chars) - medium font */
|
|
71
|
+
.slide1-intro__brand--medium {
|
|
72
|
+
font-size: clamp(32px, 10vw, 56px);
|
|
73
|
+
line-height: 1.1;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
/*
|
|
76
|
-
.slide1-intro__brand--
|
|
77
|
-
font-size: clamp(
|
|
76
|
+
/* Long words (15+ chars) - smaller font to fit */
|
|
77
|
+
.slide1-intro__brand--long {
|
|
78
|
+
font-size: clamp(24px, 7vw, 44px);
|
|
79
|
+
line-height: 1.1;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
/* Each word
|
|
82
|
+
/* Each word on its own line, never breaks mid-word */
|
|
81
83
|
.slide1-intro__word {
|
|
82
|
-
display:
|
|
83
|
-
white-space: nowrap;
|
|
84
|
+
display: block;
|
|
85
|
+
/* white-space: nowrap; */
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
/* Top floating frames - positioned
|
|
88
|
+
/* Top floating frames - positioned below business name */
|
|
87
89
|
.slide1-intro__frames-top {
|
|
88
90
|
display: flex;
|
|
89
91
|
flex-direction: row;
|
|
@@ -94,24 +96,21 @@
|
|
|
94
96
|
position: absolute;
|
|
95
97
|
width: 100%;
|
|
96
98
|
left: 0;
|
|
97
|
-
top:
|
|
99
|
+
top: 30vh;
|
|
98
100
|
z-index: 2;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
/*
|
|
102
|
-
|
|
103
|
-
.slide1-intro--words-1 .slide1-intro__frames-top {
|
|
103
|
+
/* Adjust frame position based on business name length */
|
|
104
|
+
.slide1-intro:has(.slide1-intro__brand--short) .slide1-intro__frames-top {
|
|
104
105
|
top: 26vh;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
.slide1-intro--words-2 .slide1-intro__frames-top {
|
|
108
|
+
.slide1-intro:has(.slide1-intro__brand--medium) .slide1-intro__frames-top {
|
|
109
109
|
top: 28vh;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
top: 32vh;
|
|
112
|
+
.slide1-intro:has(.slide1-intro__brand--long) .slide1-intro__frames-top {
|
|
113
|
+
top: 30vh;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
.slide1-intro__frames-top .frame-rect {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slide1Intro.d.ts","sourceRoot":"","sources":["../../src/slides/Slide1Intro.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,mBAAmB,CAAC;AAE3B,UAAU,gBAAgB;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,iBAAS,WAAW,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,EAAE,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Slide1Intro.d.ts","sourceRoot":"","sources":["../../src/slides/Slide1Intro.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,mBAAmB,CAAC;AAE3B,UAAU,gBAAgB;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,iBAAS,WAAW,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,EAAE,EAAE,gBAAgB,2CA8JzI;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -13,7 +13,13 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
|
|
|
13
13
|
const copy = recapCopy[businessCategory] ?? recapCopy[BUSINESS_CATEGORIES.THRIVING];
|
|
14
14
|
const headline = introHeadline ?? copy.introHeadline;
|
|
15
15
|
const subtitle = introSubtitle ?? copy.introSubtitle;
|
|
16
|
-
|
|
16
|
+
// Calculate longest word length for font scaling
|
|
17
|
+
const words = businessName.split(' ');
|
|
18
|
+
const longestWordLength = Math.max(...words.map(w => w.length));
|
|
19
|
+
// Determine font size class based on longest word length
|
|
20
|
+
// Short words (<=8 chars): large font, Medium (9-14): medium, Long (15+): small
|
|
21
|
+
const fontSizeClass = longestWordLength <= 8 ? 'short' : longestWordLength <= 14 ? 'medium' : 'long';
|
|
22
|
+
const slideClass = `slide1-intro slide1-intro--${copy.introVariant}`;
|
|
17
23
|
const isNewUser = businessCategory === BUSINESS_CATEGORIES.NEW_USER;
|
|
18
24
|
const handleContinue = () => {
|
|
19
25
|
if (typeof window !== 'undefined') {
|
|
@@ -43,7 +49,7 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
|
|
|
43
49
|
backgroundPosition: 'center',
|
|
44
50
|
};
|
|
45
51
|
};
|
|
46
|
-
return (_jsxs("div", { className: slideClass, children: [_jsxs("div", { className: "slide1-intro__brand-container", children: [_jsx("div", { className: "slide1-intro__bg-text", children: "HEY" }), _jsx("div", { className: `slide1-intro__brand slide1-intro__brand
|
|
52
|
+
return (_jsxs("div", { className: slideClass, children: [_jsxs("div", { className: "slide1-intro__brand-container", children: [_jsx("div", { className: "slide1-intro__bg-text", children: "HEY" }), _jsx("div", { className: `slide1-intro__brand slide1-intro__brand--${fontSizeClass}`, children: words.map((word, wordIndex, wordsArray) => {
|
|
47
53
|
// Calculate character offset for stagger delay (include space characters)
|
|
48
54
|
const charOffset = wordsArray
|
|
49
55
|
.slice(0, wordIndex)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katajere/recap",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Vendor Year in Review Experience - Recap your business metrics for 2025",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -51,18 +51,10 @@
|
|
|
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",
|
|
57
54
|
"framer-motion": "^12.0.0",
|
|
58
55
|
"html2canvas": "^1.4.1",
|
|
59
|
-
"jwt-decode": "^4.0.0",
|
|
60
56
|
"react": "^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"
|
|
57
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
66
58
|
},
|
|
67
59
|
"devDependencies": {
|
|
68
60
|
"@types/node": "^24.10.1",
|
package/src/App.tsx
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import React, { useState
|
|
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
|
|
9
|
-
import { useAuthStore } from "./store/auth";
|
|
1
|
+
import React, { useState } 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 { mockRecapData } from './data/mock';
|
|
8
|
+
import './App.css';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Main App component
|
|
13
12
|
* Manages auth state machine: login → otp → recap
|
|
14
13
|
*/
|
|
15
14
|
function App() {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
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]);
|
|
15
|
+
const [authStep, setAuthStep] = useState<AuthStep>(AUTH_STEPS.LOGIN);
|
|
16
|
+
const [identifier, setIdentifier] = useState<string>('');
|
|
30
17
|
|
|
31
18
|
// Handle login submission
|
|
32
19
|
const handleLogin = (value: string) => {
|
|
@@ -37,40 +24,45 @@ function App() {
|
|
|
37
24
|
// Handle OTP submission
|
|
38
25
|
const handleOtpSubmit = (otp: string) => {
|
|
39
26
|
// In production, verify OTP with backend here
|
|
40
|
-
console.log(
|
|
41
|
-
|
|
27
|
+
console.log('OTP submitted:', otp);
|
|
42
28
|
setAuthStep(AUTH_STEPS.RECAP);
|
|
43
29
|
};
|
|
44
30
|
|
|
45
31
|
// Handle back from OTP to login
|
|
46
32
|
const handleBackToLogin = () => {
|
|
47
33
|
setAuthStep(AUTH_STEPS.LOGIN);
|
|
48
|
-
setIdentifier(
|
|
34
|
+
setIdentifier('');
|
|
49
35
|
};
|
|
50
36
|
|
|
51
37
|
return (
|
|
52
38
|
<div className="app">
|
|
53
39
|
{/* Desktop backdrop blur */}
|
|
54
40
|
<div className="app__backdrop" />
|
|
55
|
-
|
|
41
|
+
|
|
56
42
|
{/* Story shell (390x844 phone frame) */}
|
|
57
43
|
<div className="app__shell">
|
|
58
44
|
<AnimatePresence mode="wait">
|
|
59
45
|
{authStep === AUTH_STEPS.LOGIN && (
|
|
60
|
-
<LoginScreen
|
|
46
|
+
<LoginScreen
|
|
47
|
+
key="login"
|
|
48
|
+
onSubmit={handleLogin}
|
|
49
|
+
/>
|
|
61
50
|
)}
|
|
62
|
-
|
|
51
|
+
|
|
63
52
|
{authStep === AUTH_STEPS.OTP && (
|
|
64
|
-
<OtpScreen
|
|
53
|
+
<OtpScreen
|
|
65
54
|
key="otp"
|
|
66
55
|
identifier={identifier}
|
|
67
56
|
onSubmit={handleOtpSubmit}
|
|
68
57
|
onBack={handleBackToLogin}
|
|
69
58
|
/>
|
|
70
59
|
)}
|
|
71
|
-
|
|
60
|
+
|
|
72
61
|
{authStep === AUTH_STEPS.RECAP && (
|
|
73
|
-
<RecapStory
|
|
62
|
+
<RecapStory
|
|
63
|
+
key="recap"
|
|
64
|
+
recapData={mockRecapData}
|
|
65
|
+
/>
|
|
74
66
|
)}
|
|
75
67
|
</AnimatePresence>
|
|
76
68
|
</div>
|
package/src/LoginScreen.tsx
CHANGED
|
@@ -1,59 +1,24 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { motion } from
|
|
3
|
-
import { scaleIn, slideUp } from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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";
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import { scaleIn, slideUp } from './utils';
|
|
4
|
+
import Header from './components/Header';
|
|
5
|
+
import './LoginScreen.css';
|
|
10
6
|
|
|
11
7
|
interface LoginScreenProps {
|
|
12
8
|
onSubmit: (identifier: string) => void;
|
|
13
9
|
}
|
|
14
|
-
type LoginProps = {
|
|
15
|
-
email: string;
|
|
16
|
-
};
|
|
17
10
|
|
|
18
11
|
/**
|
|
19
12
|
* LoginScreen - Landing/login page with animations
|
|
20
13
|
*/
|
|
21
14
|
function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
22
|
-
|
|
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);
|
|
15
|
+
const [identifier, setIdentifier] = useState('');
|
|
48
16
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
17
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
if (identifier.trim()) {
|
|
20
|
+
onSubmit(identifier);
|
|
21
|
+
}
|
|
57
22
|
};
|
|
58
23
|
|
|
59
24
|
return (
|
|
@@ -64,7 +29,7 @@ function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
|
64
29
|
</div>
|
|
65
30
|
|
|
66
31
|
{/* Middle hero section */}
|
|
67
|
-
<motion.div
|
|
32
|
+
<motion.div
|
|
68
33
|
className="login-screen__hero"
|
|
69
34
|
variants={scaleIn}
|
|
70
35
|
initial="initial"
|
|
@@ -75,58 +40,27 @@ function LoginScreen({ onSubmit }: LoginScreenProps) {
|
|
|
75
40
|
</motion.div>
|
|
76
41
|
|
|
77
42
|
{/* Bottom form section */}
|
|
78
|
-
<motion.form
|
|
43
|
+
<motion.form
|
|
79
44
|
className="login-screen__form"
|
|
80
|
-
onSubmit={handleSubmit
|
|
45
|
+
onSubmit={handleSubmit}
|
|
81
46
|
variants={slideUp}
|
|
82
47
|
initial="initial"
|
|
83
48
|
animate="animate"
|
|
84
49
|
>
|
|
85
50
|
<div className="form-group">
|
|
86
|
-
<label htmlFor="identifier" className="form-label">
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
)}
|
|
51
|
+
<label htmlFor="identifier" className="form-label">Email or Phone Number</label>
|
|
52
|
+
<input
|
|
53
|
+
id="identifier"
|
|
54
|
+
type="text"
|
|
55
|
+
placeholder="Enter email or phone"
|
|
56
|
+
value={identifier}
|
|
57
|
+
onChange={(e) => setIdentifier(e.target.value)}
|
|
58
|
+
className="form-input"
|
|
117
59
|
/>
|
|
118
60
|
</div>
|
|
119
61
|
|
|
120
|
-
<button
|
|
121
|
-
|
|
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"}
|
|
62
|
+
<button type="submit" className="btn-primary">
|
|
63
|
+
Log In
|
|
130
64
|
</button>
|
|
131
65
|
</motion.form>
|
|
132
66
|
</div>
|
package/src/OtpScreen.tsx
CHANGED
|
@@ -1,86 +1,31 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from
|
|
2
|
-
import { motion } from
|
|
3
|
-
import { delayedFadeIn } from
|
|
4
|
-
import Header from
|
|
5
|
-
import
|
|
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";
|
|
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';
|
|
11
6
|
|
|
12
7
|
interface OtpScreenProps {
|
|
13
8
|
identifier: string;
|
|
14
9
|
onSubmit: (otp: string) => void;
|
|
15
10
|
onBack: () => void;
|
|
16
11
|
}
|
|
17
|
-
type VerifyOTPProps = {
|
|
18
|
-
email: string;
|
|
19
|
-
otp: string;
|
|
20
|
-
};
|
|
21
12
|
|
|
22
13
|
/**
|
|
23
14
|
* OtpScreen - OTP verification with 6 input boxes
|
|
24
15
|
*/
|
|
25
16
|
function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
26
|
-
const [otp, setOtp] = useState<string[]>([
|
|
17
|
+
const [otp, setOtp] = useState<string[]>(['', '', '', '', '', '']);
|
|
27
18
|
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);
|
|
32
19
|
|
|
33
20
|
useEffect(() => {
|
|
34
21
|
// Focus first input on mount
|
|
35
22
|
inputRefs.current[0]?.focus();
|
|
36
23
|
}, []);
|
|
37
24
|
|
|
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
|
-
};
|
|
80
25
|
const handleChange = (index: number, value: string) => {
|
|
81
26
|
// Only accept single digit
|
|
82
27
|
if (value.length > 1) return;
|
|
83
|
-
|
|
28
|
+
|
|
84
29
|
const newOtp = [...otp];
|
|
85
30
|
newOtp[index] = value;
|
|
86
31
|
setOtp(newOtp);
|
|
@@ -91,23 +36,20 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
91
36
|
}
|
|
92
37
|
};
|
|
93
38
|
|
|
94
|
-
const handleKeyDown = (
|
|
95
|
-
index: number,
|
|
96
|
-
e: React.KeyboardEvent<HTMLInputElement>
|
|
97
|
-
) => {
|
|
39
|
+
const handleKeyDown = (index: number, e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
98
40
|
// Handle backspace
|
|
99
|
-
if (e.key ===
|
|
41
|
+
if (e.key === 'Backspace' && !otp[index] && index > 0) {
|
|
100
42
|
inputRefs.current[index - 1]?.focus();
|
|
101
43
|
}
|
|
102
44
|
};
|
|
103
45
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
46
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
const otpValue = otp.join('');
|
|
49
|
+
if (otpValue.length === 6) {
|
|
50
|
+
onSubmit(otpValue);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
111
53
|
|
|
112
54
|
return (
|
|
113
55
|
<div className="otp-screen">
|
|
@@ -117,38 +59,32 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
117
59
|
</div>
|
|
118
60
|
|
|
119
61
|
{/* Middle hero section */}
|
|
120
|
-
<motion.div
|
|
62
|
+
<motion.div
|
|
121
63
|
className="otp-screen__hero"
|
|
122
64
|
variants={delayedFadeIn(0.2)}
|
|
123
65
|
initial="initial"
|
|
124
66
|
animate="animate"
|
|
125
67
|
>
|
|
126
68
|
<h1 className="otp-screen__title">Recap</h1>
|
|
127
|
-
<p className="otp-screen__subtitle">
|
|
128
|
-
Check your email or WhatsApp and enter the 6-digit OTP below
|
|
129
|
-
</p>
|
|
69
|
+
<p className="otp-screen__subtitle">Check your email or WhatsApp and enter the 6-digit OTP below</p>
|
|
130
70
|
</motion.div>
|
|
131
71
|
|
|
132
72
|
{/* Bottom form section */}
|
|
133
|
-
<motion.form
|
|
73
|
+
<motion.form
|
|
134
74
|
className="login-screen__form"
|
|
135
|
-
onSubmit={
|
|
75
|
+
onSubmit={handleSubmit}
|
|
136
76
|
variants={delayedFadeIn(0.4)}
|
|
137
77
|
initial="initial"
|
|
138
78
|
animate="animate"
|
|
139
79
|
>
|
|
140
80
|
<div className="form-group">
|
|
141
|
-
<label htmlFor="otp-input-0" className="form-label">
|
|
142
|
-
Enter OTP
|
|
143
|
-
</label>
|
|
81
|
+
<label htmlFor="otp-input-0" className="form-label">Enter OTP</label>
|
|
144
82
|
<div className="otp-inputs">
|
|
145
83
|
{otp.map((digit, index) => (
|
|
146
84
|
<input
|
|
147
85
|
key={index}
|
|
148
|
-
id={index === 0 ?
|
|
149
|
-
ref={
|
|
150
|
-
inputRefs.current[index] = el;
|
|
151
|
-
}}
|
|
86
|
+
id={index === 0 ? 'otp-input-0' : undefined}
|
|
87
|
+
ref={el => { inputRefs.current[index] = el; }}
|
|
152
88
|
type="text"
|
|
153
89
|
inputMode="numeric"
|
|
154
90
|
pattern="[0-9]*"
|
|
@@ -162,16 +98,8 @@ function OtpScreen({ identifier, onSubmit, onBack }: OtpScreenProps) {
|
|
|
162
98
|
</div>
|
|
163
99
|
</div>
|
|
164
100
|
|
|
165
|
-
<button
|
|
166
|
-
|
|
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"}
|
|
101
|
+
<button type="submit" className="btn-primary">
|
|
102
|
+
Verify OTP
|
|
175
103
|
</button>
|
|
176
104
|
</motion.form>
|
|
177
105
|
</div>
|
package/src/index.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Google Fonts import for Lora - must be first for priority loading */
|
|
2
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
|
-
|
|
3
|
+
|
|
4
4
|
body {
|
|
5
5
|
margin: 0;
|
|
6
6
|
/* Lora as primary, with emoji font fallbacks for cross-platform emoji support */
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
/* gap: clamp(12px, 1.9dvh, 16px); */
|
|
17
17
|
/* gap: calc(12px + env(safe-area-inset-top)); */
|
|
18
18
|
position: absolute;
|
|
19
|
-
|
|
20
|
-
left:
|
|
21
|
-
top: clamp(40px, 5.69dvh, 48px); */
|
|
19
|
+
width: 100%;
|
|
20
|
+
left: 0;
|
|
21
|
+
/* top: clamp(40px, 5.69dvh, 48px); */
|
|
22
22
|
z-index: 3;
|
|
23
23
|
overflow: visible;
|
|
24
24
|
}
|
|
@@ -53,37 +53,39 @@
|
|
|
53
53
|
align-self: stretch;
|
|
54
54
|
display: flex;
|
|
55
55
|
flex-wrap: wrap;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
padding-left: calc(16px + env(safe-area-inset-left));
|
|
57
|
+
padding-right: calc(16px + env(safe-area-inset-right));
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
width: 100%;
|
|
59
60
|
position: relative;
|
|
60
61
|
z-index: 4;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
/*
|
|
64
|
-
.slide1-intro__brand--
|
|
65
|
-
font-size: clamp(
|
|
66
|
-
line-height: 1;
|
|
64
|
+
/* Short words (<=8 chars) - larger font */
|
|
65
|
+
.slide1-intro__brand--short {
|
|
66
|
+
font-size: clamp(40px, 14vw, 72px);
|
|
67
|
+
line-height: 1.1;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/*
|
|
70
|
-
.slide1-intro__brand--
|
|
71
|
-
font-size: clamp(
|
|
72
|
-
line-height: 1;
|
|
70
|
+
/* Medium words (9-14 chars) - medium font */
|
|
71
|
+
.slide1-intro__brand--medium {
|
|
72
|
+
font-size: clamp(32px, 10vw, 56px);
|
|
73
|
+
line-height: 1.1;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
/*
|
|
76
|
-
.slide1-intro__brand--
|
|
77
|
-
font-size: clamp(
|
|
76
|
+
/* Long words (15+ chars) - smaller font to fit */
|
|
77
|
+
.slide1-intro__brand--long {
|
|
78
|
+
font-size: clamp(24px, 7vw, 44px);
|
|
79
|
+
line-height: 1.1;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
/* Each word
|
|
82
|
+
/* Each word on its own line, never breaks mid-word */
|
|
81
83
|
.slide1-intro__word {
|
|
82
|
-
display:
|
|
83
|
-
white-space: nowrap;
|
|
84
|
+
display: block;
|
|
85
|
+
/* white-space: nowrap; */
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
/* Top floating frames - positioned
|
|
88
|
+
/* Top floating frames - positioned below business name */
|
|
87
89
|
.slide1-intro__frames-top {
|
|
88
90
|
display: flex;
|
|
89
91
|
flex-direction: row;
|
|
@@ -94,24 +96,21 @@
|
|
|
94
96
|
position: absolute;
|
|
95
97
|
width: 100%;
|
|
96
98
|
left: 0;
|
|
97
|
-
top:
|
|
99
|
+
top: 30vh;
|
|
98
100
|
z-index: 2;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
/*
|
|
102
|
-
|
|
103
|
-
.slide1-intro--words-1 .slide1-intro__frames-top {
|
|
103
|
+
/* Adjust frame position based on business name length */
|
|
104
|
+
.slide1-intro:has(.slide1-intro__brand--short) .slide1-intro__frames-top {
|
|
104
105
|
top: 26vh;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
.slide1-intro--words-2 .slide1-intro__frames-top {
|
|
108
|
+
.slide1-intro:has(.slide1-intro__brand--medium) .slide1-intro__frames-top {
|
|
109
109
|
top: 28vh;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
top: 32vh;
|
|
112
|
+
.slide1-intro:has(.slide1-intro__brand--long) .slide1-intro__frames-top {
|
|
113
|
+
top: 30vh;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
.slide1-intro__frames-top .frame-rect {
|
|
@@ -23,7 +23,15 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
|
|
|
23
23
|
const headline = introHeadline ?? copy.introHeadline;
|
|
24
24
|
const subtitle = introSubtitle ?? copy.introSubtitle;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// Calculate longest word length for font scaling
|
|
27
|
+
const words = businessName.split(' ');
|
|
28
|
+
const longestWordLength = Math.max(...words.map(w => w.length));
|
|
29
|
+
|
|
30
|
+
// Determine font size class based on longest word length
|
|
31
|
+
// Short words (<=8 chars): large font, Medium (9-14): medium, Long (15+): small
|
|
32
|
+
const fontSizeClass = longestWordLength <= 8 ? 'short' : longestWordLength <= 14 ? 'medium' : 'long';
|
|
33
|
+
|
|
34
|
+
const slideClass = `slide1-intro slide1-intro--${copy.introVariant}`;
|
|
27
35
|
const isNewUser = businessCategory === BUSINESS_CATEGORIES.NEW_USER;
|
|
28
36
|
|
|
29
37
|
const handleContinue = () => {
|
|
@@ -71,8 +79,8 @@ function Slide1Intro({ businessName, businessCategory, introHeadline, introSubti
|
|
|
71
79
|
<div className="slide1-intro__bg-text">HEY</div>
|
|
72
80
|
|
|
73
81
|
{/* Business name (character animation with natural word flow) */}
|
|
74
|
-
<div className={`slide1-intro__brand slide1-intro__brand
|
|
75
|
-
{
|
|
82
|
+
<div className={`slide1-intro__brand slide1-intro__brand--${fontSizeClass}`}>
|
|
83
|
+
{words.map((word, wordIndex, wordsArray) => {
|
|
76
84
|
// Calculate character offset for stagger delay (include space characters)
|
|
77
85
|
const charOffset = wordsArray
|
|
78
86
|
.slice(0, wordIndex)
|
package/dist/store/auth.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
package/dist/store/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/store/auth.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}));
|
package/dist/utils/Helpers.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/utils/Helpers.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/utils/RecapApi.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/utils/RecapApi.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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/src/store/auth.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
);
|
package/src/store/data.tsx
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
);
|
package/src/utils/Helpers.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
};
|
package/src/utils/RecapApi.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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;
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|