Skip to content

refactor: centralize auth-gate strings into src/lib/constants.ts - #807

Merged
Aditya948351 merged 1 commit into
Aditya948351:masterfrom
nishupr:refactor/centralize-constants
Jul 8, 2026
Merged

refactor: centralize auth-gate strings into src/lib/constants.ts #807
Aditya948351 merged 1 commit into
Aditya948351:masterfrom
nishupr:refactor/centralize-constants

Conversation

@nishupr

@nishupr nishupr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #750 — creates src/lib/constants.ts and extracts scattered hardcoded strings into an exported object for cleaner maintenance.

Scope

Audited the codebase for hardcoded alert()/message strings (16 files use alert() directly). The clearest, most valuable duplication was the "please log in to do X" family of messages, which appeared — with slightly different wording each time — across 8 different files. Centralized those first, since they're genuinely the same concept repeated, not just coincidentally similar text.

Other one-off success/error strings (e.g. "User updated successfully.", "Failed to update user.") are more page-specific and less clearly duplicated; left them as-is for a possible follow-up rather than making this PR sprawl across all 16 files.

Changes

New: src/lib/constants.ts

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;

Migrated 8 files to use AUTH_MESSAGES instead of literal strings:

  • src/components/projects/ProjectCard.tsx
  • src/components/profile/FollowButton.tsx
  • src/components/profile/UserProfile.tsx
  • src/components/resources/InternshipCalendarModal.tsx
  • src/app/community/page.tsx
  • src/app/community/view/client.tsx
  • src/app/opensource/page.tsx
  • src/app/u/client.tsx

No behavior or copy changes — every message renders exactly as before, just sourced from one shared file instead of being duplicated inline.

How to test

  1. npm run dev
  2. While logged out, try to star a project, follow a user, and react to a discussion
  3. Confirm each alert/message text is unchanged from before

Related Issue

Closes #750

@github-actions github-actions Bot added good first issue gssoc26 This is a official GirlScript Summer of Code label. level:beginner Beginner level issues type:bug type:refactor labels Jul 8, 2026
@Aditya948351
Aditya948351 merged commit 741a055 into Aditya948351:master Jul 8, 2026
4 checks passed
@nishupr

nishupr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

hey @Aditya948351 thank you for merging the PR, could you please add the gssoc:approved label as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue gssoc26 This is a official GirlScript Summer of Code label. level:beginner Beginner level issues type:bug type:refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Centralize standard static strings into a constants file

2 participants