Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c26bdfb
added comp and sections
ssofiejohansson May 1, 2025
f5b96b0
add form
ssofiejohansson May 1, 2025
aba6941
publish form
ssofiejohansson May 1, 2025
105c6ef
edit Post section
ssofiejohansson May 1, 2025
5fcdef6
Added textbox and likebutton styling to view-comp
oskarnordin May 1, 2025
a08a898
Post
ssofiejohansson May 1, 2025
0989853
Merge branch 'main' into Sofie
ssofiejohansson May 1, 2025
fab8659
Merge pull request #1 from ssofiejohansson/Sofie
ssofiejohansson May 1, 2025
3789073
test
ssofiejohansson May 1, 2025
3aae5f6
test
ssofiejohansson May 1, 2025
2f5140d
added container
ssofiejohansson May 1, 2025
12a43e4
Merge branch 'Sofie' of https://github.com/ssofiejohansson/js-project…
ssofiejohansson May 1, 2025
414c4fb
Merge pull request #2 from ssofiejohansson/Sofie
ssofiejohansson May 1, 2025
86c86d2
clean up
ssofiejohansson May 1, 2025
b95fdf4
edit of containers
ssofiejohansson May 1, 2025
2660047
edit view
ssofiejohansson May 1, 2025
b462e3f
test
ssofiejohansson May 1, 2025
63d5935
submit button
ssofiejohansson May 1, 2025
aa27821
removed components to make the posting more clear
ssofiejohansson May 2, 2025
90eba53
made a new container for each thought
ssofiejohansson May 2, 2025
09a92e8
like btn test
ssofiejohansson May 2, 2025
f9d5551
added timestamp
oskarnordin May 2, 2025
9b6007a
added like count
ssofiejohansson May 2, 2025
9c97ece
Merge pull request #3 from ssofiejohansson/sofie2
ssofiejohansson May 2, 2025
323ca69
Merge pull request #4 from ssofiejohansson/Ocke
oskarnordin May 2, 2025
8f683dd
Update README.md
ssofiejohansson May 3, 2025
cc26697
cleaned up code, styling of actions
ssofiejohansson May 3, 2025
9d7b888
created container
ssofiejohansson May 3, 2025
6844865
Update Post with character counter
oskarnordin May 4, 2025
daf2f73
Merge branch 'main' into Ocke
oskarnordin May 4, 2025
ec46a0a
Merge pull request #5 from ssofiejohansson/Ocke
oskarnordin May 4, 2025
e0e065b
fixed post error
ssofiejohansson May 5, 2025
c398e77
added character visual counter
oskarnordin May 5, 2025
70aaa0f
Merge branch 'main' of https://github.com/ssofiejohansson/js-project-…
oskarnordin May 5, 2025
d4bdfcf
bug fix
oskarnordin May 5, 2025
35a3111
bug
ssofiejohansson May 5, 2025
e12af57
updated push
oskarnordin May 5, 2025
4b85b53
styling edit
ssofiejohansson May 5, 2025
270f90a
minor styling changes
ssofiejohansson May 6, 2025
752424b
added Thoughts.jsx to clean up App.jsx
ssofiejohansson May 6, 2025
04ac491
Synk
oskarnordin May 6, 2025
9060d2b
added API call
oskarnordin May 6, 2025
44b8e70
fetch in view
oskarnordin May 7, 2025
d9ffd5d
Added post functionality and like functionality to API.
oskarnordin May 7, 2025
aa0bff1
added character counter back and added animation on submit
ssofiejohansson May 8, 2025
999d85b
Merge pull request #6 from ssofiejohansson/lollo
ssofiejohansson May 8, 2025
afecbf3
like button fix
ssofiejohansson May 8, 2025
8c767ce
adding fun guy animation
oskarnordin May 8, 2025
7208e8a
Update Thoughts.jsx
oskarnordin May 8, 2025
da09b9a
Merge pull request #7 from ssofiejohansson/Ocke
oskarnordin May 8, 2025
c576a4f
size down animation
ssofiejohansson May 9, 2025
1cf86a5
changed submit animation, edited on hover, cleaned up code
ssofiejohansson May 9, 2025
0b73348
Update README.md
ssofiejohansson May 11, 2025
39d6b62
added loadingstate, fixed position of the post animation
ssofiejohansson May 11, 2025
49cfccb
loading state etx
ssofiejohansson May 11, 2025
abebb7c
Merge pull request #8 from ssofiejohansson/lollo2
ssofiejohansson May 11, 2025
9d594a7
made changes from code review notes
ssofiejohansson May 20, 2025
18eca23
updated fetch url
ssofiejohansson May 26, 2025
d3012dd
update url
ssofiejohansson May 26, 2025
fbb31ab
Update thoughts
oskarnordin Jun 3, 2025
14f597b
Connect to backend
oskarnordin Jun 9, 2025
3ac2d23
Update README.md
ssofiejohansson Jun 10, 2025
b6ebc5e
update img
ssofiejohansson Jun 10, 2025
2127dc9
added browser routes
ssofiejohansson Jun 10, 2025
822a827
edit login
ssofiejohansson Jun 10, 2025
3c4ce88
update nav
ssofiejohansson Jun 11, 2025
e67d5aa
Login + Register connect to backend
oskarnordin Jun 11, 2025
e620219
Error message when username already used
oskarnordin Jun 11, 2025
738b85c
Fixade styling på register/login + navbar
oskarnordin Jun 11, 2025
4f4448c
nav
ssofiejohansson Jun 12, 2025
a003756
Merge branch 'main' of https://github.com/ssofiejohansson/js-project-…
ssofiejohansson Jun 12, 2025
c0e697f
Update port
oskarnordin Jun 12, 2025
8564426
changed port
ssofiejohansson Jun 12, 2025
0058679
Front update 12/6
oskarnordin Jun 12, 2025
dd2ee7d
Update
oskarnordin Jun 15, 2025
e7ceb7c
API URL implemented
oskarnordin Jun 15, 2025
825f7eb
Update README.md
oskarnordin Jun 15, 2025
8b52b19
fixed error to deploy
ssofiejohansson Jun 16, 2025
a4410f2
.env ignore
oskarnordin Jun 16, 2025
4ddcf4e
Merge branch 'main' of https://github.com/ssofiejohansson/js-project-…
oskarnordin Jun 16, 2025
3bcd6b3
changed API URL
oskarnordin Jun 16, 2025
8e836fa
changed from localhost
ssofiejohansson Jun 16, 2025
d0d2fb0
added redirects file
ssofiejohansson Jun 16, 2025
1274781
changed db URL
oskarnordin Jun 16, 2025
9791d4f
changed to import.meta
ssofiejohansson Jun 16, 2025
c938613
removed localhost
ssofiejohansson Jun 16, 2025
1314933
fixed like
ssofiejohansson Jun 16, 2025
421e948
reg error msg
ssofiejohansson Jun 16, 2025
a003429
removed MyLikes do to not working properly
ssofiejohansson Jun 16, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dist
dist-ssr
*.local
package-lock.json
.env

# Editor directories and files
.vscode/*
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Happy Thoughts

https://smilezone78.netlify.app/
19 changes: 13 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<!DOCTYPE html>
<html lang="en">


<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<link rel="icon" type="image/svg+xml" href="./heart.png" />
<html lang="en">
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Chewy&display=swap"
rel="stylesheet"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Happy Thoughts</title>
</head>

<body>
<div id="root"></div>
<script
type="module"
src="./src/main.jsx">
</script>
<script type="module" src="./src/main.jsx"></script>
</body>
</html>

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@lottiefiles/dotlottie-react": "^0.13.5",
"jwt-decode": "^4.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"react-router-dom": "^7.6.2",
"styled-components": "^6.1.17"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
Expand Down
1 change: 1 addition & 0 deletions public/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=https://js-project-happy-thoughts-backend-1.onrender.com
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added public/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

24 changes: 21 additions & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { Thoughts } from './Sections/Thoughts';
import { Home } from './Pages/Home';
import { Login } from './Pages/Login';
import { Register } from './Pages/Register';
import { Logout } from './Pages/Logout';
import './index.css';
// import { MyLikes } from './Pages/MyLikes';

export const App = () => {
return (
<h1>Happy Thoughts</h1>
)
}
<BrowserRouter>
<Routes>
<Route path='/' element={<Home />} />
<Route path='/thoughts' element={<Thoughts />} />
<Route path='/login' element={<Login />} />
<Route path='/logout' element={<Logout />} />
<Route path='/register' element={<Register />} />
{/* <Route path='/thoughts/likes' element={<MyLikes />} /> */}
</Routes>
</BrowserRouter>
);
};
56 changes: 56 additions & 0 deletions src/Pages/Home.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { Container } from '../Sections/Thoughts';
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
import { Bubble } from '../Sections/Components/Bubble';
import { Button } from '../Sections/Components/Button';
import { Title } from '../Sections/Post';

const ButtonContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 10px;
`;

export const DotLottieWrapper = styled.div`
display: none;
@media (min-width: 768px) {
display: block;
position: fixed;
bottom: 24px;
right: 24px;
z-index: 100;
}
`;

export const Home = () => {
return (
<Container>
<Title>✨ Welcome to Happy Thoughts ✨</Title>
<p>Trying to make the world a better place, one thought at a time.</p>
<ButtonContainer>
<Button as={Link} to='/login'>
Login
</Button>
<Button as={Link} to='/register'>
Sign up
</Button>
</ButtonContainer>

<DotLottieWrapper>
<Bubble>
Hi there! You have to be logged in to see our happy thoughts. Please{' '}
<Link to='/login'>login</Link> or <Link to='/register'>sign up</Link> ❤️
</Bubble>
<DotLottieReact
src='https://lottie.host/5a7cb486-522b-4467-b656-356bea2585ff/MH7Oyw6zWd.lottie'
loop
autoplay
style={{ maxWidth: '200px' }}
/>
</DotLottieWrapper>
</Container>
);
};
88 changes: 88 additions & 0 deletions src/Pages/Login.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { Title } from '../Sections/Post';
import { Container } from '../Sections/Thoughts';
import { useState } from 'react';
import {
FormWrapper,
Label,
Input,
ErrorMsg,
SubmitButton,
} from '../Sections/Components/Form';
import { useNavigate } from 'react-router-dom';
import { Link } from 'react-router-dom';


const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8081';

export const Login = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [message, setMessage] = useState('');
const [success, setSuccess] = useState(false);
const navigate = useNavigate();

const handleLogin = async (e) => {
e.preventDefault();
try {
const response = await fetch(`${API_URL}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
});

const data = await response.json();
if (data.success) {
setMessage(`Hi, ${username} 🐮 Let's post some happy thoughts!`);
setSuccess(true);
localStorage.setItem('accessToken', data.accessToken);
localStorage.setItem('userId', data.id);
navigate('/thoughts', {
state: {
loginMessage: `Hey ${username} 🐮 Let's post some happy thoughts!`,
},
});
} else {
setMessage(data.message || 'Login failed');
setSuccess(false);
}
} catch (err) {
setMessage('Something went wrong. Please try again.');
setSuccess(false);
}
};

return (
<>
<Container>
<Title>Login to Happy Thoughts</Title>
<p>
Don't have an account? Sign up <Link to='/register'>here</Link>.
</p>
<FormWrapper onSubmit={handleLogin}>
<Label>
Username:
<Input
value={username}
onChange={(e) => setUsername(e.target.value)}
autoComplete='username'
/>
</Label>
<Label>
Password:
<Input
type='password'
value={password}
onChange={(e) => setPassword(e.target.value)}
autoComplete='current-password'
/>
</Label>
<SubmitButton type='submit'>Log in</SubmitButton>
{message && !success && <ErrorMsg>{message}</ErrorMsg>}
</FormWrapper>
<p>
← Go back to <Link to='/'>home</Link>.
</p>
</Container>
</>
);
};
15 changes: 15 additions & 0 deletions src/Pages/Logout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

export const Logout = () => {
const navigate = useNavigate();

useEffect(() => {
// Remove the correct auth keys
localStorage.removeItem('accessToken');
localStorage.removeItem('userId');
navigate('/');
}, [navigate]);

return null;
};
69 changes: 69 additions & 0 deletions src/Pages/MyLikes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// import React, { useEffect, useState } from 'react';
// import { Container, SubHeading } from '../Sections/Thoughts';
// import { View } from '../Sections/View'; // <-- Use the shared View
// import { Button } from '../Sections/Components/Button';
// import { Link } from 'react-router-dom';
// import styled, { keyframes } from 'styled-components';
// import { ViewContainer, TextField } from '../Sections/View'; // Import the ViewContainer for styling

// // Spinner animation from Thoughts.jsx
// const Rotate = keyframes`
// 0% { transform: rotate(0deg); }
// 100% { transform: rotate(360deg); }
// `;

// const Hourglass = styled.div`
// font-size: 45px;
// animation: ${Rotate} 1.5s linear infinite;
// `;

// const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8081';

// export const MyLikes = () => {
// const [likedThoughts, setLikedThoughts] = useState([]);

// useEffect(() => {
// const accessToken = localStorage.getItem('accessToken');
// console.log('Access token:', accessToken);

// if (!accessToken) {
// console.error('No access token found');
// return;
// }

// fetch(`${API_URL}/thoughts/likes`, {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json',
// Authorization: `Bearer ${accessToken}`, // ✅ must be this format
// },
// })
// .then((res) => {
// if (!res.ok) {
// throw new Error('Network response was not ok');
// }
// return res.json();
// })
// .then((data) => {
// console.log('Liked thoughts:', data);
// setLikedThoughts(data);
// })
// .catch((err) => {
// console.error('Fetch error:', err);
// });
// }, []);

// return (
// <Container>
// <h2>My Liked Thoughts</h2>
// <Link to='/thoughts'>
// <Button style={{ marginBottom: '20px' }}>Go back</Button>
// </Link>
// {likedThoughts.map((thought) => (
// <ViewContainer key={thought._id}>
// <TextField>{thought.message}</TextField>
// </ViewContainer>
// ))}
// </Container>
// );
// };
Loading