Skip to content

Commit dcaab67

Browse files
ZabeehUllahmujtabaidrees94
authored andcommitted
fix: UI bugs reported in e2e testing
1 parent 400eb95 commit dcaab67

8 files changed

Lines changed: 194 additions & 144 deletions

File tree

app/auth/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export default function AuthPage() {
3333

3434
useEffect(() => {
3535
setStytchToken(localStorage.getItem("stytchToken"));
36+
const editMode = localStorage.getItem('editMode')
37+
if(editMode){
38+
setActiveTab("login")
39+
}
3640
}, []);
3741

3842
const validateForm = () => {

app/dashboard/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function DashboardPage() {
3434
const { app, setApp } = useAppStore();
3535

3636

37-
const { hideDashboard } = useAuth()
37+
const { hideDashboard, logout } = useAuth()
3838

3939

4040
const getClientApps = async () => {
@@ -85,20 +85,14 @@ export default function DashboardPage() {
8585

8686
})
8787
);
88-
// console.log("UPDATED APPS => ",updatedApps);
89-
90-
// const stream_data=await selectProfileType("kjzl6kcym7w8y6hhihqpmq4ul15xjxpwgxgu3zgr02fce448rtqn1tmsyea3110")
91-
// console.log("Stream Data=> ", stream_data)
92-
// setClientApps(response.data.client.apps)
9388
setClientApps(updatedApps);
9489
} else {
9590
setError("Unexpected data format received from server")
9691
}
9792
} catch (err) {
9893
setError("You are not authorize please login again")
9994
console.error("Error fetching client apps:", err)
100-
localStorage.clear();
101-
router.push("/")
95+
logout()
10296
} finally {
10397
setIsLoading(false)
10498
}

app/page.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function DashboardPage() {
6161
const [error, setError] = useState<string | null>(null)
6262
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0)
6363
const [expandedSection, setExpandedSection] = useState("customize")
64-
const [showRoulette, setShowRoulette] = useState(true)
64+
const [showRoulette, setShowRoulette] = useState(false)
6565
const { app } = useAppStore() // use for edit flow
6666
const { addProject, project } = useProjects() // use for secrt flow
6767

@@ -86,7 +86,7 @@ export default function DashboardPage() {
8686
// 2. PROFILE CONFIGURATION DATA
8787
const [selectedProfileType, setSelectedProfileType] = useState<ProfileType | null>(null)
8888
const [profileName, setProfileName] = useState("<profile_name>")
89-
const [profileDescription, setProfileDescription] = useState("Your custom profile description here")
89+
const [profileDescription, setProfileDescription] = useState("<Your_custom_profile_description_here>")
9090

9191
// 3. DEPLOYMENT CONFIGURATIONS DATA
9292
const [urls, setUrls] = useState([])
@@ -138,13 +138,13 @@ export default function DashboardPage() {
138138
dark: customizationData.general.icon.dark,
139139
},
140140
authOptions: customizationData.authOptions,
141-
showRoulette,
141+
showRoulette: !showRoulette,
142142
clientId: localStorage.getItem("clientId"),
143143
domains: urls,
144144
appName,
145145
onboardingConfig,
146146
platformNeeded: selectedProfileType?.profileDetails?.id === "custom" ? selectedProfileType.platforms : [],
147-
streamId: selectedProfileType?.profileDetails.streamId,
147+
streamId: id && selectedProfileType?.profileDetails?.id === "custom"? app?.streamId : selectedProfileType?.profileDetails.streamId,
148148
}
149149

150150
const dataForStorage = id ? { ...baseData, id } : baseData
@@ -202,7 +202,10 @@ export default function DashboardPage() {
202202
}
203203

204204
useEffect(() => {
205-
routeToDashboard()
205+
const storedToken = localStorage.getItem("stytchToken")
206+
if(storedToken){
207+
routeToDashboard()
208+
}
206209
}, [])
207210

208211
useEffect(() => {
@@ -223,14 +226,13 @@ export default function DashboardPage() {
223226
setEnableOnboarding(parsedConfig.enableOnboarding || enableOnboarding)
224227
setQuestions(parsedConfig.questions || questions)
225228
setCurrentQuestionIndex(parsedConfig.currentQuestionIndex || currentQuestionIndex)
226-
setShowRoulette(parsedConfig.showRoulette || true)
229+
setShowRoulette(parsedConfig.showRoulette ?? true)
227230
}
228231
}, [id, app])
229232

230233
useEffect(() => {
231234
if (id) {
232235
localStorage.setItem("editMode", 'true')
233-
console.log("App", app)
234236
setCustomizationData({
235237
general: {
236238
theme: "light",
@@ -290,7 +292,7 @@ export default function DashboardPage() {
290292

291293
setAppName(app?.appName || "<app_name_here>");
292294
setUrls(Array.isArray(app?.domains) ? app.domains : JSON.parse(app?.domains || "[]"));
293-
setShowRoulette(app?.showRoulette || true);
295+
setShowRoulette(!app?.showRoulette);
294296
}else{
295297
localStorage.removeItem("editMode")
296298
}

components/WidgetCard.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +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+
const [hasUploadedImage, setHasUploadedImage] = useState<boolean>(false)
99100

100101
const { app, setApp } = useAppStore() // use for edit flow
101102
const searchParams = useSearchParams()
@@ -130,7 +131,7 @@ export default function WidgetCard({
130131
newQuestion = {
131132
id,
132133
type: "CATEGORY_QUESTION",
133-
mainQuestion: "",
134+
mainQuestion: "Pick topics that interest you",
134135
supportingText: "",
135136
categories: [
136137
{
@@ -380,6 +381,7 @@ export default function WidgetCard({
380381

381382
const handleRemoveFile = (mode) => {
382383
setUploadedFile((prev) => ({ ...prev, [mode]: null }))
384+
setHasUploadedImage(false)
383385
if (fileInputRef.current?.[mode]) {
384386
fileInputRef.current[mode].value = null
385387

@@ -454,7 +456,9 @@ export default function WidgetCard({
454456
const handleKeyDown = (e) => {
455457
if (e.key === "Enter") {
456458
e.preventDefault()
457-
addUrl()
459+
if(urls.length < 3) {
460+
addUrl()
461+
}
458462
}
459463
}
460464

@@ -522,6 +526,9 @@ export default function WidgetCard({
522526
if (questions.length > 0 && currentQuestionIndex >= questions.length) {
523527
setCurrentQuestionIndex(Math.max(0, questions.length - 1))
524528
}
529+
if (customizationData?.general?.icon?.light) {
530+
setHasUploadedImage(true)
531+
}
525532
}, [questions.length, currentQuestionIndex])
526533

527534
const getCustomAppPlatforms = async (appStreamId: string) => {
@@ -550,6 +557,10 @@ export default function WidgetCard({
550557
setSelectedProfileType(customProfile)
551558
setDisable(false) // Enable only "custom"
552559
}
560+
561+
if (app.logos?.dark || app.logos?.light) {
562+
setHasUploadedImage(true)
563+
}
553564
}
554565
}, [id, profileTypes, app])
555566

@@ -576,9 +587,9 @@ export default function WidgetCard({
576587
accept="image/*"
577588
/>
578589

579-
{uploadedFile?.light ? (
590+
{(uploadedFile?.light || hasUploadedImage) ? (
580591
<div className="flex items-center gap-2 bg-gray-100 px-3 py-1 rounded-md text-xs text-gray-700">
581-
<span className="truncate max-w-[120px]">{uploadedFile.light.name}</span>
592+
<span className="truncate max-w-[120px]">{uploadedFile?.light?.name || "image"} </span>
582593
<button onClick={() => handleRemoveFile("light")}>
583594
<X className="w-4 h-4 text-red-500 hover:text-red-700" />
584595
</button>
@@ -823,7 +834,13 @@ export default function WidgetCard({
823834
<div className="space-y-5">
824835
<div className="flex items-center justify-between bg-gray-100 p-3 rounded-md">
825836
<span className="text-sm font-medium">Enable custom onboarding flows</span>
826-
<Switch checked={enableOnboarding} onCheckedChange={setEnableOnboarding} />
837+
<Switch checked={enableOnboarding} onCheckedChange={() => {
838+
setEnableOnboarding((prev) => !prev)
839+
if (enableOnboarding) {
840+
setQuestions([])
841+
setCurrentQuestionIndex(0)
842+
}
843+
}} />
827844
</div>
828845

829846
{enableOnboarding && (
@@ -998,12 +1015,12 @@ export default function WidgetCard({
9981015
</div>
9991016
) : (
10001017
<>
1001-
<div className="mb-5">
1018+
{!showRoulette && <div className="mb-5">
10021019
<PlatformConnection
10031020
setSelectedProfileType={setSelectedProfileType}
10041021
selectedProfileType={selectedProfileType}
10051022
/>
1006-
</div>
1023+
</div>}
10071024

10081025
<div className="flex items-center justify-between bg-gray-100 p-3 rounded-md">
10091026
<span className="text-xs font-medium">
@@ -1012,7 +1029,7 @@ export default function WidgetCard({
10121029
<Switch checked={showRoulette} onCheckedChange={setShowRoulette} />
10131030
</div>
10141031

1015-
{!showRoulette && (
1032+
{showRoulette && (
10161033
<p className="text-xs text-amber-600 mt-2">
10171034
Platforms view disabled
10181035
</p>
@@ -1100,6 +1117,7 @@ export default function WidgetCard({
11001117

11011118
if (
11021119
selectedProfileType?.profileDetails?.id == "custom" &&
1120+
!showRoulette &&
11031121
(!profileName ||
11041122
profileName == "<profile_name>" ||
11051123
!profileDescription ||
@@ -1123,6 +1141,7 @@ export default function WidgetCard({
11231141
enableOnboarding,
11241142
questions,
11251143
currentQuestionIndex,
1144+
showRoulette,
11261145
savedAt: new Date().getTime(), // Add timestamp
11271146
}
11281147

@@ -1154,6 +1173,7 @@ export default function WidgetCard({
11541173
setAppName("<app_name_here>")
11551174
setEnableOnboarding(false)
11561175
setQuestions([])
1176+
setShowRoulette(false)
11571177
setCurrentQuestionIndex(0)
11581178
setIsReturningUser(false)
11591179
setIsWidget(false)

components/clientInterface/oboardingQuestions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const OnboardingQuestions = ({ questions, currentQuestionIndex, setCurrentQuesti
230230

231231
<h2 className="text-2xl font-bold text-gray-800 mb-3">
232232
{questions[currentQuestionIndex]?.type === 'CATEGORY_QUESTION' ? (
233-
<>{questions[currentQuestionIndex]?.mainQuestion || 'Pick topics that interest you'}</>
233+
<>{questions[currentQuestionIndex]?.mainQuestion}</>
234234
) : (
235235
<>
236236
{questions[currentQuestionIndex]?.mainQuestion || `Question ${currentQuestionIndex + 1}`}

0 commit comments

Comments
 (0)