Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/app/community/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import Fuse from 'fuse.js';
import ReviewsSection from './ReviewsSection';
import { useState, useEffect, useMemo } from 'react';
Expand Down Expand Up @@ -137,7 +138,7 @@ export default function CommunityPage() {
<button
onClick={() => {
if (!user) {
alert('Please login to start a discussion.');
alert(AUTH_MESSAGES.LOGIN_TO_START_DISCUSSION);
return;
}
setShowCreateModal(true);
Expand Down
5 changes: 3 additions & 2 deletions src/app/community/view/client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import { useState, useEffect } from 'react';
import { useAuth } from '@/context/AuthContext';
import {
Expand Down Expand Up @@ -208,7 +209,7 @@ export default function DiscussionViewClient() {

const handleReaction = async (emoji: string) => {
if (!user || !discussionId) {
alert('Please login to react.');
alert(AUTH_MESSAGES.LOGIN_TO_REACT);
return;
}

Expand Down Expand Up @@ -479,7 +480,7 @@ export default function DiscussionViewClient() {
) : (
<div className="text-center p-8 bg-muted/20 rounded-xl border border-border/50 border-dashed">
<p className="text-muted-foreground">
Please login to reply to this discussion.
{AUTH_MESSAGES.LOGIN_TO_REPLY_TO_DISCUSSION}
</p>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/app/opensource/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import { useState, useEffect } from 'react';
import {
Github,
Expand Down Expand Up @@ -152,7 +153,7 @@ export default function OpenSourcePage() {

const handleConnectGitHub = async () => {
if (!user) {
alert('Please login to connect your GitHub account.');
alert(AUTH_MESSAGES.LOGIN_TO_CONNECT_GITHUB);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/u/client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { AUTH_MESSAGES } from '@/lib/constants';
const STATS_URL =
process.env.NEXT_PUBLIC_GITHUB_STATS_URL ??
'https://github-readme-stats-salesp07.vercel.app';
Expand Down Expand Up @@ -420,7 +421,7 @@ function ProfileContent({ uid }: { uid?: string }) {
currentLikes: string[]
) => {
if (!currentUser) {
alert('Please login to like projects.');
alert(AUTH_MESSAGES.LOGIN_TO_LIKE_PROJECTS);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/profile/FollowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import { useState, useEffect } from 'react';
import { useAuth } from '@/context/AuthContext';
import { UserPlus, UserCheck, Loader2 } from 'lucide-react';
Expand Down Expand Up @@ -31,7 +32,7 @@ export default function FollowButton({

const handleFollowToggle = async () => {
if (!user) {
alert('Please login to follow users.');
alert(AUTH_MESSAGES.LOGIN_TO_FOLLOW_USERS);
return;
}
if (user.uid === targetUserId) return;
Expand Down
3 changes: 2 additions & 1 deletion src/components/profile/UserProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { AUTH_MESSAGES } from '@/lib/constants';
const AVATAR_FALLBACK =
process.env.NEXT_PUBLIC_AVATAR_FALLBACK_URL ?? 'https://ui-avatars.com/api';
import { useState, useEffect, useRef } from 'react';
Expand Down Expand Up @@ -407,7 +408,7 @@ export default function UserProfile() {
if (!user) {
return (
<div className="flex items-center justify-center min-h-screen">
<p>Please login to view your profile.</p>
<p>{AUTH_MESSAGES.LOGIN_TO_VIEW_PROFILE}</p>
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/projects/ProjectCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import { useState, type ReactNode } from 'react';
import { Target, ExternalLink, Edit3, Star, Bookmark } from 'lucide-react';
import Image from 'next/image';
Expand Down Expand Up @@ -118,7 +119,7 @@ export default function ProjectCard({
const handleToggleStar = async (e: React.MouseEvent) => {
e.stopPropagation();
if (!user) {
alert('Please login to star projects.');
alert(AUTH_MESSAGES.LOGIN_TO_STAR_PROJECTS);
return;
}
if (isStarring) return;
Expand Down
3 changes: 2 additions & 1 deletion src/components/resources/InternshipCalendarModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { AUTH_MESSAGES } from '@/lib/constants';
import { useState, useEffect } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import {
Expand Down Expand Up @@ -84,7 +85,7 @@ export function InternshipCalendarModal({

const handleStar = async () => {
if (!user) {
alert('Please login to star resources!');
alert(AUTH_MESSAGES.LOGIN_TO_STAR_RESOURCES);
return;
}

Expand Down
24 changes: 24 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Centralized static strings used across the app.
*
* Goal: avoid the same (or near-identical) hardcoded strings being
* duplicated across components, so copy changes only need to happen
* in one place.
*
* This file currently covers the "please log in to do X" family of
* messages, since those were the most widely duplicated pattern found
* across the codebase. Other scattered one-off alert/error strings can
* be migrated here incrementally in follow-up PRs.
*/

export const AUTH_MESSAGES = {
LOGIN_TO_STAR_PROJECTS: 'Please login to star projects.',
LOGIN_TO_STAR_RESOURCES: 'Please login to star resources!',
LOGIN_TO_REACT: 'Please login to react.',
LOGIN_TO_LIKE_PROJECTS: 'Please login to like projects.',
LOGIN_TO_FOLLOW_USERS: 'Please login to follow users.',
LOGIN_TO_CONNECT_GITHUB: 'Please login to connect your GitHub account.',
LOGIN_TO_START_DISCUSSION: 'Please login to start a discussion.',
LOGIN_TO_REPLY_TO_DISCUSSION: 'Please login to reply to this discussion.',
LOGIN_TO_VIEW_PROFILE: 'Please login to view your profile.',
} as const;
Loading