Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
},
"plugins": ["react", "prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"react/react-in-jsx-scope": "off",
"react/prop-types": 0
},
Expand Down
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
interval: 'weekly'

- package-ecosystem: "github-actions"
- package-ecosystem: 'github-actions'
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": false,
"endOfLine": "lf"
"jsxBracketSameLine": false
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-promise": "^6.6.0",
"eslint-plugin-react": "^7.37.1",
"prettier": "^3.3.3"
"prettier": "^3.5.2"
}
}
7 changes: 2 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down
2 changes: 1 addition & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
grid-template-columns: 151px 2fr 1fr;
grid-template-rows: 96px auto;
background-color: #f0f5fa;
height: 100vh;
min-height: 100vh;
}

.ReactModal__Body--open,
Expand Down
61 changes: 37 additions & 24 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,56 @@
import './App.css';
import { Routes, Route } from 'react-router-dom';
import Dashboard from './pages/dashboard';
import CohortTeacher from './pages/cohortTeacher';
import Login from './pages/login';
import Register from './pages/register';
import Loading from './pages/loading';
import Verification from './pages/verification';
import { AuthProvider, ProtectedRoute } from './context/auth';
import { ModalProvider } from './context/modal';
import { UserProvider } from './context/user';
import Welcome from './pages/welcome';

const App = () => {
return (
<>
<AuthProvider>
<ModalProvider>
<Routes>
<Route path="login" element={<Login />} />
<Route path="register" element={<Register />} />
<Route path="loading" element={<Loading />} />
<Route path="verification" element={<Verification />} />
<UserProvider>
<ModalProvider>
<Routes>
<Route path="login" element={<Login />} />
<Route path="register" element={<Register />} />
<Route path="loading" element={<Loading />} />
<Route path="verification" element={<Verification />} />

<Route
index
element={
<ProtectedRoute>
<Dashboard />
</ProtectedRoute>
}
/>
<Route
path="welcome"
element={
<ProtectedRoute disabledNav={true}>
<Welcome />
</ProtectedRoute>
}
/>
</Routes>
</ModalProvider>
<Route
index
element={
<ProtectedRoute>
<Dashboard />
</ProtectedRoute>
}
/>
<Route
index
path="cohort"
element={
<ProtectedRoute>
<CohortTeacher />
</ProtectedRoute>
}
/>
<Route
path="welcome"
element={
<ProtectedRoute disabledNav={true}>
<Welcome />
</ProtectedRoute>
}
/>
</Routes>
</ModalProvider>
</UserProvider>
</AuthProvider>
</>
);
Expand Down
18 changes: 18 additions & 0 deletions src/assets/icons/clipboardIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable prettier/prettier */
import React from 'react';

const ClipboardIcon = () => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 33 36"
width="50"
height="56"
fill="currentColor"
>
<path d="M16 2H8C7.45 2 7 2.45 7 3V4H5C4.45 4 4 4.45 4 5V21C4 21.55 4.45 22 5 22H19C19.55 22 20 21.55 20 21V5C20 4.45 19.55 4 19 4H17V3C17 2.45 16.55 2 16 2zM9 4H15V3H9V4zM6 6H18V20H6V6z" />
</svg>
);
};

export default ClipboardIcon;
13 changes: 13 additions & 0 deletions src/assets/icons/fileIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable prettier/prettier */
const FileIcon = () => {
return (
<svg width="33" height="36" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2ZM13 9V3.5L18.5 9H13Z"
fill="#000046"
/>
</svg>
);
};

export default FileIcon;
18 changes: 18 additions & 0 deletions src/assets/icons/noteIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable prettier/prettier */
import React from 'react';

const NoteIcon = () => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 20"
width="45"
height="50"
fill="currentColor"
>
<path d="M3 3h18v18H3V3zm2 2v14h14V5H5zm2 3h10v2H7V8zm0 4h10v2H7v-2zm0 4h6v2H7v-2z" />
</svg>
);
};

export default NoteIcon;
23 changes: 20 additions & 3 deletions src/components/createPostModal/index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
import { useState } from 'react';
import { useState, useContext } from 'react';
import useModal from '../../hooks/useModal';
import ProfileCircle from '../profileCircle';
import { UserContext } from '../../context/user';
import { AuthContext } from '../../context/auth';
import { post } from '../../service/apiClient';
import './style.css';
import Button from '../button';

const CreatePostModal = () => {
// Use the useModal hook to get the closeModal function so we can close the modal on user interaction
const { closeModal } = useModal();
const auth = useContext(AuthContext);
const user = useContext(UserContext);

const [message, setMessage] = useState(null);
const [text, setText] = useState('');

const name = `${user.firstName} ${user.lastName}`;
const userInitials = name.match(/\b(\w)/g);

const onChange = (e) => {
setText(e.target.value);
};

const onSubmit = () => {
setMessage('Submit button was clicked! Closing modal in 2 seconds...');

post('posts', { text }, true, auth.token).then(() => {
setText('');
});

setTimeout(() => {
setMessage(null);
closeModal();
}, 2000);
};

if (!user) {
return <p>Loading...</p>;
}

return (
<>
<section className="create-post-user-details">
<div className="profile-icon">
<p>AJ</p>
<ProfileCircle initials={userInitials} />
</div>
<div className="post-user-name">
<p>Alex J</p>
<p>{`${user.firstName} ${user.lastName}`}</p>
</div>
</section>

Expand Down
28 changes: 23 additions & 5 deletions src/components/editPostModal/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
import { useState } from 'react';
import { useState, useContext } from 'react';
import useModal from '../../hooks/useModal';
import ProfileCircle from '../profileCircle';
import { UserContext } from '../../context/user';
import { AuthContext } from '../../context/auth';
import { patch } from '../../service/apiClient';
import './style.css';
import Button from '../button';

const EditPostModal = () => {
const EditPostModal = ({ postId }) => {
const { closeModal } = useModal();
const auth = useContext(AuthContext);
const user = useContext(UserContext);

const [message, setMessage] = useState(null);
const [text, setText] = useState('');

const name = `${user.firstName} ${user.lastName}`;
const userInitials = name.match(/\b(\w)/g);

const onChange = (e) => {
setText(e.target.value);
};

const onSubmit = () => {
setMessage('Submit button was clicked! Closing modal in 2 seconds...');

patch(`posts/${postId}`, { text }, true, auth.token).then(() => {
setText('');
});

setTimeout(() => {
setMessage(null);
closeModal();
}, 2000);
};

if (!user) {
return <p>Loading...</p>;
}

return (
<>
<section className="create-post-user-details">
<div className="profile-icon">
<p>AJ</p>
<ProfileCircle initials={userInitials} />
</div>
<div className="post-user-name">
<p>Alex J</p>
<p>{`${user.firstName} ${user.lastName}`}</p>
</div>
</section>

Expand All @@ -39,7 +57,7 @@ const EditPostModal = () => {
<section className="create-post-actions">
<Button
onClick={onSubmit}
text="Post"
text="Update Post"
classes={`${text.length ? 'blue' : 'offwhite'} width-full`}
disabled={!text.length}
/>
Expand Down
Loading