Skip to content

Repository files navigation

Hackday App — Data Flow and State Overview

Global State: src/contexts/HackathonContext.tsx

  • State shape: currentUser, projects, challenges, bounties, goodies, attendees, loading, error.
  • Important Types: User, Project, Attendee, Challenge, Bounty.
  • Session: Saved/restored via localStorage by the Provider’s saveSession/loadSession/clearSession.
  • Project editing access: Any user whose email appears in Project.teamMembers is considered a project editor.

Key API functions

  • updateUserProfile(userId, { profile, name, firstName, lastName })
    • Merges into currentUser.profile and updates currentUser.name when provided.
    • Also updates the matching Attendee entry (by email) with firstName, lastName, and merged profile.
  • createProject(project) / updateProject(id, updates)
    • Persist projects into global state. Team member email list (teamMembers) determines who can edit the project via HackerProject screen.

Components and Data Flow

src/components/HackerProject.tsx

  • Purpose: Create/Edit a hacker’s project.
  • State binding:
    • Loads the current user’s project by checking if currentUser.email is included in any project.teamMembers.
    • All project fields (name, description, links, tags, challenges, team members) bind to local component state and are saved to global state with createProject or updateProject.
  • Team management:
    • Add/remove/update team members by email.
    • After adding a teammate’s email, they can edit the same project since HackerProject checks membership by teamMembers.includes(currentUser.email).
    • Shows a guidance banner if the user is solo (only one non-empty email).
  • Constraints:
    • teamName is optional; the UI does not enforce it.
  • Profile completion banner:
    • A clickable banner prompts “Complete your profile”; clicking opens ProfileEditor.
    • An X dismiss button persists dismissal to localStorage with a key per-user (profile-banner-dismissed-<email>).

src/components/ProfileEditor.tsx

  • Purpose: Edit the current user’s profile and identity.
  • Prefill: firstName/lastName are populated from the matching attendee (if found) or split from currentUser.name.
  • Fields: First name, Last name, City, LinkedIn, Twitter, Bio, and tag-like Other Projects (renamed to "Add Tags").
  • Save: Calls updateUserProfile with { profile, name, firstName, lastName } so both currentUser and the matching Attendee record are updated in global state.

Dashboards

  • src/components/HostDashboard.tsx
  • src/components/SponsorDashboard.tsx
    • Both dashboards show a clickable, dismissible “Complete your profile” banner (same behavior as project page).
    • Non-onboarding back buttons were removed; back navigation is handled at the app shell (HackathonInterface) and appears only during onboarding.
    • Lists, stats, and tables are derived from global state (projects, attendees, bounties, challenges, goodies).
    • Any UI not backed by state has been removed/avoided.

src/components/HackathonInterface.tsx

  • Back button: Shown only during onboarding screens (hostLogin, sponsorLogin, hackerSignup, projectQuestions, projectSetup). Positioned bottom-left.
  • Screen routing: Directs between major app screens and passes data through formData or hostDashboardData where required.

How to Collaborate on Projects

  • Adding teammates:
    • In the project page, add teammates by entering their email under Team Members.
    • Saving persists to global state; the added teammate (when logged in with that email) will be able to edit the same project.
  • Joining an existing project:
    • You must ask the project creator to add your email to their project’s Team Members list.
    • Once added, refresh or revisit the project page to load the project for your account.
  • Removing a teammate:
    • Use the remove button next to a team member email; save to persist the change.

Persistence

  • Session: Provider stores a session with user and datasets in localStorage. The closable profile banner also stores a per-user dismissal flag in localStorage.

Notes and Guarantees

  • teamName is optional and not required to save a project.
  • Project editing rights are determined solely by email membership in teamMembers.
  • Profile changes update both the currentUser and corresponding Attendee record for consistency across dashboards.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages