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

Disallow completing challenge when no profile exists #1109

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
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
11 changes: 8 additions & 3 deletions src/components/ProgressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from '@site/src/ui/design-system/src/lib/Components/Button';
import { useProgress } from '../hooks/use-progress';
import { submitNoopChallenge } from '../utils/gold-star';
import ChallengeModal from './ChallengeModal';
import { useProfile } from '../hooks/use-profile';

interface ProgressModalProps {
isOpen: boolean;
Expand All @@ -17,6 +18,7 @@ const ProgressModal: React.FC<ProgressModalProps> = ({
onClose,
onOpenProfileModal,
}) => {
const { profile, isLoading: isProfileLoading } = useProfile();
const { profileItems, challengeItems } = useProgress();
const [challengeModalOpen, setChallengeModalOpen] = useState(false);

Expand All @@ -34,8 +36,8 @@ const ProgressModal: React.FC<ProgressModalProps> = ({
<Modal isOpen={isOpen} onClose={onClose} title="Progress">
<div className="space-y-6">
<p className="text-sm text-gray-600 dark:text-gray-100">
Complete the steps below to unlock rewards and challenges. Keep track of your progress and stay on track
with your goals!
Complete the steps below to unlock rewards and challenges. Keep
track of your progress and stay on track with your goals!
</p>

{/* Profile Section */}
Expand All @@ -62,8 +64,11 @@ const ProgressModal: React.FC<ProgressModalProps> = ({
variant="primary"
className="w-full max-w-md"
onClick={openChallengeModal}
disabled={!profile}
>
View First Challenge to Complete
{profile || isProfileLoading
? 'View First Challenge to Complete'
: 'Create Profile to View Challenge'}
</Button>
</div>
</div>
Expand Down
Loading