Skip to content
Open

Dev #31

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
e068d1c
feat: add .env example
Smachy24 Nov 5, 2024
4fc36f4
fix: delete env file
Smachy24 Nov 5, 2024
0b18b0e
:see_no_evil: .env in gitignore
mathiszerari Nov 5, 2024
108918a
Delete .env
Smachy24 Nov 5, 2024
7a4b9d7
feat : User Register
ValzM Nov 5, 2024
ac38da7
feat: User login
ValzM Nov 5, 2024
80ff350
feat : Add Login and Register to the router
ValzM Nov 5, 2024
ce6acf0
feat: send message to user
Smachy24 Nov 5, 2024
b6b78c8
feat: router guard for non auth user
ValzM Nov 5, 2024
28764f9
:sparkles: get friend requests & friendRequest interface
mathiszerari Nov 5, 2024
536811e
feat: load messages sent
Smachy24 Nov 5, 2024
6eae377
:mute: console log deleted
mathiszerari Nov 5, 2024
b160ebd
:art: rename objects
mathiszerari Nov 5, 2024
b6dabb0
✒️ write function doc
mathiszerari Nov 5, 2024
f6f17f7
:art: move the timeAgo function to the utils folder
mathiszerari Nov 5, 2024
bc80ef5
:art: friend request card in a component
mathiszerari Nov 5, 2024
c0b0697
chore : refactor user store
ValzM Nov 5, 2024
4dea249
:art: move the api call to a service
mathiszerari Nov 5, 2024
f4cf5d8
feat: store messages
Smachy24 Nov 5, 2024
373a63a
:sparkles: loader component created
mathiszerari Nov 5, 2024
b3d2999
:sparkles: loader condition added on friendrequestPage
mathiszerari Nov 5, 2024
de53d03
feat: error on get messages if bad id or if users not friends
Smachy24 Nov 5, 2024
c190003
feat: event new messages
Smachy24 Nov 5, 2024
8a6de30
feat: Router guards
ValzM Nov 5, 2024
9b5f1b7
refactor : Less repetitive code form register and login form
ValzM Nov 5, 2024
f83f571
feat : add auth service
ValzM Nov 5, 2024
1abcb88
feat : add userDto
ValzM Nov 5, 2024
309b236
feat : redirect user to home page after login or register
ValzM Nov 5, 2024
0d97626
feat : add logout button
ValzM Nov 5, 2024
e64c797
feat : add current user friend list
ValzM Nov 5, 2024
f41df97
:fire: better useEffect fn
mathiszerari Nov 6, 2024
a261e8d
:fire: remove comments
mathiszerari Nov 6, 2024
a0b414a
:art: new services folder name
mathiszerari Nov 6, 2024
7c0d82e
:fire: remove comments
mathiszerari Nov 6, 2024
2f433e4
:art: move loadFriendRequest
mathiszerari Nov 6, 2024
f9642e6
rename component and page files
mathiszerari Nov 6, 2024
815137b
rename some files
mathiszerari Nov 6, 2024
612d255
:fire: remove loop
mathiszerari Nov 6, 2024
8085495
:fire: remoive imports
mathiszerari Nov 6, 2024
c824926
chore : follow project files nomination convention
ValzM Nov 6, 2024
880748a
export type update
mathiszerari Nov 6, 2024
d975da4
chore : plurial to components folder names
ValzM Nov 6, 2024
d4e75a6
feat : add current user friend list
ValzM Nov 5, 2024
1701a07
update types import
mathiszerari Nov 6, 2024
0277a3a
update loader
mathiszerari Nov 6, 2024
1494a70
feat : add plurial to router guards components import
ValzM Nov 6, 2024
4156daa
Merge pull request #2 from mathiszerari/feat/list-friend-request
Smachy24 Nov 6, 2024
890291d
Merge branch 'dev' into feat/send-message
Smachy24 Nov 6, 2024
ebe2259
fix merge
ValzM Nov 6, 2024
b81b16c
chore : remove uppercase from folder names
ValzM Nov 6, 2024
8c3897d
chore : separate function logics with spaces
ValzM Nov 6, 2024
e6e18f4
:art: rename folder and store file
mathiszerari Nov 6, 2024
be26ee4
refactor : create dto folder & move checkAuth to auth service
ValzM Nov 6, 2024
b3b33c8
Merge pull request #4 from mathiszerari/feat/auth
Smachy24 Nov 6, 2024
b1659c4
Merge branch 'dev' into feat/send-message
Smachy24 Nov 6, 2024
ffc31c3
Merge pull request #3 from mathiszerari/feat/send-message
ValzM Nov 6, 2024
c56a414
fix : INTENTIONAL errors to updates folders names
ValzM Nov 6, 2024
430c801
fix : repair previous error to have correct names
ValzM Nov 6, 2024
8bae911
fix : correct import names
ValzM Nov 6, 2024
5ba1ca9
Merge pull request #5 from mathiszerari/fix/folder-names
Smachy24 Nov 6, 2024
92e6123
Merge branch 'dev' of https://github.com/mathiszerari/wii-chat into f…
ValzM Nov 6, 2024
4237ba5
feat: store messages to zustand store
Smachy24 Nov 6, 2024
7311301
feat : redirect user to his friend chat
ValzM Nov 6, 2024
69d0ee0
chore : remove plurial
ValzM Nov 6, 2024
f564a74
Merge pull request #6 from mathiszerari/feat/friends-list
Smachy24 Nov 6, 2024
3773aa2
Merge branch 'dev' of https://github.com/mathiszerari/react-project i…
Smachy24 Nov 6, 2024
cd237c1
Merge pull request #7 from mathiszerari/feat/send-message-error
ValzM Nov 6, 2024
95c056c
Merge branch 'dev' of https://github.com/mathiszerari/react-project i…
Smachy24 Nov 6, 2024
ab3d691
feat : add friend store
ValzM Nov 6, 2024
30d867d
feat : only fetch friends when store is empty
ValzM Nov 6, 2024
7df9776
Merge pull request #8 from mathiszerari/feat/friends-list
mathiszerari Nov 6, 2024
c3c17e1
:sparkles: new friend request notification feature
mathiszerari Nov 6, 2024
bb33cbb
Merge pull request #9 from mathiszerari/feat/notify-friend-request
Smachy24 Nov 6, 2024
88534fa
Merge branch 'feat/user-store' of https://github.com/mathiszerari/wii…
ValzM Nov 6, 2024
6481c62
feat: send error on send message if user not friends
Smachy24 Nov 6, 2024
2502aa3
Merge pull request #11 from mathiszerari/feat/send-message-error
ValzM Nov 6, 2024
51e23f8
feat : user store, clear user and friends store at user Logout
ValzM Nov 6, 2024
9ba9934
feat: different color if sender or receiver
Smachy24 Nov 6, 2024
e264cd4
fix : clear user data at logout
ValzM Nov 6, 2024
3ad7b8b
Merge pull request #13 from mathiszerari/feat/user-store
Smachy24 Nov 6, 2024
f48e01b
Merge pull request #12 from mathiszerari/feat/messages-by-user
Smachy24 Nov 6, 2024
1115f76
:sparkles: create a add-friend component for friend page & send frien…
mathiszerari Nov 6, 2024
9fee1ed
:sparkles: accept friend now avaible
mathiszerari Nov 6, 2024
08611f3
Merge pull request #15 from mathiszerari/dev
mathiszerari Nov 6, 2024
07d668b
:sparkles: reload page
mathiszerari Nov 6, 2024
634fce7
:bug: bug fix
mathiszerari Nov 6, 2024
fd2671e
:sparkles: true id used in friend page
mathiszerari Nov 6, 2024
ef59b2f
Merge pull request #14 from mathiszerari/feat/send-friend-request
Smachy24 Nov 6, 2024
31658a2
feat: add message service adapter
Smachy24 Nov 6, 2024
677467e
:fire: remove settings from navbar (#16)
mathiszerari Nov 6, 2024
b5b8df1
:sparkles: new event listener for accepted notif
mathiszerari Nov 6, 2024
909e052
:sparkles: new notif page
mathiszerari Nov 6, 2024
063fe6e
:sparkles: new notif type and store
mathiszerari Nov 6, 2024
f6edf03
:construction: try to save in the notification store friend-request-r…
mathiszerari Nov 6, 2024
174ff76
:construction: store the accepted friend requests
mathiszerari Nov 6, 2024
eae470c
feat: add loader loading messages
Smachy24 Nov 6, 2024
48007e1
feat: retry messages
Smachy24 Nov 6, 2024
1b14c13
:construction: event in friend page is working
mathiszerari Nov 6, 2024
7fb9a27
:construction: receiving friend request is working everywhere
mathiszerari Nov 6, 2024
ac5f10f
:sparkles: receiving friend request is working and well
mathiszerari Nov 6, 2024
4901a57
:sparkles: request accepted by the other one is now good to be saved
mathiszerari Nov 6, 2024
32f840d
:sparkles: notifications stored in the localStorage
mathiszerari Nov 6, 2024
42c00f2
:sparkles: notification page is great
mathiszerari Nov 6, 2024
332c44b
:sparkles: for invitations send it's good too
mathiszerari Nov 6, 2024
48e4c72
feat: retry message button
Smachy24 Nov 7, 2024
6b06af4
Merge pull request #17 from mathiszerari/feat/message-retry
ValzM Nov 7, 2024
8fb419a
feat: add link to messages
Smachy24 Nov 7, 2024
3c4353b
Merge pull request #18 from mathiszerari/feat/message-link
mathiszerari Nov 7, 2024
ce41773
:construction: notification unseen system is working but notification…
mathiszerari Nov 7, 2024
c5043e3
feat : button component and input styles
ValzM Nov 7, 2024
b1d6e04
:art: move event in app into component notifications
mathiszerari Nov 7, 2024
39b81ca
:construction: in progress
mathiszerari Nov 7, 2024
8613219
Merge branch 'feat/notify-accepted-friend-request' into dev
mathiszerari Nov 7, 2024
8e28897
feat : add login and register style
ValzM Nov 7, 2024
f86b9e6
feat : add footer style
ValzM Nov 7, 2024
e71ad72
feat : make the navigation bar sticky
ValzM Nov 7, 2024
9c3cb1d
Feat/notify accepted friend request (#21)
Smachy24 Nov 7, 2024
dad3070
feat : add friends home and chat styles
ValzM Nov 7, 2024
50681c4
feat : footer responsive
ValzM Nov 7, 2024
2b3e1e3
feat : responsive home
ValzM Nov 7, 2024
5c5fc6a
feat : message responsive
ValzM Nov 7, 2024
7afeb3b
feat : improve friends cards style
ValzM Nov 7, 2024
fca09a7
feat : add custom cursors
ValzM Nov 8, 2024
bd479af
feat : pointer cursor on friend card hover
ValzM Nov 8, 2024
871a7e4
Feat/design system (#22)
ValzM Nov 8, 2024
92dc0e6
Revert "Feat/design system (#22)" (#23)
Smachy24 Nov 8, 2024
00a8f47
Merge branch 'feat/design-system' into dev
ValzM Nov 8, 2024
3fa6d48
fix : message display latest at bottom and get friend name
ValzM Nov 8, 2024
03f72b9
feat : retry message ui (#24)
ValzM Nov 8, 2024
b6cebeb
feat : link message text (#25)
ValzM Nov 8, 2024
5ad33c8
Feat/notifications front (#27)
ValzM Nov 8, 2024
2553b06
Feat/invit link (#26)
mathiszerari Nov 8, 2024
27e5bc4
fix: automatic load friend requests
Smachy24 Nov 8, 2024
27b1ca2
fix: gitignore
Smachy24 Nov 8, 2024
4aa5211
Delete .idea/.gitignore
Smachy24 Nov 8, 2024
6cc9e23
Delete .idea/modules.xml
Smachy24 Nov 8, 2024
6fd27b6
Delete .idea/vcs.xml
Smachy24 Nov 8, 2024
5d3a0f0
Delete .idea/wii-chat.iml
Smachy24 Nov 8, 2024
c10671c
Merge pull request #28 from mathiszerari/fix/friend-request-reload
ValzM Nov 8, 2024
8f20e77
Initial Styling for friend page
jooob56 Nov 8, 2024
23802ad
fix : responsive friend page
jooob56 Nov 8, 2024
f317b1d
chore : cleaning code and comments
jooob56 Nov 8, 2024
9dc289a
Merge branch 'dev' into style/friend-page
jooob56 Nov 8, 2024
a03e44c
Merge pull request #30 from mathiszerari/style/friend-page
ValzM Nov 8, 2024
9c10e07
:bug: error is showed on friend request to add a person that is alrea…
mathiszerari Nov 8, 2024
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT=5000
REACT_APP_API_BASE_URL=http://localhost:3000
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand All @@ -21,3 +22,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea
58 changes: 57 additions & 1 deletion package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
"@types/node": "^16.18.119",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"lucide-react": "^0.454.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.1",
"react-router-dom": "^6.27.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"zustand": "^5.0.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Outlet } from "react-router-dom";

import Navigation from "./components/navigation";
import Notifications from "./components/notifications/notifications.component";

export default function App() {
return (
<div>
<Navigation />
<div className="border w-full h-full flex flex-col justify-between">
<Outlet />
<Notifications />
<Navigation />
</div>
);
}
6 changes: 6 additions & 0 deletions src/adapters/message.adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Message from "../types/message";

export interface MessageAdapter {
sendMessage: (message: Message) => Promise<void>;
fetchMessages: (receiverId: string) => Promise<Message[]>;
}
Binary file added src/assets/images/block-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/normal-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/pointer-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/text-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/common/error.common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class CommonError extends Error {
public statusCode: number;
public errorCode: string;
public details?: any;

constructor(statusCode: number, errorCode: string, message: string, details?: any) {
super(message);
this.statusCode = statusCode;
this.errorCode = errorCode;
this.details = details;

Object.setPrototypeOf(this, CommonError.prototype);
}

toJSON() {
return {
statusCode: this.statusCode,
errorCode: this.errorCode,
message: this.message,
details: this.details || null,
};
}
}
100 changes: 100 additions & 0 deletions src/components/add-friend.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { useUserStore } from "../stores/user.store";
import { SubmitHandler, useForm } from "react-hook-form";
import { sendFriendRequest } from "../services/friend-request.service";
import ShareButton from "./send-invite-link.component";
import { useState } from "react";
import Button from "./buttons/button";

type FormInputs = {
content: string;
}

export default function AddFriend() {
const user = useUserStore();
const [error, setError] = useState<string | null>(null);
const { register, handleSubmit, reset } = useForm({
defaultValues: {
content: ""
}
});

const onSubmit: SubmitHandler<FormInputs> = async (input) => {
try {
await sendFriendRequest(input.content);
reset();
} catch (err) {
console.error(err);
setError((err as Error).message);
}
}

const sendFriendRequest = async (receiverId: string) => {
try {
const randomuuid = crypto.randomUUID();
const response = await fetch(`${process.env.REACT_APP_API_BASE_URL}/social/friend-request/${randomuuid}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({ receiverId: receiverId }),
});

if (!response.ok) {
const error = await response.json();
throw new Error(error.message);
}
} catch (error) {
console.error('Error sending friend request:', error);
throw error;
}
}

return (
<div>
<div>
<div className='adress-book-rim'>
<div className='adress-book'>
<h2 className='smiley'>&#9786;&#9787;</h2>
<h1>Adress Book</h1>

<div className='friend-code'>
<p className='info-message'>This console's Wii number</p>
<div className='flex items-center'>
<p className=''>{user.id}</p>
</div>
</div>
<div className="flex flex-row gap-4">
<Button
className="relative right-2 z-10"
variant="primary"
label="Copy"
onClick={() => navigator.clipboard.writeText(user.id)}
/>
<ShareButton />
</div>
</div>
</div>

<div className='add-friend-form'>
<div className='add-friend-form-header'>
<p>Wii Number</p>
</div>
<form onSubmit={handleSubmit(onSubmit)}>
<input type="text"
placeholder="Enter a Wii Number" {...register('content', { required: true })} />
<Button
className="relative right-2 z-10 mb-2"
variant="primary"
label="send"
type="submit"
/>
</form>

{error && <div className="text-red-500">{error}</div>}
</div>
</div>

</div>
);
}
28 changes: 28 additions & 0 deletions src/components/buttons/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface ButtonProps {
label: string;
onClick?: (params?: any) => any;
type?: "submit" | "button";
disabled?: boolean;
variant?: "primary" | "secondary" | "tertiary";
className?: string;
}

export default function Button({
label,
onClick,
type = "button",
disabled,
variant = "primary",
className,
}: ButtonProps) {
return (
<button
className={`${variant}-btn ${className}`}
onClick={onClick}
disabled={disabled}
type={type}
>
{label}
</button>
);
}
17 changes: 17 additions & 0 deletions src/components/buttons/icon.button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interface IconButtonProps {
children?: React.ReactNode;
onClick: (params?: any) => any;
className?: string;
}

export default function IconButton({
children,
onClick,
className,
}: IconButtonProps) {
return (
<button className={`icon-btn ${className}`} onClick={onClick}>
{children ?? children}
</button>
);
}
9 changes: 9 additions & 0 deletions src/components/cards/friend-placeholder.card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.friend-card-placeholder {
@apply border-4 border-zinc-400 aspect-video rounded-[5%/40%] bg-slate-50 shadow-[inset_0px_-64px_32px_rgba(0,0,0,0.2)] cursor-not-allowed;
@apply bg-gradient-to-b from-zinc-300 via-zinc-300 to-zinc-300;
@apply bg-[length:7px_7px];
}

.friend-card-placeholder:hover {
cursor: url("../../assets/images/block-cursor.png"), not-allowed;
}
9 changes: 9 additions & 0 deletions src/components/cards/friend-placeholder.card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import "./friend-placeholder.card.css";

export default function FriendCardPlaceholder() {
return (
<div className="friend-card-placeholder flex justify-center items-center text-5xl font-bold select-none">
<span className="opacity-10">Wii Chat</span>
</div>
);
}
32 changes: 32 additions & 0 deletions src/components/cards/friend.card.style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@layer {
.friend-card {
@apply flex justify-center items-center font-bold text-2xl uppercase;
@apply cursor-pointer border-4 border-zinc-400 aspect-video rounded-[5%/40%] bg-slate-50 shadow-[inset_0px_-64px_32px_rgba(0,0,0,0.2)] hover:scale-105 transition-all duration-300;
@apply bg-[length:7px_7px];
}

.friend-card:hover {
cursor: url("../../assets/images/pointer-cursor.png"), not-allowed;
}
}

.friend-card-red {
@apply friend-card;
@apply text-red-400;
@apply border-4 border-red-300 bg-red-50 shadow-[inset_0px_-64px_32px_rgba(255,0,0,0.2)];
@apply bg-gradient-to-b from-red-100 via-red-200 to-red-200;
}

.friend-card-blue {
@apply friend-card;
@apply text-blue-500;
@apply border-4 border-blue-300 bg-blue-50 shadow-[inset_0px_-64px_32px_rgba(0,0,255,0.2)];
@apply bg-gradient-to-b from-blue-200 via-blue-200 to-blue-200;
}

.friend-card-green {
@apply friend-card;
@apply text-green-500;
@apply border-4 border-green-300 bg-green-50 shadow-[inset_0px_-64px_32px_rgba(0,255,0,0.2)];
@apply bg-gradient-to-b from-green-200 via-green-200 to-green-200;
}
Loading