Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

298 auth #343

Merged
merged 52 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3aed649
requests
RobzLegz Sep 26, 2022
d6d3c66
Merge pull request #342 from RobzLegz/338-like
RobzLegz Sep 26, 2022
db55bd6
send req
RobzLegz Sep 26, 2022
e815062
test
RobzLegz Sep 27, 2022
a2439d8
Merge pull request #344 from RobzLegz/298-auth
RobzLegz Sep 27, 2022
fe4a2bf
why u not wrk ???
RobzLegz Sep 27, 2022
b3e7d1a
user icon
RobzLegz Sep 27, 2022
3b1218b
starting profile
RobzLegz Sep 27, 2022
e9ecd5c
lolading
RobzLegz Sep 27, 2022
73d69b1
routes
RobzLegz Sep 27, 2022
3f14e8d
add to favourites route
RobzLegz Sep 27, 2022
d7ae9ef
rtrn stuff
RobzLegz Sep 27, 2022
977ab26
logging
RobzLegz Sep 27, 2022
e669334
register work
RobzLegz Sep 27, 2022
60daabc
controls opt
RobzLegz Sep 27, 2022
2102b48
rdx
RobzLegz Sep 27, 2022
f138377
fix login and register
Piparkuucinsh Sep 27, 2022
e3bf956
shiii
RobzLegz Sep 27, 2022
b9234fe
liked page
RobzLegz Sep 28, 2022
4f447a6
controls
RobzLegz Sep 28, 2022
a1d7e86
add to favourites
RobzLegz Sep 28, 2022
1270bd9
fav file
RobzLegz Sep 28, 2022
5ece2a4
favourites
RobzLegz Sep 28, 2022
a2ff54d
kidala
RobzLegz Sep 28, 2022
9aef78d
Merge pull request #351 from RobzLegz/348-favourite
RobzLegz Sep 28, 2022
0dffac4
drag
RobzLegz Sep 28, 2022
ec03e35
starting settnigs
RobzLegz Sep 28, 2022
a391b4d
banner
RobzLegz Sep 28, 2022
2067f08
settings
RobzLegz Sep 28, 2022
43b32a3
profile
RobzLegz Sep 28, 2022
2f4d458
start
RobzLegz Sep 28, 2022
00e0d26
responsive profile
RobzLegz Sep 28, 2022
edcc7af
preview
RobzLegz Sep 28, 2022
6036efd
responsive profile
RobzLegz Sep 28, 2022
cdc9e0d
responsive settings
RobzLegz Sep 28, 2022
b253f65
controls
RobzLegz Sep 28, 2022
ef554d3
load user
RobzLegz Sep 28, 2022
6f10d34
changes
Piparkuucinsh Sep 28, 2022
85f8036
Merge branch '357-settings' into fastapi-backend
RobzLegz Sep 28, 2022
b94f77c
Merge pull request #360 from RobzLegz/fastapi-backend
RobzLegz Sep 28, 2022
f53b842
login
RobzLegz Sep 28, 2022
aed6dba
register fix
RobzLegz Sep 29, 2022
a813742
real time files
RobzLegz Sep 29, 2022
27ac70a
disabled
RobzLegz Sep 29, 2022
9ba4454
update profile
RobzLegz Sep 29, 2022
a663bc6
keybind
RobzLegz Sep 29, 2022
371f89a
opt
RobzLegz Sep 29, 2022
b81ef18
max
RobzLegz Sep 29, 2022
0650fd7
Merge pull request #359 from RobzLegz/357-settings
RobzLegz Sep 29, 2022
4c8426a
Merge pull request #356 from RobzLegz/354-profile
RobzLegz Sep 29, 2022
6c53e30
Merge pull request #355 from RobzLegz/353-edit
RobzLegz Sep 29, 2022
8dac4a1
Merge pull request #347 from RobzLegz/345-profile
RobzLegz Sep 29, 2022
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
3 changes: 3 additions & 0 deletions frontend/pages/new/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Profile from '../../src/modules/pages/Profile';

export default Profile;
3 changes: 3 additions & 0 deletions frontend/pages/new/settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Settings from '../../src/modules/pages/Settings';

export default Settings;
Binary file added frontend/public/images/kidala.jpg
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 frontend/public/images/kidala.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: 1 addition & 0 deletions frontend/src/interfaces/like.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface Like {
user_id: string;
file_id: string;
count: number;
}
9 changes: 8 additions & 1 deletion frontend/src/interfaces/user.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { Like } from './like';

export interface User {
_id: string;
ip: string | null;
email: string | null;
role: "admin" | null;
role: 'admin' | null;
username: string | null;
password: string | null;
bio?: string | null;
name?: string | null;
avatar?: string | null;
banner?: string | null;
favourites: string[];
likes: Like[];
verified: boolean;
followers: string[];
following: string[];
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/PageModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const PageModule: React.FC<PageModuleProps> = ({
return (
<main className={`page ${className}`}>
<HeadParser title={title} description={description} file={file} />

{children}

<CheckAuth />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/pages/MyFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const MyFiles: PageComponent<MyFilesProps> = () => {
<PageModule
title="MyFiles"
description="Kidala life - combining social media with file upload"
className="pt-24"
className="pt-24 px-2"
>
<Nav myFiles />

Expand Down
21 changes: 21 additions & 0 deletions frontend/src/modules/pages/Profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NextPage } from 'next';
import React from 'react';
import Nav from '../../ui/navigation/Nav';
import ProfileContainer from '../../ui/profile/ProfileContainer';
import PageModule from '../PageModule';

const Profile: NextPage = () => {
return (
<PageModule
title="Profile"
description="Your profile on kidala upload file hosting services"
className="pt-24"
>
<Nav />

<ProfileContainer />
</PageModule>
);
};

export default Profile;
21 changes: 21 additions & 0 deletions frontend/src/modules/pages/Settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NextPage } from 'next';
import React from 'react';
import Nav from '../../ui/navigation/Nav';
import SettingsContainer from '../../ui/settings/SettingsContainer';
import PageModule from '../PageModule';

const Settings: NextPage = () => {
return (
<PageModule
title="Settings"
description="Kidala file upload. User settings"
className="pt-24 px-2"
>
<Nav />

<SettingsContainer />
</PageModule>
);
};

export default Settings;
108 changes: 97 additions & 11 deletions frontend/src/redux/slices/appSlice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createSlice } from '@reduxjs/toolkit';
import { FileInterface } from '../../interfaces/file';
import { Like } from '../../interfaces/like';
import { User } from '../../interfaces/user';
import { LikeFileResponse } from '../../requests/fileRequests';
import { sortFiles } from '../../utils/sortFiles';

export interface SortOptions {
Expand All @@ -14,6 +17,7 @@ export interface AppInfo {
sortOptions: SortOptions;
audioVolume: number;
db_file_len: number;
collectedUsers: User[];
}

const initialState: AppInfo = {
Expand All @@ -26,6 +30,7 @@ const initialState: AppInfo = {
},
audioVolume: 1,
db_file_len: 0,
collectedUsers: [],
};

export const appSlice = createSlice({
Expand Down Expand Up @@ -87,12 +92,47 @@ export const appSlice = createSlice({
return state;
}

const newfiles: FileInterface[] = state.files.map((prod) => {
if (prod._id === updatedFile._id) {
prod = updatedFile;
const newfiles: FileInterface[] = state.files.map((fileQ) => {
if (fileQ._id === updatedFile._id) {
fileQ = updatedFile;
}

return prod;
return fileQ;
});

state = {
...state,
files: newfiles,
};

return state;
},
likeFileRdx: (
state,
action: { type: string; payload: LikeFileResponse['likeObj'] }
) => {
if (!state.files) {
return state;
}

const newLike: Like = {
...action.payload,
};

const newfiles: FileInterface[] = state.files.map((fileQ) => {
if (fileQ._id === action.payload.file_id) {
fileQ = {
...fileQ,
likes: [
...fileQ.likes.filter(
(l) => l.user_id !== newLike.user_id
),
newLike,
],
};
}

return fileQ;
});

state = {
Expand Down Expand Up @@ -150,21 +190,21 @@ export const appSlice = createSlice({
return state;
}

const siftFiles = files.map((blog) => {
if (state.files?.some((b) => b._id === blog._id)) {
const siftFiles = files.map((file) => {
if (state.files?.some((b) => b._id === file._id)) {
return null;
}

return blog;
return file;
});

const okFiles = siftFiles.filter((bl) => bl !== null);

let newFiles: FileInterface[] = [...state.files];

okFiles.forEach((blog) => {
if (blog) {
newFiles = [...newFiles, blog];
okFiles.forEach((file) => {
if (file) {
newFiles = [...newFiles, file];
}
});

Expand All @@ -181,6 +221,50 @@ export const appSlice = createSlice({
db_file_len: action.payload,
};

return state;
},
getUserFromFileRdx: (state, action) => {
const collectedUsers: User[] | null = action.payload;

if (!collectedUsers) {
return state;
}

if (
!state.collectedUsers ||
state.collectedUsers.length === 0
) {
state = {
...state,
collectedUsers: collectedUsers,
};

return state;
}

const siftUsers = collectedUsers.map((user) => {
if (state.collectedUsers?.some((b) => b._id === user._id)) {
return null;
}

return user;
});

const okUsers = siftUsers.filter((bl) => bl !== null);

let newUsers: User[] = [...state.collectedUsers];

okUsers.forEach((file) => {
if (file) {
newUsers = [...newUsers, file];
}
});

state = {
...state,
collectedUsers: newUsers,
};

return state;
},
},
Expand All @@ -195,7 +279,9 @@ export const {
setSortOptions,
setAudioVolume,
receiveFiles,
setDbFileLen
setDbFileLen,
likeFileRdx,
getUserFromFileRdx,
} = appSlice.actions;

export const selectApp = (state: any) => state.app;
Expand Down
Loading