Skip to content

Commit

Permalink
Merge branch 'develop' into SMA-28-Implement-new-user-profile-registr…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
DeakCsaba0124 authored Feb 8, 2024
2 parents 18244eb + 5259f1e commit f9e28c4
Show file tree
Hide file tree
Showing 26 changed files with 362 additions and 74 deletions.
4 changes: 4 additions & 0 deletions backend/sportsmatch/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ out/

### VS Code ###
.vscode/

### h2 database ###
./sportsmatch
*.db
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public static void main(String[] args) {

@Override
public void run(String... args) throws Exception {
addData();
checkRecords();
}

private void checkRecords() {
List<User> users = userRepository.findAll();
if (users.isEmpty()) {
addData();
}
}

public void addData() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sportsmatch.controllers;

import com.sportsmatch.dtos.EventDTO;
import com.sportsmatch.dtos.EventHistoryDTO;
import com.sportsmatch.models.Event;
import com.sportsmatch.services.EventService;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -45,4 +46,11 @@ public ResponseEntity<?> getUpcomingEvents(@RequestBody List<Long> sportsIds) {
List<EventDTO> listOfEvents = eventService.getEventsBySports(sportsIds);
return ResponseEntity.ok().body(listOfEvents);
}

// todo this is placeholder for frontend - it doesn't do anything yet
@GetMapping("/event-history")
public EventHistoryDTO getEventsHistory() {
EventHistoryDTO eventHistoryDTO = new EventHistoryDTO();
return eventHistoryDTO;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.sportsmatch.dtos;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class EventHistoryDTO {

private Integer userScore;
private Integer opponentScore;
private UserDTO opponent;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sportsmatch.dtos;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class UserDTO {

private String name;
}
4 changes: 2 additions & 2 deletions backend/sportsmatch/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.url=jdbc:h2:file:./sportsmatch
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=true
spring.h2.console.enabled=true

spring.mvc.hiddenmethod.filter.enabled=true

jwt.secret=56e1a2c8b7a56f5c480cf0045186dbc514d9172e4fbbc81dd82f541384274c3c
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 38 additions & 30 deletions frontend/sportsmatch-app/src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
.App {
text-align: center;
}
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@700&display=swap');

.App-logo {
height: 40vmin;
pointer-events: none;
}
:root {
--sm-primary-font: 'Inter', sans-serif;
--sm-secondary-font: 'Manrope', sans-serif;

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
--sm-primary-bg: #f9f8f5;
--sm-orange: #e85f29;
--sm-dark: #4a494f;
--sm-white: #ffffff;
--sm-txt-dark: #393939;
--sm-secondary-orange: #fc4c02;
--sm-orange-overlay: rgba(232, 95, 41, 0.25);

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
--sm-border-shadow: 0px 0px 5px rgba(0, 0, 0, 0.05);
--sm-border-radius: 2px;

--sm-btn-size-regular: 3.125em;
--sm-btn-size-small: 1.875em;

--sm-h1-size: 3em;
--sm-h2-size: 1em;
--sm-text-size: 1em;
}

.App-link {
color: #61dafb;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Inter', sans-serif;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
svg {
color: var(--sm-white);
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: var(--sm-primary-bg);
background-size: cover;
background-position: center;
}
11 changes: 11 additions & 0 deletions frontend/sportsmatch-app/src/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '../styles/Avatar.css'

interface AvatarProps {
src: string
}

const Avatar: React.FC<AvatarProps> = ({ src }) => (
<div className="avatar" style={{ backgroundImage: `url(${src}` }}></div>
)

export default Avatar
48 changes: 48 additions & 0 deletions frontend/sportsmatch-app/src/components/EventHistoryItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { EventHistoryDTO } from '../generated/api'
import '../styles/EventHistoryItem.css'
import Avatar from './Avatar'

interface EventHistoryProps {
eventHistoryDTO: EventHistoryDTO
}

function EventHistoryItem({ eventHistoryDTO }: EventHistoryProps) {
return (
<>
<div className="container-sm">
<div className="event-history-item">
<div className="match-status">VICTORY (uncorfirmed)</div>
<div className="user-side">
<div className="profile">
<div className="user-avatar">
<Avatar src="pictures/michael-dam-mEZ3PoFGs_k-unsplash.jpg" />
</div>
<div className="user-name">You</div>
</div>
<div className="user-score score">
<span>{eventHistoryDTO.userScore}</span>
</div>
</div>
<div className="colon">
<span>:</span>
</div>
<div className="opponent-side">
<div className="opponent-score score">
<span>{eventHistoryDTO.opponentScore}</span>
</div>
<div className="profile">
<div className="opponent-avatar">
<Avatar src="pictures/jeffrey-keenan-pUhxoSapPFA-unsplash.jpg" />
</div>
<div className="opponent-name">
{eventHistoryDTO.opponent?.name}
</div>
</div>
</div>
</div>
</div>
</>
)
}

export default EventHistoryItem
5 changes: 5 additions & 0 deletions frontend/sportsmatch-app/src/generated/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ export type { OpenAPIConfig } from './core/OpenAPI';

export type { AuthRequestDTO } from './models/AuthRequestDTO';
export type { EventDTO } from './models/EventDTO';
export type { EventHistoryDTO } from './models/EventHistoryDTO';
export type { Pageable } from './models/Pageable';
export type { SportDTO } from './models/SportDTO';
export type { UserDTO } from './models/UserDTO';

export { EventsControllerService } from './services/EventsControllerService';
export { ExSecuredEndpointService } from './services/ExSecuredEndpointService';
export { LoginService } from './services/LoginService';
export { RegisterService } from './services/RegisterService';
export { SportControllerService } from './services/SportControllerService';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { UserDTO } from './UserDTO';
export type EventHistoryDTO = {
userScore?: number;
opponentScore?: number;
opponent?: UserDTO;
};

10 changes: 10 additions & 0 deletions frontend/sportsmatch-app/src/generated/api/models/Pageable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type Pageable = {
page?: number;
size?: number;
sort?: Array<string>;
};

8 changes: 8 additions & 0 deletions frontend/sportsmatch-app/src/generated/api/models/SportDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type SportDTO = {
name?: string;
};

8 changes: 8 additions & 0 deletions frontend/sportsmatch-app/src/generated/api/models/UserDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UserDTO = {
name?: string;
};

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* tslint:disable */
/* eslint-disable */
import type { EventDTO } from '../models/EventDTO';
import type { EventHistoryDTO } from '../models/EventHistoryDTO';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
Expand Down Expand Up @@ -70,4 +71,14 @@ export class EventsControllerService {
},
});
}
/**
* @returns EventHistoryDTO OK
* @throws ApiError
*/
public static getEventsHistory(): CancelablePromise<EventHistoryDTO> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/v1/event/event-history',
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Pageable } from '../models/Pageable';
import type { SportDTO } from '../models/SportDTO';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class SportControllerService {
/**
* @param pageable
* @returns SportDTO OK
* @throws ApiError
*/
public static getSports(
pageable: Pageable,
): CancelablePromise<Array<SportDTO>> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/v1/sports/all',
query: {
'pageable': pageable,
},
});
}
}
7 changes: 7 additions & 0 deletions frontend/sportsmatch-app/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Match from '../components/Match'
import SportEvent from '../components/SportEvent'
import EventHistoryItem from '../components/EventHistoryItem'

function Home() {
const sampleEvent = {
Expand All @@ -14,11 +15,17 @@ function Home() {
playerOne: 'johndoe87',
playerTwo: 'jess_ward',
}
const sampleHistoryDTO = {
userScore: 1,
opponentScore: 2,
opponent: { name: 'Opponent' },
}

return (
<>
<Match event={sampleEvent} />
<SportEvent event={sampleEvent} />
<EventHistoryItem eventHistoryDTO={sampleHistoryDTO} />
</>
)
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/sportsmatch-app/src/styles/Avatar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.avatar {
width: 100%;
height: 100%;
border: 2px solid #FC4C02;
border-radius: 50%;
background-size: cover;
background-position: center center;
object-fit: cover;
}
Loading

0 comments on commit f9e28c4

Please sign in to comment.