Skip to content

Commit

Permalink
Merge branch 'main' into landing-version-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddobby94 committed Apr 3, 2024
2 parents 4bfb03e + 410f8d0 commit ba4916a
Show file tree
Hide file tree
Showing 16 changed files with 5,705 additions and 5,153 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Make mentors code owners of the entire repo, so we can distinguish between
# mentor and student reviews on github.
* @HackYourFuture-CPH/final-project-mentors
* @HackYourFuture-CPH/team26-group2-reviewers
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can either choose to install the project using a Docker container that comes
7. Run this command to build a database with Docker: `docker compose up -d`. The database will be built based on the values in `.env`.
8. Run `yarn db:setup` to run example migrations and seeds.
9. Run `yarn dev` to start the server in development mode.
10. Navigate to http://localhost:5001/api/exampleResources to verify that the API works and you can read data from the database.
10. Navigate to http://localhost:5001/api/teams to verify that the API works and you can read data from the database.

### Or without Docker

Expand All @@ -25,7 +25,7 @@ You can either choose to install the project using a Docker container that comes
4. Update the credentials in the newly created `.env` and make sure everything matches with the credentials for the database you set up in step (1).
5. Run `yarn db:setup` to run example migrations and seeds.
6. Run `yarn dev` to start the server in development mode.
7. Navigate to http://localhost:5001/api/exampleResources to verify that the API works and you can read data from the database.
7. Navigate to http://localhost:5001/api/teams to verify that the API works and you can read data from the database.

## Yarn commands

Expand Down
11 changes: 0 additions & 11 deletions packages/client/.env.example

This file was deleted.

6 changes: 6 additions & 0 deletions packages/client/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
"react/state-in-constructor": "off",
"react/jsx-props-no-spreading": "off",
"react/function-component-definition": "off"
// "import/no-extraneous-dependencies" : [
// "error",
// {
// "dev dependencies": true
// }
// ]
},
"overrides": [
{
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import './App.css';

import LandingPageContainer from './containers/LandingPage/LandingPage.Container';
import { PageNotFound } from './containers/PageNotFound/PageNotFound.Container';

Expand Down
13 changes: 13 additions & 0 deletions packages/client/src/component/Login.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Typography } from '@mui/material';
import React from 'react';

const Login = () => {
return (
<div>
<Typography variant="h1">H1 Heading</Typography>
<Typography variant="h6">H6 Heading</Typography>
</div>
);
};

export default Login;
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
/* TODO: This is an example controller to illustrate a server side controller.
Can be deleted as soon as the first real controller is added. */
/* eslint-disable no-console */

const knex = require('../../config/db');
const HttpError = require('../lib/utils/http-error');
const moment = require('moment-timezone');

const getExampleResources = async () => {
return knex('exampleResources').select(
'exampleResources.id',
'exampleResources.title',
);
const getAllTeams = async () => {
return knex('Teams').select('*');
};
const isValidTeamCode = async (teamCode) => {
try {
const team = await knex('Teams').where({ team_code: teamCode }).first();
return !!team;
} catch (error) {
console.error('Error checking team code:', error);
return false;
}
};

const getteams = async () => {
return knex('teams').select('teams.id', 'teams.title');
};

const getExampleResourceById = async (id) => {
Expand All @@ -18,18 +29,20 @@ const getExampleResourceById = async (id) => {
}

try {
const exampleResources = await knex('exampleResources')
.select('exampleResources.id as id', 'title')
const teams = await knex('teams')
.select('teams.id as id', 'title')
.where({ id });
if (exampleResources.length === 0) {
if (teams.length === 0) {
throw new Error(`incorrect entry with the id of ${id}`, 404);
}
return exampleResources;
return teams;
} catch (error) {
return error.message;
}
};

/// from the boiler plate template (will be used later)

const editExampleResource = async (
exampleResourceId,
updatedExampleResource,
Expand All @@ -38,18 +51,18 @@ const editExampleResource = async (
throw new HttpError('exampleResourceId should be a number', 400);
}

return knex('exampleResources').where({ id: exampleResourceId }).update({
return knex('teams').where({ id: exampleResourceId }).update({
title: updatedExampleResource.title,
updatedAt: moment().format(),
});
};

const deleteExampleResource = async (exampleResourceId) => {
return knex('exampleResources').where({ id: exampleResourceId }).del();
return knex('teams').where({ id: exampleResourceId }).del();
};

const createExampleResource = async (body) => {
await knex('exampleResources').insert({
await knex('teams').insert({
title: body.title,
});

Expand All @@ -59,9 +72,11 @@ const createExampleResource = async (body) => {
};

module.exports = {
getExampleResources,
getteams,
getExampleResourceById,
deleteExampleResource,
createExampleResource,
editExampleResource,
getAllTeams,
isValidTeamCode,
};
176 changes: 0 additions & 176 deletions packages/server/api/routes/exampleResources.router.js

This file was deleted.

Loading

0 comments on commit ba4916a

Please sign in to comment.