cleaned up everything, basically all comments and console.logs are gone
This commit is contained in:
@@ -8,17 +8,13 @@ import { FriendshipService } from './friendship.service';
|
||||
export class FriendshipController {
|
||||
constructor(private readonly friendshipService: FriendshipService) { }
|
||||
|
||||
|
||||
// new and improved finder of people
|
||||
// GET http://transcendance:8080/api/v2/network/myfriends
|
||||
@Get('myfriends')
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
findOne(@Query('username') otherUsername: string, @Req() req) {
|
||||
// console.log('GET myfriends')
|
||||
const user = req.user;
|
||||
if (otherUsername !== undefined) {
|
||||
// console.log('my friend: ' + otherUsername)
|
||||
return this.friendshipService.findOneRelationshipByUsername(otherUsername, user.username);
|
||||
}
|
||||
return this.friendshipService.findAllFriendships(user.id);
|
||||
@@ -30,10 +26,8 @@ export class FriendshipController {
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
create(@Body() createFriendshipDto: CreateFriendshipDto, @Req() req) {
|
||||
// console.log('friendship.service create')
|
||||
const user = req.user;
|
||||
if (user.username !== createFriendshipDto.receiverUsername) {
|
||||
// console.log('friendship.service create have a receiver name')
|
||||
return this.friendshipService.create(createFriendshipDto, user);
|
||||
}
|
||||
return new HttpException('You can\'t request a frienship to yourself', HttpStatus.BAD_REQUEST);
|
||||
@@ -72,7 +66,6 @@ export class FriendshipController {
|
||||
@UseGuards(TwoFactorGuard)
|
||||
remove(@Param('relationshipId') relationshipId: number, @Req() req) {
|
||||
const user : User = req.user;
|
||||
// console.log('deleting a friendship')
|
||||
return this.friendshipService.removeFriendship(relationshipId, user);
|
||||
}
|
||||
|
||||
@@ -99,8 +92,6 @@ export class FriendshipController {
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
findBlocked(@Query('relationshipId') relationshipId: number, @Req() req) {
|
||||
// console.log('friendship.controller fetching blocked users')
|
||||
// console.log(relationshipId)
|
||||
const user = req.user;
|
||||
if (Number.isNaN(relationshipId))
|
||||
return this.friendshipService.findAllBlockedFriends(user.id);
|
||||
|
||||
@@ -16,7 +16,6 @@ export class FriendshipService {
|
||||
private readonly userRepository: Repository<User>,
|
||||
) { }
|
||||
|
||||
//kinda useless but someone else might use it
|
||||
async findOneRelationshipById(friendId : number, userId : number) {
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
@@ -39,12 +38,8 @@ export class FriendshipService {
|
||||
)
|
||||
}),
|
||||
)
|
||||
// .andWhere('friendship.status != :status', {status : FriendshipStatus.BLOCKED})
|
||||
.getOne()
|
||||
|
||||
// console.log('END Find one friend by ID: ')
|
||||
// console.log({...friendship})
|
||||
|
||||
if (!friendship) {
|
||||
throw new HttpException(`There is no such friendship`, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -52,7 +47,6 @@ export class FriendshipService {
|
||||
}
|
||||
|
||||
async findOneRelationshipByUsername(friendUsername : string, username : string) {
|
||||
// This seems to work, finding friendships by username but checking the actual users not the friendship
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.leftJoinAndSelect('friendship.sender', 'sender')
|
||||
@@ -76,9 +70,6 @@ export class FriendshipService {
|
||||
)
|
||||
.getOne()
|
||||
|
||||
// console.log('END Find one friend by username: ')
|
||||
// console.log({...friendship})
|
||||
|
||||
if (!friendship) {
|
||||
throw new HttpException(`There is no such friendship`, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -100,8 +91,6 @@ export class FriendshipService {
|
||||
for (const friendship of friendships) {
|
||||
sendFrienships.push(new SendableFriendship(friendship));
|
||||
}
|
||||
// console.log('friendship.service my friends:')
|
||||
// console.log({...sendFrienships})
|
||||
return sendFrienships;
|
||||
}
|
||||
|
||||
@@ -142,16 +131,6 @@ export class FriendshipService {
|
||||
.where('sender.id = :requestee', { requestee: userId })
|
||||
.andWhere('friendship.status = :status', { status: FriendshipStatus.BLOCKED })
|
||||
.getMany();
|
||||
|
||||
// let partialFriendship : Partial<Friendship>[] = [];
|
||||
// for (const friendship of friendships) {
|
||||
// partialFriendship.push({id: friendship.id, date: friendship.date, senderUsername: friendship.senderUsername, receiverUsername: friendship.receiverUsername, status: friendship.status});
|
||||
// }
|
||||
// console.log('friendship.service findAllBlockedFriends, friendships:')
|
||||
// console.log({...friendships})
|
||||
// console.log('friendship.service findAllBlockedFriends, partial friendship:')
|
||||
// return partialFriendship;
|
||||
|
||||
let sendFrienships: SendableFriendship[] = []
|
||||
for (const friendship of friendships) {
|
||||
sendFrienships.push(new SendableFriendship(friendship));
|
||||
@@ -167,10 +146,6 @@ export class FriendshipService {
|
||||
.where('sender.id = :requestee', { requestee: userId })
|
||||
.andWhere('friendship.status = :status', { status: FriendshipStatus.REQUESTED })
|
||||
.getMany();
|
||||
|
||||
// console.log('friendships services pendant friendships:')
|
||||
// console.log({...friendships})
|
||||
|
||||
let sendFrienships: SendableFriendship[] = []
|
||||
for (const friendship of friendships) {
|
||||
sendFrienships.push(new SendableFriendship(friendship));
|
||||
@@ -186,10 +161,6 @@ export class FriendshipService {
|
||||
.where('receiver.id = :addressee', { addressee: userId })
|
||||
.andWhere('friendship.status = :status', { status: FriendshipStatus.REQUESTED })
|
||||
.getMany();
|
||||
|
||||
// console.log('friendship service received requests')
|
||||
// console.log({...friendships})
|
||||
|
||||
let sendFrienships: SendableFriendship[] = []
|
||||
for (const friendship of friendships) {
|
||||
sendFrienships.push(new SendableFriendship(friendship));
|
||||
@@ -198,15 +169,11 @@ export class FriendshipService {
|
||||
}
|
||||
|
||||
async create(createFriendshipDto: CreateFriendshipDto, creator : User) {
|
||||
// console.log("DTO : \n")
|
||||
// console.log({...createFriendshipDto})
|
||||
|
||||
const receiver = await this.userRepository.findOneBy({username: createFriendshipDto.receiverUsername});
|
||||
if (!receiver)
|
||||
throw new HttpException(`The addressee does not exist.`, HttpStatus.NOT_FOUND);
|
||||
if (createFriendshipDto.status !== FriendshipStatus.REQUESTED && createFriendshipDto.status !== FriendshipStatus.BLOCKED)
|
||||
throw new HttpException(`The status is not valid.`, HttpStatus.NOT_FOUND);
|
||||
|
||||
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
@@ -218,21 +185,13 @@ export class FriendshipService {
|
||||
.andWhere('receiver.id = :receiverId2', {receiverId2: creator.id})
|
||||
.getOne();
|
||||
|
||||
// console.log('friendship.service create, friendship: \n\n\n')
|
||||
// console.log({...friendship})
|
||||
|
||||
if (friendship) {
|
||||
// console.log('there is already a friend request')
|
||||
|
||||
if (friendship.status && friendship.status === FriendshipStatus.ACCEPTED)
|
||||
throw new HttpException(`The friendship request has already been accepted.`, HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === FriendshipStatus.REQUESTED) {
|
||||
if (friendship && friendship.sender && friendship.sender.id === creator.id) {
|
||||
throw new HttpException(`The friendship request has already been sent the ${friendship.date}.`, HttpStatus.OK);
|
||||
} else {
|
||||
|
||||
// console.log('the friend request is being updated to Accepted')
|
||||
|
||||
friendship.status = FriendshipStatus.ACCEPTED;
|
||||
const saveAFriendship = await this.friendshipRepository.save(friendship);
|
||||
return new SendableFriendship(saveAFriendship);
|
||||
@@ -242,7 +201,6 @@ export class FriendshipService {
|
||||
else if (friendship.status && friendship.status === FriendshipStatus.DECLINED)
|
||||
throw new HttpException(`The request has been declined.`, HttpStatus.OK);
|
||||
}
|
||||
// console.log('friendship.service create, we are still saving a new friendship')
|
||||
|
||||
const newFriendship = new Friendship();
|
||||
newFriendship.sender = creator;
|
||||
@@ -259,10 +217,6 @@ export class FriendshipService {
|
||||
.leftJoinAndSelect('friendship.receiver', 'receiver')
|
||||
.where('friendship.id = :friendshipId', { friendshipId: relationshipId })
|
||||
.getOne();
|
||||
|
||||
// console.log('.service accept friendship')
|
||||
// console.log({...relation})
|
||||
|
||||
if (!relation)
|
||||
throw new HttpException(`The requested relationship not found.`, HttpStatus.NOT_FOUND);
|
||||
if (relation.sender.id === user.id) {
|
||||
@@ -304,8 +258,6 @@ export class FriendshipService {
|
||||
|
||||
// in the case where you RECEIVED the friendship but now want to block that person
|
||||
if (relation.receiver && relation.receiver.id === user.id) {
|
||||
// console.log('friendship.service blockFriendship trying to delete and recreate a friendship with block')
|
||||
// console.log({...relation})
|
||||
const newFriendshipDto = {"receiverUsername": relation.sender.username, "status": FriendshipStatus.BLOCKED};
|
||||
await this.removeFriendship(relationshipId, user);
|
||||
return await this.create(newFriendshipDto, user);
|
||||
@@ -328,17 +280,10 @@ export class FriendshipService {
|
||||
if (friendship.sender.id !== user.id && friendship.receiver.id !== user.id) {
|
||||
throw new HttpException(`You can't do that.`, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
// console.log('.service deleted a friendship')
|
||||
|
||||
return this.friendshipRepository.remove(friendship);
|
||||
}
|
||||
|
||||
async findIfUserIsBlockedOrHasBlocked(userConnectedId: number, userToFindId: number) {
|
||||
// console.log("finding if user is blocked")
|
||||
// console.log('user connected: ' + userConnectedId)
|
||||
// console.log('user to find: ' + userToFindId)
|
||||
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.leftJoinAndSelect('friendship.sender', 'sender')
|
||||
@@ -362,17 +307,11 @@ export class FriendshipService {
|
||||
.andWhere('friendship.status = :status', {status : FriendshipStatus.BLOCKED})
|
||||
.getOne()
|
||||
|
||||
|
||||
// console.log('printing friendship queried')
|
||||
// console.log({...friendship})
|
||||
|
||||
if (friendship) {
|
||||
console.log('we are blocked in friendship.service')
|
||||
return true;
|
||||
}
|
||||
|
||||
// console.log('we are not blocked in friendship service')
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
|
||||
import { Friendship, FriendshipStatus } from "./entities/friendship.entity";
|
||||
|
||||
|
||||
// Ok i don't really know what i'm doing but i want a thing that is typeset that i can use to send info back to the Front when they create a friendship or ask for a friendship
|
||||
// Ok it doesn't seem like i really need an interface, that just enfoces the types
|
||||
|
||||
// export interface SendableFriendship {
|
||||
export class SendableFriendship {
|
||||
id: number;
|
||||
date: Date;
|
||||
@@ -13,7 +8,6 @@ export class SendableFriendship {
|
||||
receiverUsername: string;
|
||||
status: FriendshipStatus;
|
||||
|
||||
// if my constructor is here won't it get sent all over the place too?
|
||||
constructor(friendship: Friendship) {
|
||||
this.id = friendship.id;
|
||||
this.date = friendship.date
|
||||
|
||||
@@ -8,7 +8,6 @@ export class SendableUser {
|
||||
status: string;
|
||||
stats: UserStats;
|
||||
|
||||
// if my constructor is here won't it get sent all over the place too?
|
||||
constructor(user: User) {
|
||||
this.username = user.username;
|
||||
this.image_url = user.image_url;
|
||||
|
||||
@@ -4,11 +4,9 @@ import { User } from './entities/user.entity';
|
||||
import { Repository, Not } from 'typeorm';
|
||||
import { CreateUsersDto } from './dto/create-users.dto';
|
||||
import { UpdateUsersDto } from './dto/update-users.dto';
|
||||
import { PaginationQueryDto } from 'src/common/dto/pagination-query.dto';
|
||||
import { UserStats } from './entities/userStat.entities';
|
||||
import { FriendshipService } from 'src/friendship/friendship.service';
|
||||
// On va devoir sûrement trouver un moyen plus simple pour passer l'id, sûrement via des pipes
|
||||
// ou des interceptors, mais pour l'instant on va faire comme ça.
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
|
||||
@@ -22,16 +20,12 @@ export class UsersService {
|
||||
const user = await this.userRepository.findOneBy({fortyTwoId: fortytwo_id});
|
||||
if (!user)
|
||||
{
|
||||
// console.log(`The requested user not found.`);
|
||||
return null;
|
||||
}
|
||||
// console.log(`The requested user found.`);
|
||||
return user;
|
||||
}
|
||||
|
||||
async findOne(username: string) {
|
||||
// console.log(`FIND ONE USER SERVICE Find user ${username}`);
|
||||
|
||||
const user = await this.userRepository.createQueryBuilder('user')
|
||||
.leftJoinAndSelect('user.stats', 'stats')
|
||||
.where('user.username = :username', { username: username })
|
||||
@@ -39,8 +33,6 @@ export class UsersService {
|
||||
if (!user)
|
||||
throw new NotFoundException(`The requested user not found.`);
|
||||
|
||||
// console.log(`FIND ONE USER SERVICE The requested user found. ` + user.username + " " + user.stats.id + user.stats.winGame + user.stats.loseGame + user.stats.drawGame + user.stats.totalGame);
|
||||
|
||||
const partialUser : Partial<User> = {
|
||||
username: user.username,
|
||||
image_url: user.image_url,
|
||||
@@ -48,9 +40,6 @@ export class UsersService {
|
||||
status: user.status,
|
||||
stats: user.stats,
|
||||
};
|
||||
|
||||
// console.log(`Returned Partial User.` + partialUser.username + user.username);
|
||||
|
||||
return partialUser;
|
||||
}
|
||||
|
||||
@@ -69,26 +58,14 @@ export class UsersService {
|
||||
let partialUsers : Partial<User>[] = [];
|
||||
|
||||
for (const otherUser of otherUsers) {
|
||||
// console.log('other user: ')
|
||||
// console.log({...otherUser})
|
||||
// let tmp = await this.friendshipService.findIfUserIsBlockedOrHasBlocked(currentUser.id, otherUser.id);
|
||||
// console.log('user.services findIF Blocked... : ')
|
||||
// console.log(tmp)
|
||||
// if (tmp === false) {
|
||||
if (await this.friendshipService.findIfUserIsBlockedOrHasBlocked(currentUser.id, otherUser.id) === false) {
|
||||
partialUsers.push({username: otherUser.username, image_url: otherUser.image_url, status: otherUser.status, stats: otherUser.stats});
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('user.services findAll, partialUsers:')
|
||||
// console.log({...partialUsers})
|
||||
|
||||
return partialUsers;
|
||||
}
|
||||
|
||||
async create(createUserDto: CreateUsersDto) {
|
||||
// console.log('\nuser.services create a new user, createUserDto: ')
|
||||
// console.log({...createUserDto})
|
||||
if (await this.userRepository.findOneBy({fortyTwoId: createUserDto.fortyTwoId}))
|
||||
throw new HttpException(`The user already exists.`,HttpStatus.CONFLICT);
|
||||
const user = this.userRepository.create(createUserDto);
|
||||
@@ -101,7 +78,6 @@ export class UsersService {
|
||||
async update(id: number, updateUserDto: UpdateUsersDto, username : string) {
|
||||
console.log("Maj user username : " + username + " updateuser dto " + updateUserDto.username )
|
||||
if (await this.isUsernameExists(updateUserDto.username) === true && updateUserDto.username !== username) {
|
||||
// console.log('updating username ' + updateUserDto.username + ' but it already is in use')
|
||||
throw new HttpException(`The username is already in use.`,HttpStatus.CONFLICT);
|
||||
}
|
||||
const user = await this.userRepository.preload(
|
||||
@@ -143,15 +119,12 @@ export class UsersService {
|
||||
return this.userRepository.update(id, {image_url: avatar});
|
||||
}
|
||||
|
||||
// doing search with username not id because userService.findOne doesn't return an Id anymore, just username... fuck this architecture is big trash...
|
||||
async getAvatarUrl(username: string) {
|
||||
const user = await this.userRepository.findOneBy({username: username});
|
||||
if (!user)
|
||||
throw new HttpException(`The user could not be found.`,HttpStatus.NOT_FOUND);
|
||||
// console.log('user.service getAvatarUrl of ' + user.username)
|
||||
if (!user.image_url)
|
||||
throw new HttpException(`The user has no avatar.`,HttpStatus.NOT_FOUND);
|
||||
// console.log('User.service Avatar URL ' + user.image_url);
|
||||
return user.image_url;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { push } from "svelte-spa-router";
|
||||
|
||||
let qrCodeImg;
|
||||
@@ -57,21 +56,18 @@
|
||||
|
||||
</script>
|
||||
|
||||
<!-- ask Hugo but for Reactive page might want to put main in a div or something? -->
|
||||
<main>
|
||||
<h1>2FA Sign In</h1>
|
||||
<p>use google authenticator</p>
|
||||
{#await fetchQrCodeImg}
|
||||
<p>Please Wait...</p>
|
||||
{:then data}
|
||||
<!-- What the hell is data? ask Cherif -->
|
||||
<img src={qrCodeImg} alt="A QRCodeImg you must scan with google authenticator" id="qrcodeImg" />
|
||||
<form on:submit|preventDefault={submitCode}>
|
||||
<input id="code" bind:value={qrCode} type="text" placeholder="Input Code"/>
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
{#if wrongCode}
|
||||
<!-- shoudl i do this in the Net Ninja way? like it's "" until an error happens? -->
|
||||
<div class="error">
|
||||
{wrongCode}
|
||||
</div>
|
||||
@@ -83,18 +79,13 @@
|
||||
|
||||
<style>
|
||||
main {
|
||||
/* display: flex; */
|
||||
/* align-items: center; */
|
||||
text-align: center;
|
||||
padding-top: 40px;
|
||||
padding-bottom: 40px;
|
||||
/* max-width: 500px; */
|
||||
}
|
||||
|
||||
form {
|
||||
/* max-width: 330px; */
|
||||
padding-top: 15px;
|
||||
|
||||
}
|
||||
|
||||
form input {
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
</script>
|
||||
|
||||
<div class="background-pages">
|
||||
{#if oneUser}
|
||||
<GenerateUserDisplay user={oneUser}/>
|
||||
{:else}
|
||||
<h2>Sorry</h2>
|
||||
<div>Failed to load user {params.username}</div>
|
||||
{/if}
|
||||
|
||||
<!-- This is where i might toss in an Invite to Game button ? -->
|
||||
|
||||
{#if oneUser}
|
||||
<GenerateUserDisplay user={oneUser}/>
|
||||
{:else}
|
||||
<h2>Sorry</h2>
|
||||
<div>Failed to load user {params.username}</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
let avatar, newAvatar;
|
||||
let uploadAvatarSuccess = false;
|
||||
|
||||
// tbh i might not need this...
|
||||
let set = { username: '', tfa: false };
|
||||
let nameTmp; // annoying...
|
||||
let nameTmp;
|
||||
const errors = { username: '', checkbox: '', avatar: ''};
|
||||
let success = {username: '', avatar: '' };
|
||||
|
||||
@@ -24,7 +23,6 @@
|
||||
if (!user) {
|
||||
console.log('User did not load, something more official should prolly happen')
|
||||
}
|
||||
// i don't unerstand why this is necessary but it really doesn't like it otherwise
|
||||
nameTmp = user.username;
|
||||
|
||||
set.tfa = user.isEnabledTwoFactorAuth;
|
||||
@@ -82,8 +80,6 @@
|
||||
const data = new FormData();
|
||||
data.append("file", newAvatar[0]);
|
||||
|
||||
// tmp
|
||||
console.log(data);
|
||||
|
||||
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user/avatar`,
|
||||
{
|
||||
@@ -136,8 +132,6 @@
|
||||
<form on:submit|preventDefault={settingsHandler}>
|
||||
<div class="form-field">
|
||||
<div class="label">New Username</div>
|
||||
<!-- it really hates {user.username} and ${user.username} -->
|
||||
<!-- <input type="text" placeholder="current username: ${user.username}" bind:value={set.username}> -->
|
||||
<input type="text" placeholder="{nameTmp}" bind:value={set.username}>
|
||||
<div class="success">{success.username}</div>
|
||||
<div class="error">{errors.username}</div>
|
||||
@@ -152,18 +146,15 @@
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<!-- ok so it can't actually show us the file we upload until we've uploaded it... -->
|
||||
{#if avatar}
|
||||
<img class="avatar" src={avatar} alt="your avatar"/>
|
||||
{/if}
|
||||
<form on:submit|preventDefault={uploadAvatar}>
|
||||
<!-- not convinced this has any utility. -->
|
||||
<!-- <input type="text" bind:value={postVar} placeholder={"choose your file"}/> -->
|
||||
<div class="form-field">
|
||||
<div class="label">Pick a new Avatar</div>
|
||||
<input type="file" bind:files={newAvatar}/>
|
||||
<div class="error">{errors.avatar}</div>
|
||||
<div class="success">{success.avatar}</div>
|
||||
<div class="success">{success.avatar}</div>
|
||||
</div>
|
||||
<Button type={!newAvatar ? "primary" : "secondary"}>Upload Avatar</Button>
|
||||
</form>
|
||||
@@ -174,38 +165,23 @@
|
||||
</main>
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
main {
|
||||
text-align: center;
|
||||
/* display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 20px; */
|
||||
}
|
||||
|
||||
|
||||
|
||||
div.cards{
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 20px;
|
||||
/* text-align: center; */
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
img {
|
||||
/* we want the image to display as the same size no matter the resolution */
|
||||
/* max-width: fit-content; */
|
||||
/* max-width: 100px; */
|
||||
width: 60px;
|
||||
/* ok this works but i'm guessing i'll need to add some @media ... */
|
||||
/* padding: 10px; */
|
||||
/* this doesn't work either when nothing loads and it's just the words... don't love that */
|
||||
}
|
||||
|
||||
form {
|
||||
/* max-width: 500px; */
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -223,7 +199,6 @@
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
.error{
|
||||
font-size: 1vw;
|
||||
font-weight: bold;
|
||||
|
||||
@@ -496,18 +496,12 @@
|
||||
.box {
|
||||
--width: 70vw;
|
||||
--height: 60vh;
|
||||
/* --height: auto; */
|
||||
position: absolute;
|
||||
width: var(--width);
|
||||
/* width: auto; */
|
||||
/* height: var(--height); */
|
||||
height: auto;
|
||||
left: calc(50% - var(--width) / 2);
|
||||
/* left: 0px; */
|
||||
top: calc(50% - var(--height) / 2);
|
||||
/* top: 0px; */
|
||||
/* top: calc(50% - ); */
|
||||
/* display: flex; */
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
border: 2px solid white;
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 6px;
|
||||
/* this softens the corners */
|
||||
|
||||
box-shadow: 0px 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
</style>
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
export let user;
|
||||
let rank = '';
|
||||
let avatar;
|
||||
|
||||
if (user.stats.loseGame > user.stats.winGame) {
|
||||
rank = "Come on, you can do better"
|
||||
@@ -47,13 +46,11 @@
|
||||
<div class="outer">
|
||||
{#if user}
|
||||
<main>
|
||||
<!-- <img class="avatar" src="{avatar}" alt="user avatar"> -->
|
||||
{#await fetchAvatar(user.username) then avatar}
|
||||
<img class="avatar" src="{avatar}" alt="user avatar">
|
||||
{:catch error}
|
||||
<p class="errorA">Avatar was unable to load</p>
|
||||
{/await}
|
||||
<!-- <div class="error">{errors.avatar}</div> -->
|
||||
<div class="username">{user.username}</div>
|
||||
<div class="rank">Rank:
|
||||
<span class="glitter">
|
||||
@@ -102,11 +99,8 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Normal CSS stuff */
|
||||
.avatar{
|
||||
max-width: 150px;
|
||||
/* width: 1em; */
|
||||
/* padding: 5px; */
|
||||
}
|
||||
|
||||
/* The variable rich section */
|
||||
@@ -114,10 +108,8 @@
|
||||
max-width: 600px;
|
||||
margin: 40px auto;
|
||||
text-align: center;
|
||||
/* i think i want to use a grid? */
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
/* not sure about this, maybe top should be larger? */
|
||||
grid-template-rows: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@@ -139,12 +131,6 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.error{
|
||||
font-size: 1vw;
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.errorA{
|
||||
font-size: 0.5em;
|
||||
font-weight: bold;
|
||||
@@ -173,8 +159,6 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Glittery Star Stuff */
|
||||
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
import { push } from "svelte-spa-router";
|
||||
import { location } from 'svelte-spa-router';
|
||||
|
||||
|
||||
// no need, it's just for links
|
||||
import active from 'svelte-spa-router/active'
|
||||
// or i could leave them all and not display if they're active?
|
||||
|
||||
$: current = $location;
|
||||
|
||||
let handleClickLogout = async () =>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
.tab.big{
|
||||
margin-bottom: 50px;
|
||||
/* guessing at size */
|
||||
}
|
||||
.tab.medium{
|
||||
margin-bottom: 40px;
|
||||
@@ -32,7 +31,6 @@
|
||||
}
|
||||
.tab.small{
|
||||
margin-bottom: 10px;
|
||||
/* need it small */
|
||||
}
|
||||
ul{
|
||||
display: flex;
|
||||
@@ -41,15 +39,12 @@
|
||||
list-style-type: none;
|
||||
}
|
||||
li{
|
||||
/* margin: 0 16px; */
|
||||
/* font-size: 18px; */
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
}
|
||||
li.big{
|
||||
margin: 0 20px;
|
||||
font-size: 22px;
|
||||
/* guessing at size */
|
||||
}
|
||||
li.medium{
|
||||
margin: 0 16px;
|
||||
@@ -59,7 +54,6 @@
|
||||
li.small{
|
||||
margin: 8px;
|
||||
font-size: 10px;
|
||||
/* need it small */
|
||||
}
|
||||
|
||||
.active{
|
||||
@@ -79,7 +73,6 @@
|
||||
li.default{
|
||||
margin: 0 16px;
|
||||
font-size: 18px;
|
||||
/* the OG size */
|
||||
}
|
||||
|
||||
@media screen and (max-width: 700px) {
|
||||
@@ -93,5 +86,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -6,7 +6,6 @@ export async function fetchAvatar(username?: string)
|
||||
url += `?username=${username}`;
|
||||
}
|
||||
|
||||
// throw new Error("HTTP ")
|
||||
return fetch(url)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -12,11 +12,9 @@ import { fetchUser } from "../pieces/utils";
|
||||
async function checkLogin(detail) {
|
||||
const user = await fetchUser();
|
||||
if (!user || !user.username) {
|
||||
// console.log('failed to be logged in')
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// console.log('successfully logged in')
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import ProfileSettings from '../pages/profile/ProfileSettings.svelte';
|
||||
import ProfileUsers from '../pages/profile/ProfileUsers.svelte';
|
||||
import ProfileDisplayOneUser from "../pages/profile/ProfileDisplayOneUser.svelte";
|
||||
|
||||
import DisplayAUser from '../pieces/DisplayAUser.svelte';
|
||||
|
||||
// establishing the prefix here very clearly so we can have a coherent repeatable structure
|
||||
export const prefix = '/profile';
|
||||
|
||||
@@ -15,6 +13,5 @@ export const profileRoutes = {
|
||||
'/settings': ProfileSettings,
|
||||
'/users': ProfileUsers,
|
||||
'/users/:username': ProfileDisplayOneUser,
|
||||
// '/users/:username': DisplayAUser,
|
||||
'*': NotFound
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user