Skip to content

Commit 70c0e98

Browse files
ZabeehUllahmujtabaidrees94
authored andcommitted
fix: bug resolutions
1 parent b91fb21 commit 70c0e98

5 files changed

Lines changed: 87 additions & 71 deletions

File tree

app/otp/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export default function OTPPage() {
138138
<Button type="submit" onClick={handleSubmit} disabled={isLoading}>
139139
{isLoading ? "Verifying..." : "Verify OTP"}
140140
</Button>
141+
{error && <p onClick={() => router.push("/auth")} className="text-sm text-blue-500 cursor-pointer">
142+
Go back to <span className="text-blue-500 cursor-pointer">login</span>
143+
</p>}
141144
</CardFooter>
142145
</Card>
143146
</div>

app/page.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export default function DashboardPage() {
106106

107107
// Clear saved config when setup is finished
108108
localStorage.removeItem("widgetConfig")
109+
localStorage.removeItem("auth")
109110

110111
const onboardingConfig = {
111112
customOnboarding: enableOnboarding,
@@ -232,9 +233,9 @@ export default function DashboardPage() {
232233
},
233234
},
234235
authOptions: {
235-
email: app?.authentication.email || false,
236-
gmail: app?.authentication.gmail || true,
237-
metamask: app?.authentication.wallet || true,
236+
email: app?.authentication.email ?? true,
237+
gmail: app?.authentication.gmail ?? true,
238+
metamask: app?.authentication.wallet ?? true,
238239
},
239240
});
240241

@@ -286,11 +287,6 @@ export default function DashboardPage() {
286287
}
287288
}, [id, app]);
288289

289-
const logout = () => {
290-
localStorage.clear()
291-
router.push("/")
292-
}
293-
294290
if (isLoading) {
295291
return (
296292
<div className="flex justify-center items-center h-screen">

components/WidgetCard.tsx

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import { useEffect, useRef, useState } from "react"
4-
import { ChevronDown, ChevronUp, ArrowRight, Upload, X, Plus } from "lucide-react"
4+
import { ChevronDown, ChevronUp, ArrowRight, Upload, X, Plus, Loader2 } from "lucide-react"
55
import { Button } from "@/components/ui/button"
66
import { Checkbox } from "@/components/ui/checkbox"
77
import { Input } from "@/components/ui/input"
@@ -84,7 +84,7 @@ export default function WidgetCard({
8484
currentQuestionIndex,
8585
setCurrentQuestionIndex,
8686
showRoulette,
87-
setShowRoulette
87+
setShowRoulette,
8888
}) {
8989
const [uploadedFile, setUploadedFile] = useState({ light: null, dark: null })
9090
const fileInputRef = useRef({})
@@ -96,7 +96,7 @@ export default function WidgetCard({
9696
const [isLoading, setIsLoading] = useState(false)
9797
const [isReturningUser, setIsReturningUser] = useState(false)
9898
const [isWidget, setIsWidget] = useState<boolean>(false)
99-
99+
100100
const { app, setApp } = useAppStore() // use for edit flow
101101
const searchParams = useSearchParams()
102102
const id = searchParams.get("id")
@@ -107,7 +107,7 @@ export default function WidgetCard({
107107
setIsWidget(true)
108108
}
109109
}, [])
110-
110+
111111
const handleAddQuestion = (type: QuestionType) => {
112112
if (questions.length == 3) return
113113
const id = Date.now()
@@ -289,9 +289,9 @@ export default function WidgetCard({
289289
categories: q.categories.map((cat) =>
290290
cat.id === categoryId
291291
? {
292-
...cat,
293-
tags: cat.tags.map((tag) => (tag.id === tagId ? { ...tag, text } : tag)),
294-
}
292+
...cat,
293+
tags: cat.tags.map((tag) => (tag.id === tagId ? { ...tag, text } : tag)),
294+
}
295295
: cat,
296296
),
297297
}
@@ -311,11 +311,11 @@ export default function WidgetCard({
311311
categories: q.categories.map((cat) =>
312312
cat.id === categoryId
313313
? {
314-
...cat,
315-
tags: cat.tags.filter((tag) => tag.id !== tagId),
316-
}
314+
...cat,
315+
tags: cat.tags.filter((tag) => tag.id !== tagId),
316+
}
317317
: cat,
318-
),
318+
),
319319
}
320320
}
321321
return q
@@ -335,15 +335,15 @@ export default function WidgetCard({
335335
filteredCategories.length > 0
336336
? filteredCategories
337337
: [
338-
{
339-
id: Date.now(),
340-
name: "New Category",
341-
tags: [
342-
{ id: Date.now() + 1, text: "Tag 1" },
343-
{ id: Date.now() + 2, text: "Tag 2" },
344-
],
345-
},
346-
],
338+
{
339+
id: Date.now(),
340+
name: "New Category",
341+
tags: [
342+
{ id: Date.now() + 1, text: "Tag 1" },
343+
{ id: Date.now() + 2, text: "Tag 2" },
344+
],
345+
},
346+
],
347347
}
348348
}
349349
return q
@@ -441,15 +441,15 @@ export default function WidgetCard({
441441
}
442442

443443
const addUrl = () => {
444-
const trimmedUrl = currentUrl.trim();
444+
const trimmedUrl = currentUrl.trim()
445445
if (trimmedUrl && !urls.includes(trimmedUrl)) {
446-
const urlPattern = /^(https?:\/\/)(www\.)?[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(:\d+)?$/;
446+
const urlPattern = /^(https?:\/\/)(www\.)?[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(:\d+)?$/
447447

448448
if (urlPattern.test(trimmedUrl)) {
449-
setUrls([...urls, trimmedUrl]);
450-
setCurrentUrl("");
449+
setUrls([...urls, trimmedUrl])
450+
setCurrentUrl("")
451451
} else {
452-
alert("Please enter a valid URL (e.g., https://example.com)");
452+
alert("Please enter a valid URL (e.g., https://example.com)")
453453
}
454454
}
455455
}
@@ -470,9 +470,9 @@ export default function WidgetCard({
470470
addUrl()
471471
}
472472

473-
474473
useEffect(() => {
475474
const getUniversalProfiles = async () => {
475+
setIsLoading(true)
476476
const response = await axios.get(`${process.env.NEXT_PUBLIC_DASHBOARD_API}/crm/client-app/universal-profile`)
477477
const universalProfiles = response?.data?.data?.universalProfiles
478478
if (universalProfiles) {
@@ -518,6 +518,7 @@ export default function WidgetCard({
518518
if (updatedProfilesWithCustom.length > 0 && !savedConfig) {
519519
setSelectedProfileType(updatedProfilesWithCustom[0])
520520
}
521+
setIsLoading(false)
521522
}
522523
}
523524
getUniversalProfiles()
@@ -741,28 +742,31 @@ export default function WidgetCard({
741742
</a>
742743
</span>
743744
),
744-
content: (
745+
content: isLoading ? (
746+
<div className="flex justify-center items-center py-12">
747+
<Loader2 className="h-6 w-6 text-gray-400 animate-spin" />
748+
</div>
749+
) : (
745750
<div className="space-y-5">
746751
<div>
747752
<h3 className="text-sm font-medium mb-3">Select or create profile</h3>
748753
<div className="bg-teal-50 p-3 rounded-md mb-4 text-xs">
749754
We offer some pre-built universal profiles. Use these to get access to rich user context and also reduce
750755
steps for your users
751756
</div>
752-
757+
753758
<div className="flex flex-wrap gap-2 mb-6">
754759
{profileTypes.map((type) => {
755-
const isCustom = type.profileDetails.id === "custom"
756760
const isSelected = selectedProfileType?.profileDetails?.id === type.profileDetails?.id
757-
761+
758762
return (
759763
<Button
760764
key={type.profileDetails.id}
761765
disabled={id ? disable || (!disable && type.profileDetails.id !== "custom") : false}
762766
variant={isSelected ? "default" : "outline"}
763767
className={`
764-
${isSelected ? "bg-teal-500 hover:bg-teal-600 text-white" : "bg-white text-gray-700 hover:bg-gray-50"}
765-
`}
768+
${isSelected ? "bg-teal-500 hover:bg-teal-600 text-white" : "bg-white text-gray-700 hover:bg-gray-50"}
769+
`}
766770
onClick={() => setSelectedProfileType(type)}
767771
>
768772
{type.profileDetails.label}
@@ -771,7 +775,7 @@ export default function WidgetCard({
771775
})}
772776
</div>
773777
</div>
774-
778+
775779
{selectedProfileType?.profileDetails?.id === "custom" && (
776780
<div className="space-y-4">
777781
<div className="grid grid-cols-3 gap-4 items-center">
@@ -783,11 +787,16 @@ export default function WidgetCard({
783787
id="profileName"
784788
placeholder="Enter Name"
785789
value={profileName}
786-
onChange={(e) => setProfileName(e.target.value)}
790+
onChange={(e) => {
791+
const newValue = e.target.value
792+
if(newValue.length <= 25){
793+
setProfileName(newValue)
794+
}
795+
}}
787796
/>
788797
</div>
789798
</div>
790-
799+
791800
<div className="grid grid-cols-3 gap-4 items-center">
792801
<label htmlFor="profileDescription" className="text-sm font-medium">
793802
Description
@@ -798,8 +807,9 @@ export default function WidgetCard({
798807
placeholder="Enter Description"
799808
value={profileDescription}
800809
onChange={(e) => {
801-
if (e.target.value.length <= 70) {
802-
setProfileDescription(e.target.value)
810+
const newValue = e.target.value
811+
if(newValue.length <= 60){
812+
setProfileDescription(newValue)
803813
}
804814
}}
805815
/>
@@ -808,7 +818,8 @@ export default function WidgetCard({
808818
</div>
809819
)}
810820
</div>
811-
),
821+
)
822+
812823
},
813824

814825
{
@@ -988,26 +999,34 @@ export default function WidgetCard({
988999
id: "platformConnection",
9891000
title: "Platform Connections",
9901001
description: "Supercharge your app with user data from relevant platforms",
991-
content: (
1002+
content: isLoading ? (
1003+
<div className="flex justify-center items-center py-12">
1004+
<Loader2 className="h-6 w-6 text-gray-400 animate-spin" />
1005+
</div>
1006+
) : (
9921007
<>
9931008
<div className="mb-5">
9941009
<PlatformConnection
9951010
setSelectedProfileType={setSelectedProfileType}
9961011
selectedProfileType={selectedProfileType}
997-
></PlatformConnection>
1012+
/>
9981013
</div>
1014+
9991015
<div className="flex items-center justify-between bg-gray-100 p-3 rounded-md">
1000-
<span className="text-xs font-medium">I don’t want user data from platforms in my application</span>
1016+
<span className="text-xs font-medium">
1017+
I don’t want user data from platforms in my application
1018+
</span>
10011019
<Switch checked={showRoulette} onCheckedChange={setShowRoulette} />
10021020
</div>
1003-
1021+
10041022
{!showRoulette && (
10051023
<p className="text-xs text-amber-600 mt-2">
1006-
Platforms view disabled
1024+
Platforms view disabled
10071025
</p>
10081026
)}
10091027
</>
1010-
),
1028+
)
1029+
10111030
},
10121031
{
10131032
id: "deploymentConfig",
@@ -1023,8 +1042,9 @@ export default function WidgetCard({
10231042
placeholder="Enter your app name"
10241043
value={appName}
10251044
onChange={(e) => {
1026-
if (appName.length < 20) {
1027-
setAppName(e.target.value)
1045+
const newValue = e.target.value
1046+
if (newValue.length <= 25) {
1047+
setAppName(newValue)
10281048
}
10291049
}}
10301050
/>
@@ -1086,14 +1106,15 @@ export default function WidgetCard({
10861106
if (!appName || appName == "<app_name_here>") return true
10871107

10881108
if (
1089-
selectedProfileType?.id == "custom" &&
1109+
selectedProfileType?.profileDetails?.id == "custom" &&
10901110
(!profileName ||
10911111
profileName == "<profile_name>" ||
10921112
!profileDescription ||
10931113
profileDescription == "Your custom profile description here" ||
10941114
!selectedProfileType?.platforms?.length)
1095-
)
1115+
) {
10961116
return true
1117+
}
10971118

10981119
if (enableOnboarding && questions.length == 0) return true
10991120
}
@@ -1128,7 +1149,7 @@ export default function WidgetCard({
11281149
},
11291150
},
11301151
authOptions: {
1131-
email: false,
1152+
email: true,
11321153
gmail: true,
11331154
metamask: true,
11341155
},
@@ -1141,6 +1162,8 @@ export default function WidgetCard({
11411162
setEnableOnboarding(false)
11421163
setQuestions([])
11431164
setCurrentQuestionIndex(0)
1165+
setIsReturningUser(false)
1166+
setIsWidget(false)
11441167
}
11451168

11461169
useEffect(() => {
@@ -1172,7 +1195,6 @@ export default function WidgetCard({
11721195
}
11731196
}, [id])
11741197

1175-
11761198
// Add a new function to check if any data has been modified from default values
11771199
const hasUserEnteredData = () => {
11781200
// Check if any customization data has been modified

components/clientInterface/platformConnectionConfig.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ const PlatformConnectionConfig: React.FC<PlatformConnectionConfigProps> = ({
120120

121121
// Check if we should use the custom logo
122122
const shouldUseCustomLogo = general?.icon?.light || general?.icon?.dark;
123-
123+
124+
if (!showRoulette) {
125+
return <div className="text-sm text-gray-500 mb-4 text-center">
126+
No platforms available for this app.
127+
</div>
128+
}
129+
124130
if (!hasPlatforms) {
125131
return <div className="text-sm text-gray-500 mb-4 text-center">
126132
No platforms available for this profile type.
@@ -132,7 +138,6 @@ const PlatformConnectionConfig: React.FC<PlatformConnectionConfigProps> = ({
132138
const isSmallInterface = satellitePlatforms && satellitePlatforms.length == 1;
133139

134140
return (
135-
<div className='relative overflow-hidden'>
136141
<div
137142
className={`${isMediumInterface ? 'w-[77%]' : 'w-full'} flex gap-2 justify-around max-w-sm mx-auto rounded-xl overflow-hidden p-1.5`}
138143
style={{
@@ -264,16 +269,6 @@ const PlatformConnectionConfig: React.FC<PlatformConnectionConfigProps> = ({
264269
)}
265270

266271
</div>
267-
{!showRoulette && (
268-
<div className="absolute inset-0 z-20 bg-gray-300 bg-opacity-80 flex flex-col items-center justify-center rounded-xl">
269-
<Lock
270-
className="mb-2 opacity-80"
271-
size={50}
272-
/>
273-
<p className="text-black font-semibold text-lg">View Locked</p>
274-
</div>
275-
)}
276-
</div>
277272
);
278273
};
279274

0 commit comments

Comments
 (0)