-
Notifications
You must be signed in to change notification settings - Fork 1
Activitydiscovery/interation1 #45
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
EvaYinn
wants to merge
5
commits into
main
Choose a base branch
from
activitydiscovery/interation1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...tactivecore/src/main/java/com/bu/getactivecore/model/configuration/application.properties
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont duplicate files, work from the existing code from main branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| server.port=8080 | ||
| spring.datasource.url=jdbc:h2:mem:testdb | ||
| spring.datasource.driverClassName=org.h2.Driver | ||
| spring.datasource.username=sa | ||
| spring.datasource.password=password | ||
| spring.jpa.database-platform=org.hibernate.dialect.H2Dialect | ||
| spring.h2.console.enabled=true |
28 changes: 28 additions & 0 deletions
28
...getactivecore/src/main/java/com/bu/getactivecore/model/controller/ActivityController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.getactive.controller; | ||
|
|
||
| import com.getactive.model.Activity; | ||
| import com.getactive.service.ActivityService; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/activities") | ||
| @CrossOrigin(origins = "*") // Enable Cross-Origin for frontend requests | ||
| public class ActivityController { | ||
| private final ActivityService service; | ||
|
|
||
| public ActivityController(ActivityService service) { | ||
| this.service = service; | ||
| } | ||
|
|
||
| @GetMapping | ||
| public List<Activity> getAllActivities() { | ||
| return service.getAll(); | ||
| } | ||
|
|
||
| @PostMapping | ||
| public Activity createActivity(@RequestBody Activity activity) { | ||
| return service.create(activity); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
code/backend/getactivecore/src/main/java/com/bu/getactivecore/model/model/Activity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.getactive.model; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Entity | ||
| public class Activity { | ||
| @Id @GeneratedValue | ||
| private Long id; | ||
| private String title; | ||
| private String location; | ||
| private LocalDateTime datetime; | ||
|
|
||
| // Getters and Setters | ||
| } |
6 changes: 6 additions & 0 deletions
6
...getactivecore/src/main/java/com/bu/getactivecore/model/repository/ActivityRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.getactive.repository; | ||
|
|
||
| import com.getactive.model.Activity; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface ActivityRepository extends JpaRepository<Activity, Long> {} |
24 changes: 24 additions & 0 deletions
24
...ckend/getactivecore/src/main/java/com/bu/getactivecore/model/service/ActivityService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.getactive.service; | ||
|
|
||
| import com.getactive.model.Activity; | ||
| import com.getactive.repository.ActivityRepository; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| public class ActivityService { | ||
| private final ActivityRepository repository; | ||
|
|
||
| public ActivityService(ActivityRepository repository) { | ||
| this.repository = repository; | ||
| } | ||
|
|
||
| public List<Activity> getAll() { | ||
| return repository.findAll(); | ||
| } | ||
|
|
||
| public Activity create(Activity activity) { | ||
| return repository.save(activity); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| const ActivityCard = ({ activity }) => ( | ||
| <div className="border p-3 my-2"> | ||
| <h2>{activity.title}</h2> | ||
| <p>{new Date(activity.datetime).toLocaleString()}</p> | ||
| <p>{activity.location}</p> | ||
| </div> | ||
| ); | ||
|
|
||
| export default ActivityCard; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import React, { useState } from 'react'; | ||
| import { createActivity } from '../services/api'; | ||
|
|
||
| const CreateActivityPage = () => { | ||
| const [form, setForm] = useState({ title: '', datetime: '', location: '' }); | ||
|
|
||
| const handleSubmit = async (e) => { | ||
| e.preventDefault(); | ||
| await createActivity(form); | ||
| alert('Activity created!'); | ||
| }; | ||
|
|
||
| return ( | ||
| <form onSubmit={handleSubmit}> | ||
| <input name="title" onChange={(e) => setForm({ ...form, title: e.target.value })} placeholder="Title" required /> | ||
| <input type="datetime-local" name="datetime" onChange={(e) => setForm({ ...form, datetime: e.target.value })} required /> | ||
| <input name="location" onChange={(e) => setForm({ ...form, location: e.target.value })} placeholder="Location" required /> | ||
| <button type="submit">Create</button> | ||
| </form> | ||
| ); | ||
| }; | ||
|
|
||
| export default CreateActivityPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import React, { useEffect, useState } from 'react'; | ||
| import ActivityCard from '../components/ActivityCard'; | ||
| import { fetchActivities } from '../services/api'; | ||
|
|
||
| const DiscoverPage = () => { | ||
| const [activities, setActivities] = useState([]); | ||
|
|
||
| useEffect(() => { | ||
| fetchActivities().then(setActivities); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div className="p-4"> | ||
| <h1>Discover Activities</h1> | ||
| <div> | ||
| {activities.map((activity) => ( | ||
| <ActivityCard key={activity.id} activity={activity} /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default DiscoverPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| const ActivityCard = ({ activity }) => ( | ||
| <div className="border p-3 my-2"> | ||
| <h2>{activity.title}</h2> | ||
| <p>{new Date(activity.datetime).toLocaleString()}</p> | ||
| <p>{activity.location}</p> | ||
| </div> | ||
| ); | ||
|
|
||
| export default ActivityCard; |
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need this zip file?