Skip to content

Mave/event attendance modal #10

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions app/event-attendance/EventAttendance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import './EventAttendance.css';

//should be removed after Volunteer component is created
interface Volunteer {
id: number;
name: string;
attended: boolean;
}

//should be removed after event component is created
interface EventProps {
name: string;
start: string;
end: string;
volunteers: Volunteer[];
description: string;
}

interface EventAttendanceProps {
event: EventProps;
updateAttendance: (volunteerId: number, attended: boolean) => void;
}

//should be updated after volunteer/event components are created
const Content: React.FC<EventAttendanceProps> = ({ event, updateAttendance }) => {
return (
<div className="event-attendance-container">
<div className="event-details">
<h2>{event.name}</h2>
<p>{event.description}</p>
</div>
<div className="volunteer-list">
{event.volunteers.map(volunteer => (
<div className="volunteer-item" key={volunteer.id}>
<span>{volunteer.name}</span>
<input
type="checkbox"
checked={volunteer.attended}
onChange={(e) => updateAttendance(volunteer.id, e.target.checked)}
/>
</div>
))}
</div>
</div>
);
};

export default Content;
34 changes: 34 additions & 0 deletions app/event-attendance/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';
import React, { useState} from 'react';
import EventAttendance from './EventAttendance';

const EventAttendancePage = () => {
const [event, setEvent] = useState({
name: 'Sample Event',
start: '2024-02-01 09:00 PST',
end: '2024-02-01 11:00 PST',
volunteers: [
{ id: 1, name: 'Volunteer 1', attended: false },
{ id: 2, name: 'Volunteer 2', attended: false },
{ id: 3, name: 'Volunteer 3', attended: false }
],
description: 'This is a sample event description.'
});

const updateAttendance = (volunteerId: number, attended: boolean) => {
setEvent(prevEvent => ({
...prevEvent,
volunteers: prevEvent.volunteers.map(volunteer =>
volunteer.id === volunteerId ? { ...volunteer, attended: attended } : volunteer
)
}));
};

return (
<div>
<EventAttendance event={event} updateAttendance={updateAttendance} />
</div>
);
}

export default EventAttendancePage;
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
"lint": "next lint"
},
"dependencies": {
"@types/bootstrap": "^5.2.10",
"next": "14.0.3",
"react": "^18",
"react-dom": "^18",
"next": "14.0.3"
"react-dom": "^18"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.3",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"eslint-config-next": "14.0.3"
"typescript": "^5"
}
}