Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: userflow #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions apps/web/src/app/ideology-test/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default function IdeologyTest() {
const [isSubmitting, setIsSubmitting] = useState(false);
const [originalAnswers, setOriginalAnswers] = useState<Record<string, number>>({});
const [hasUnsavedChanges] = useState(false);
const [selectedAnswer, setSelectedAnswer] = useState<number | null>(null);
const [isProcessingAnswer, setIsProcessingAnswer] = useState(false);

const totalQuestions = questions.length;
const progress = ((currentQuestion + 1) / totalQuestions) * 100;
Expand Down Expand Up @@ -236,7 +238,11 @@ export default function IdeologyTest() {
};

const handleAnswer = async (multiplier: number) => {
if (questions.length === 0 || isSubmitting) return;
if (questions.length === 0 || isSubmitting || isProcessingAnswer) return;

// Set the selected answer and processing state
setSelectedAnswer(multiplier);
setIsProcessingAnswer(true);

const question = questions[currentQuestion];
const updatedScores = {
Expand Down Expand Up @@ -270,11 +276,18 @@ export default function IdeologyTest() {
[question.id]: multiplier,
}));

if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
}
// Add a delay before moving to the next question
setTimeout(() => {
if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
}
setIsProcessingAnswer(false);
setSelectedAnswer(null);
}, 800); // 800ms delay to show the selected answer
} catch (error) {
console.error("Error saving progress:", error);
setIsProcessingAnswer(false);
setSelectedAnswer(null);
}
};

Expand Down Expand Up @@ -393,9 +406,10 @@ export default function IdeologyTest() {
)}

{answerOptions.map((answer) => {
const isSelected =
userAnswers[questions[currentQuestion].id] ===
answer.multiplier;
const isSelected =
selectedAnswer === answer.multiplier ||
userAnswers[questions[currentQuestion].id] === answer.multiplier;

return (
<FilledButton
key={`${answer.label}-${answer.multiplier}`}
Expand All @@ -407,6 +421,7 @@ export default function IdeologyTest() {
: "bg-[#387478] hover:bg-[#387478]/90"
} rounded-[30px] shadow-[0px_4px_4px_rgba(0,0,0,0.25)] text-white text-base font-bold`}
onClick={() => handleAnswer(answer.multiplier)}
disabled={isProcessingAnswer}
>
{answer.label}
</FilledButton>
Expand All @@ -420,10 +435,10 @@ export default function IdeologyTest() {
variant="primary"
size="sm"
onClick={handlePrevious}
disabled={currentQuestion === 0}
disabled={currentQuestion === 0 || isProcessingAnswer}
className={cn(
"bg-[#E36C59] hover:bg-[#E36C59]/90",
currentQuestion === 0 && "opacity-50 cursor-not-allowed"
(currentQuestion === 0 || isProcessingAnswer) && "opacity-50 cursor-not-allowed"
)}
>
Previous
Expand All @@ -436,10 +451,10 @@ export default function IdeologyTest() {
variant="primary"
size="sm"
onClick={handleEndTest}
disabled={isSubmitting}
disabled={isSubmitting || isProcessingAnswer}
className={cn(
"bg-green-600 hover:bg-green-700",
isSubmitting && "opacity-50 cursor-not-allowed",
(isSubmitting || isProcessingAnswer) && "opacity-50 cursor-not-allowed",
)}
>
{isSubmitting ? "Saving..." : "End Test"}
Expand All @@ -449,7 +464,11 @@ export default function IdeologyTest() {
variant="primary"
size="sm"
onClick={handleNext}
className="bg-[#E36C59] hover:bg-[#E36C59]/90"
disabled={isProcessingAnswer}
className={cn(
"bg-[#E36C59] hover:bg-[#E36C59]/90",
isProcessingAnswer && "opacity-50 cursor-not-allowed"
)}
>
Next
</FilledButton>
Expand Down
13 changes: 10 additions & 3 deletions apps/web/src/app/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { NotificationDialog } from "@/components/ui/feedback/NotificationError";
import { Input } from "@/components/ui/base/input";
import { COUNTRIES, type CountryCode } from "@/constants/countries";
import { MiniKit } from "@worldcoin/minikit-js";
import type { RequestPermissionPayload } from "@worldcoin/minikit-js";
import { Permission } from "@worldcoin/minikit-js";
// import type { RequestPermissionPayload } from "@worldcoin/minikit-js";
//import { Permission } from "@worldcoin/minikit-js";
import { useRouter, useSearchParams } from "next/navigation";
import type * as React from "react";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -52,8 +52,11 @@ export default function Register() {
}));
}, [userId, router]);

// Function to request notification permission
// Function to request notification permission - commented out
const requestPermission = async () => {
// Notification permission request is now commented out
// This allows registration to proceed without requiring notification permissions
/*
const requestPermissionPayload: RequestPermissionPayload = {
permission: Permission.Notifications,
};
Expand All @@ -69,6 +72,10 @@ export default function Register() {
}
return null;
}
*/

// Return a resolved promise to maintain function signature
return Promise.resolve(null);
};

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
Expand Down
Loading