all datas are displayed in react - still have to fix the css
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
18eda07d2c
commit
f550bd19f7
@ -0,0 +1,28 @@
|
||||
export interface TeamInfo{
|
||||
id: number
|
||||
name: string
|
||||
picture: string
|
||||
mainColor: Color
|
||||
secondColor: Color
|
||||
}
|
||||
|
||||
export interface Color{
|
||||
hex: string
|
||||
}
|
||||
|
||||
export interface Team {
|
||||
info: TeamInfo
|
||||
members: Member[]
|
||||
}
|
||||
|
||||
export interface Member{
|
||||
user: User
|
||||
role: string
|
||||
}
|
||||
|
||||
export interface User{
|
||||
id: number
|
||||
name: string
|
||||
email: string
|
||||
profilePicture: string
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
body {
|
||||
background-color: #f1f1f1;
|
||||
background-color: var(--background-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace IQBall\Core\Data;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Enumeration class workaround
|
||||
* As there is no enumerations in php 7.4, this class
|
||||
* encapsulates an integer value and use it as a variant discriminant
|
||||
*/
|
||||
final class MemberRole {
|
||||
private const ROLE_PLAYER = 0;
|
||||
private const ROLE_COACH = 1;
|
||||
private const MIN = self::ROLE_PLAYER;
|
||||
private const MAX = self::ROLE_COACH;
|
||||
|
||||
private int $value;
|
||||
|
||||
private function __construct(int $val) {
|
||||
if (!$this->isValid($val)) {
|
||||
throw new InvalidArgumentException("Valeur du rôle invalide");
|
||||
}
|
||||
$this->value = $val;
|
||||
}
|
||||
|
||||
public static function player(): MemberRole {
|
||||
return new MemberRole(MemberRole::ROLE_PLAYER);
|
||||
}
|
||||
|
||||
public static function coach(): MemberRole {
|
||||
return new MemberRole(MemberRole::ROLE_COACH);
|
||||
}
|
||||
|
||||
public function name(): string {
|
||||
switch ($this->value) {
|
||||
case self::ROLE_COACH:
|
||||
return "COACH";
|
||||
case self::ROLE_PLAYER:
|
||||
return "PLAYER";
|
||||
}
|
||||
die("unreachable");
|
||||
}
|
||||
|
||||
public static function fromName(string $name): ?MemberRole {
|
||||
switch ($name) {
|
||||
case "COACH":
|
||||
return MemberRole::coach();
|
||||
case "PLAYER":
|
||||
return MemberRole::player();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function isValid(int $val): bool {
|
||||
return ($val <= self::MAX and $val >= self::MIN);
|
||||
}
|
||||
|
||||
public function isPlayer(): bool {
|
||||
return ($this->value == self::ROLE_PLAYER);
|
||||
}
|
||||
|
||||
public function isCoach(): bool {
|
||||
return ($this->value == self::ROLE_COACH);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace IQBall\Core\Data;
|
||||
|
||||
use _PHPStan_4c4f22f13\Nette\Utils\Json;
|
||||
|
||||
class User implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* @var string $email user's mail address
|
||||
*/
|
||||
private string $email;
|
||||
|
||||
/**
|
||||
* @var string the user's username
|
||||
*/
|
||||
private string $name;
|
||||
|
||||
/**
|
||||
* @var int the user's id
|
||||
*/
|
||||
private int $id;
|
||||
|
||||
/**
|
||||
* @var string user's profile picture
|
||||
*/
|
||||
private string $profilePicture;
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @param string $name
|
||||
* @param int $id
|
||||
* @param string $profilePicture
|
||||
*/
|
||||
public function __construct(string $email, string $name, int $id, string $profilePicture) {
|
||||
$this->email = $email;
|
||||
$this->name = $name;
|
||||
$this->id = $id;
|
||||
$this->profilePicture = $profilePicture;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProfilePicture(): string {
|
||||
return $this->profilePicture;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue