-
Notifications
You must be signed in to change notification settings - Fork 6
Next application #175
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
base: prod-next-app
Are you sure you want to change the base?
Next application #175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,317 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useState, useEffect } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useAppSelector } from "@/Store"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageSquare, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Share2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mail, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Facebook, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Twitter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Linkedin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Link2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Check, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pencil, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Save, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| X, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "lucide-react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { showToast } from "@/components/toast"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface ParticipantPageClientProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonId: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userId: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonName: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonStartDate: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonEndDate: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonReviewsGoal: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placesMapped: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userName: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DEFAULT_MESSAGE = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "I'm helping map accessibility in my community. Join me to make spaces more inclusive."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default function ParticipantPageClient({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonStartDate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonEndDate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapathonReviewsGoal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placesMapped, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: ParticipantPageClientProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentUserId = useAppSelector((state) => state.user.user?.id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isOwner = currentUserId === userId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [personalMessage, setPersonalMessage] = useState(DEFAULT_MESSAGE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [isEditing, setIsEditing] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [editText, setEditText] = useState(DEFAULT_MESSAGE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [copied, setCopied] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [pageUrl, setPageUrl] = useState(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [shareUrl, setShareUrl] = useState(""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Load saved message from localStorage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof window !== "undefined") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const origin = window.location.origin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setPageUrl(window.location.href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setShareUrl( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `${origin}/share/mapathon/${mapathonId}/participant/${userId}` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const savedMessage = localStorage.getItem( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `participant-message-${mapathonId}-${userId}` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (savedMessage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setPersonalMessage(savedMessage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setEditText(savedMessage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [mapathonId, userId]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleSaveMessage = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const trimmed = editText.trim(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!trimmed) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setPersonalMessage(trimmed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| localStorage.setItem( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `participant-message-${mapathonId}-${userId}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trimmed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setIsEditing(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showToast({ message: "Message saved!", type: "success" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleCancelEdit = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setEditText(personalMessage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setIsEditing(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const shareText = `Support my accessibility Mapathon: ${shareUrl || pageUrl}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleCopyLink = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await navigator.clipboard.writeText(shareUrl || pageUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setCopied(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setCopied(false), 2000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fallback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const textarea = document.createElement("textarea"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| textarea.value = shareUrl || pageUrl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+102
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const shareText = `Support my accessibility Mapathon: ${shareUrl || pageUrl}`; | |
| const handleCopyLink = async () => { | |
| try { | |
| await navigator.clipboard.writeText(shareUrl || pageUrl); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch { | |
| // Fallback | |
| const textarea = document.createElement("textarea"); | |
| textarea.value = shareUrl || pageUrl; | |
| const resolvedShareUrl = shareUrl || pageUrl; | |
| const trimmedPersonalMessage = personalMessage.trim(); | |
| const shareText = trimmedPersonalMessage | |
| ? `${trimmedPersonalMessage}\n\nSupport my accessibility Mapathon: ${resolvedShareUrl}` | |
| : `Support my accessibility Mapathon: ${resolvedShareUrl}`; | |
| const handleCopyLink = async () => { | |
| try { | |
| await navigator.clipboard.writeText(resolvedShareUrl); | |
| setCopied(true); | |
| setTimeout(() => setCopied(false), 2000); | |
| } catch { | |
| // Fallback | |
| const textarea = document.createElement("textarea"); | |
| textarea.value = resolvedShareUrl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several props are destructured but never used (
mapathonAddress,mapathonStartDate,mapathonEndDate,mapathonReviewsGoal,placesMapped,userName). This is dead code and can triggerno-unused-varslint warnings; consider removing unused props fromParticipantPageClientProps/destructuring (or prefix with_if they’re intentionally reserved for a follow-up).