Coder Social home page Coder Social logo

team-35-scofoot's Introduction

-CS 308 Team 35 - 202201

SCOFOOT

The project name is Scofoot and the URL for our project is https://scofoot.herokuapp.com/. For the football teams competing in the Turkish Super League, a player suggestion service will be established as part of the online app. The purpose of this service is to make football clubs more aware of players with high potential playing in lesser-known leagues.

Installation

First step is installing npm package manager to your device using this website.

Then you have to clone the repository to a directory.

git clone <repository> <directory>

After that, going into the directory with the following command.

cd <directory>

Then, open two terminals in your IDE.

For the first terminal, which will be for the frontend side, change its directory to client folder by typing cd client

For the second terminal, no change will be done and this will be used for the server side.

Enter the following command in two terminals to install the packages needed for this project using the package manager [npm] (https://www.npmjs.com).

npm install

After that, run the app in your local host by typing the command below for the client terminal

npm start 

After that, run the app in your local host by typing the command below for the server terminal

npm run start-dev 

After that, you will see "connected to db" on your screen.

The next step will be opening the browser and typing "localhost:'port number'", to interact with the project from the local host.

Reporting the Bugs and Offering Suggestion for Fixing

For small bug fixes, opening pull request will be sufficient while for major changes opening an issue is preferred. Besides, before reporting the bug, checking the "Known Bugs" section will be a good choice.

Known Bugs

1- Users favorite players are shown in the profile page of the user. The user can limit the results by choosing row per page limit and it's default value is 10. However, when it is changed a problem occurs to go to the next page.

Obtaining the Source Code

Cloneing the repository

To obtain the source code for the whole project you can

git clone <repo> <directory>

Such that all the files will be ready to be edited or observed. With that, all the directories and the files will be open for being edited and seen. However, it is important not to forget that the client and the server folders are seperated.

Folder Structure

  1. In the root file, there are two main folders which are client and server.

  2. Client folder includes the front-end part of the project. 2.1 The main files are located in the src folder, while minor items, such as images, are kept in the public folder. 2.2 The Src file is made up of mostly screens, reducers, constants, themes, actions, and components. 2.3 Each screen has its own folder in the Components folder. 2.3.1 There are components of the respective page in each folder in components.

  3. Server folder contains the back-end part of the project 3.1 We have three main folders named as Controllers, Models, Middleware and Routes 3.1.1 In the Routes folder, the Controllers that will be used with the given HTTP requests are defined. 3.1.2 The backbone of the backend is built by the Controllers folder, which implements backend functions to fetch and post data to the database. 3.1.3 The project's schemas, including the Players and User schemas, are located in the models folder. 3.1.4 Operations such as authentication for user login are located in the Middleware folder. 3.2 Index.js and package.json are located in the server folder as well in which we make the connection with the database in index.js and store the package versions in package.json .

How to Build the project

After cloneing the project with

git clone <repo> <directory>

go to the project directory and run

npm install --prefix client && npm run build --prefix client

Deploying the project to a remote server (Heroku)

Install Heroku

1 . Create an account on https://heroku.com. This should be pretty straight forward. 2 . Install the Heroku CLI on your computer:
https://devcenter.heroku.com/articles/heroku-cli. Check that you have the heroku-cli installed by checking the version number in your terminal:

heroku --version

3 . Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:

heroku login

Use your credentials from the earlier account creation.

Deploy the project

1 . Heroku will look for a startup-script, this is by default npm start so make sure you have that in your package.json (assuming your script is called app.js):

 "scripts": {
    "start" : "node app.js"
 }

2 . You also have to make changes to the port, you can't hardcode a dev-port. But you can reference herokus port without knowing it by a special variabel. So add the following to your code:

const port = process.env.PORT || 4000;

When you upload to Heroku it will use the environment-port but when you are developing it will use the port 4000. Then reference this port in your app:

app.listen(port);

3 . Then create a remote heroku project, kinda like creating a git repository on GitHub. This will create a project on Heroku with a random name. If you want to name your app you have to supply your own name like heroku create project-name. The command below will just create a random name:

heroku create

4 . Push your app to Heroku like pushing to GitHub expect for origin you have heroku (you will see a wall of code).

git push heroku main

5 . Visit your newly create app by opening it via heroku:

heroku open

If you are getting errors you can view the error logs by running this command:

heroku logs --tail

This might give you a hint on what's wrong.

team-35-scofoot's People

Contributors

bilgehancoskun avatar meliskudat avatar ruyadinmezel avatar gunduzarda avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

team-35-scofoot's Issues

As a user, I want to be able to see my favorite players in my profile page, so that I don't have to check for all users to find my favorite players.

Acceptance Criteria:

  • Favorite players of the user should be taken from the database and should be shown to the user in a table format such that first 10 players should be shown first and if the user clicks next the other parts should be shown.
  • Name, surname, and the club name of the players should be shown.
  • Users should be able to delete the player from their favorite lists by clicking the heart icon.
  • If the user clicks to delete the user, the page should be updated and the latest results should be shown.

About Me Section

In the profile page when user clicks on the edit icon on About Me section and saves it , the editing panel doesn’t close unless user clicks on edit icon.

Avatar Style Functions

/*
*

/*
*This function assigns a color to given string
*@param {string} a string to create color from
*@returns {color} a color in form of #xxxxx
*/
function stringToColor(string) {
let hash = 0;
let i;

for (i = 0; i < string.length; i += 1) {
  hash = string.charCodeAt(i) + ((hash << 5) - hash);
}

let color = "#";

for (i = 0; i < 3; i += 1) {
  const value = (hash >> (i * 8)) & 0xff;
  color += `00${value.toString(16)}`.slice(-2);
}

return color;

}

/*
*This function creates the style for an avatar with created color
*and first two letters of the name
*@param {string} a name
*@returns {sx: { bgcolor: stringToColor(name),},children:};} style for avatar
*/

function stringAvatar(name) {
var splittedName = name.split(" ");
return {
sx: {
bgcolor: stringToColor(name),
},
children:
splittedName.length >= 2
? ${name.split(" ")[0][0]}${name.split(" ")[1][0]}
: name[0],
};
}

As a user, I want to be able to add players to my favorite list and delete them if they already added so that I can seperate my favorite users from other users.

Acceptance Criteria:

  • The users should be able to add the player to their favorite list by clicking the empty heart icon.
  • If the users add the player to their favorite list, the button should be changed into a filled heart icon.
  • The users should be able to delete the player from their favorite list by clicking the filled heart icon.
  • If the users delete the player from their favorite list, the buttton should be changed into an empty icon.

As a user, I want to have a notification page in which I will be able to see the following requests so that I can approve or delete the requests.

Acceptance Criteria:

  • In the header, there should be a notification icon that navigates the users to a notification page if clicked.
  • In the notification page, user should be able see all the users that sent following request to them.
  • There should be two options for the user that are approving or declining the request. If any of them clicked, the user should be deleted from that following requests list.

Post Flow

Post Flow için gerekli düzenlemer yapıldı. Post Creation sayfasını bekliyor.

Favorite Players Demonstration in the Users Profile Page

Users favorite players are shown in the profile page of the user. The user can limit the results by choosing row per page limit and it's default value is 10. However, when it is changed a problem occurs to go to the next page.

As a user, I would like to have a search bar in the header that I can search for the other users so that I can be aware of the other users using Scofoot.

Acceptance Criteria:

  • Users should be able to enter letters to the search bar and this letter should be checked if it exists in the names of the users in the database.
  • In each time the user enters a new letter, the results should be updated accordingly.
  • Since there might be several results, while showing the results there should be scrolling option for users.

addToFavorites and register functions

/*
*

/**

  • This function sends a POST request to the server to add the player to the favorite player list of the user
  • @param {number} player_id any number
  • @param {number} user_id any mumber
  • @returns {Object} the user with the user_id with the updated favorite player list of that user.
    */

export const addToFavorites = (player_id , user_id) => async(dispatch, getState) => {
try{
const {data} = await axios.post("/api/users/addFavorites", {goalkeeper_id, user_id});
dispatch({ type: USER_LOGIN_SUCCESS, payload: data});

	localStorage.setItem("userInfo", JSON.stringify(data));
}
catch(error){

}

};

/**

  • This function sends a POST request to the server for a user to sign-up and updates the local storage with that user

  • @param {String} name any String

  • @param {String} surname any String

  • @param {String} email any String

  • @param {String} password any String

  • @returns {Object} the user that is registered to the system
    */
    export const register =
    (name, surname, email, password) => async (dispatch) => {
    try {
    dispatch({ type: USER_REGISTER_REQUEST });

     	const { data } = await axios.post("/api/users/signup", {
     		name,
     		surname,
     		email,
     		password,
     	});
    
     	dispatch({ type: USER_REGISTER_SUCCESS, payload: data });
    
     	dispatch({ type: USER_LOGIN_SUCCESS, payload: data });
    
     	localStorage.setItem("userInfo", JSON.stringify(data));
     } catch (error) {
     	dispatch({
     		type: USER_REGISTER_FAIL,
     		payload:
     			error.response && error.response.data.message
     				? error.response.data.message
     				: error.message,
     	});
     }
    

    };

As a user, I want to be able to send connection requests to the other users in Scofoot and see my request situation in the profile page of the other user.

Acceptance Criteria:

  • There should be a add icon button in the profile page of the searched user, and if clicked by the logged in user it should be changed to "request is already sent".
  • If the request is already approved by the other user, then the icon in the profile page should be changed to delete icon that allows users to unfollow the user even if already followed.
  • If the request is deleted by the user that is the request is sent to, then the icon should be changed to add icon allowing the user to send the request again.

As a user, I would like to have a designated secure area for me to store my observations/graphics I created about players for me to be able to go back and check my previous comparisons later on.

Accaptance Criteria:

As a user, when I make comparisons within players or visualize players statistics by filters in the interface of database where players are listed, I must be provided a button where I can store those graphs or comparison tables and I must be able to reach them from a button placed in my profile page that is only visible for me.

As a user, when I am registering to the system I need to be able to select what kind of user I am such as Football Player/User to reach the specific properties from 2 different profile types.

Acceptence Criteria
  • User should be able to select his/her user type while registring. If user selects Player, then s/he will see verification code text box and s/he needs to fill this verification code. This verification code should match in database and it can only be used once.
  • User registered as normal user, s/he should be able to switch his/her profile type from account settings. S/he still needs to enter verification code for this process.

As an admin, I would like to be able to decide which accounts will have an verified account status.

Acceptance Criteria:

-In admin's profile page, there will be an inbox icon button which
will lead the admin to "verification requests" page if clicked.

-Verification requests page will show all the incoming verification requests from
the users and admins will be able to approve or decline the requests.

-If admin approves or declines the request, then the request will be removed
from verification requests page.

As a user, I would like to send requests to get "verified account" status for other Scofoot users to see. I believe this would increase my connection within application.

Acceptence Criteria
  • In user's profile page, there will be a send request button. If clicked, the request of the user for verification will be sent to the inbox of admin and the button will be changed to a text stating that the request is already sent.

  • If the request is approved by admins, then in the profile page of the user , there will be a verified account icon showing that user's account is verified.

As a user, I need to be provided an interface where the player, team in the database is listed with their statistics on of the Scofoot application to have a easy access to the database..

Acceptence Criteria
  • In the players section, players should be listed and when we click those players we need to see detailed information about this team or if we click a football player, we need to see informations of this player.
  • Player data should be fetched partially whenever it is needed.
  • After user changes the page it should fetch new needed player data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.