Skip to content

Commit 8aa8e4e

Browse files
author
peanut201
committed
update profile and footer
1 parent 71c80d0 commit 8aa8e4e

File tree

12 files changed

+292
-65
lines changed

12 files changed

+292
-65
lines changed

client/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"react-dom": "^17.0.2",
2323
"react-hook-form": "^7.17.5",
2424
"react-icons": "^4.3.1",
25+
"react-image-crop": "^9.0.5",
2526
"react-redux": "^7.2.5",
2627
"react-router-dom": "^5.3.0",
2728
"react-scripts": "4.0.3",
@@ -59,4 +60,4 @@
5960
"concurrently": "^6.3.0",
6061
"redux-devtools": "^3.7.0"
6162
}
62-
}
63+
}

client/src/components/Footer.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useColorModeValue,
77
VisuallyHidden,
88
} from "@chakra-ui/react";
9-
import {FaInstagram, FaTwitter, FaYoutube} from "react-icons/fa";
9+
import {BsTelegram ,BsFacebook ,BsLinkedin} from "react-icons/bs";
1010

1111
const Logo = (props) => {
1212
return (
@@ -73,14 +73,14 @@ export function Footer() {
7373
© {new Date().getFullYear()} React Example. All rights reserved
7474
</Text>
7575
<Stack direction={"row"} spacing={6}>
76-
<SocialButton label={"Twitter"} href={"#"}>
77-
<FaTwitter/>
76+
<SocialButton label={"Telegram"} href={"https://t.me/peanut201"}>
77+
<BsTelegram/>
7878
</SocialButton>
79-
<SocialButton label={"YouTube"} href={"#"}>
80-
<FaYoutube/>
79+
<SocialButton label={"Facebook"} href={"https://www.facebook.com/truongdq2001/"}>
80+
<BsFacebook/>
8181
</SocialButton>
82-
<SocialButton label={"Instagram"} href={"#"}>
83-
<FaInstagram/>
82+
<SocialButton label={"Linked In"} href={"www.linkedin.com/in/peanut201"}>
83+
<BsLinkedin/>
8484
</SocialButton>
8585
</Stack>
8686
</Container>

client/src/components/Header.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import {
1414
useColorMode,
1515
Center,
1616
} from "@chakra-ui/react";
17-
import { MoonIcon, SunIcon } from "@chakra-ui/icons";
18-
import { useDispatch, useSelector } from "react-redux";
19-
import { userSelector } from "../redux/selector";
20-
import { MemoryClient } from "../utils";
21-
import { useHistory } from "react-router-dom";
22-
import { CHECKING_AUTH, ENUM_STATUS, genericAction } from "../redux/actions";
17+
import {MoonIcon, SunIcon} from "@chakra-ui/icons";
18+
import {useDispatch, useSelector} from "react-redux";
19+
import {userSelector} from "../redux/selector";
20+
import {MemoryClient} from "../utils";
21+
import {useHistory} from "react-router-dom";
22+
import {CHECKING_AUTH, ENUM_STATUS, genericAction} from "../redux/actions";
2323

2424
export function Header() {
25-
const { colorMode, toggleColorMode } = useColorMode();
25+
const {colorMode, toggleColorMode} = useColorMode();
2626
const dataUser = useSelector(userSelector);
2727
const history = useHistory();
2828
const dispatch = useDispatch();
@@ -45,7 +45,7 @@ export function Header() {
4545
<Flex alignItems={"center"}>
4646
<Stack direction={"row"} spacing={7}>
4747
<Button onClick={toggleColorMode}>
48-
{colorMode === "light" ? <MoonIcon /> : <SunIcon />}
48+
{colorMode === "light" ? <MoonIcon/> : <SunIcon/>}
4949
</Button>
5050

5151
<Menu>
@@ -58,23 +58,23 @@ export function Header() {
5858
>
5959
<Avatar
6060
size={"sm"}
61-
src={"https://avatars.dicebear.com/api/male/username.svg"}
61+
src={dataUser.user.avatar_url || "https://avatars.dicebear.com/api/male/username.svg"}
6262
/>
6363
</MenuButton>
6464
<MenuList alignItems={"center"}>
65-
<br />
65+
<br/>
6666
<Center>
6767
<Avatar
6868
size={"2xl"}
69-
src={"https://avatars.dicebear.com/api/male/username.svg"}
69+
src={dataUser.user.avatar_url || "https://avatars.dicebear.com/api/male/username.svg"}
7070
/>
7171
</Center>
72-
<br />
72+
<br/>
7373
<Center>
74-
<p>{dataUser.user ? dataUser.user.username : ""}</p>
74+
<p>{dataUser.user.username || ""}</p>
7575
</Center>
76-
<br />
77-
<MenuDivider />
76+
<br/>
77+
<MenuDivider/>
7878
<MenuItem onClick={() => history.push("/my-profile")}>
7979
Account Settings
8080
</MenuItem>
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react';
2+
import {Button, FormLabel, useToast} from "@chakra-ui/react";
3+
import {uploadFileFirebase} from "../utils";
4+
import {useSelector} from "react-redux";
5+
import {userSelector} from "../redux/selector";
6+
7+
8+
export function SingleUploadFile({onComplete}) {
9+
const dataUser = useSelector(userSelector);
10+
const toast = useToast();
11+
const onChangeFile = async (e) => {
12+
if (!e.target.files || e.target.files && !e.target.files.length) {
13+
toast({
14+
title: "Error load file",
15+
description: "Something went wrong load file!",
16+
status: "error",
17+
duration: 3000,
18+
isClosable: true,
19+
variant: "left-accent",
20+
position: "top",
21+
});
22+
}
23+
let imgFile = e.target.files[0];
24+
let validFile = imgFile.type !== 'image/png';
25+
if (validFile) {
26+
toast({
27+
title: "Valid file",
28+
description: "File includes .png | .jpg !",
29+
status: "error",
30+
duration: 3000,
31+
isClosable: true,
32+
variant: "left-accent",
33+
position: "top",
34+
});
35+
return;
36+
}
37+
const link = await uploadFileFirebase(dataUser.user._id, imgFile);
38+
onComplete(link);
39+
}
40+
return (
41+
<div className={'w-full'}>
42+
<Button as={FormLabel} htmlFor="upload" className="w-full">Change Avatar</Button>
43+
<input type={'file'} id="upload" hidden onChange={onChangeFile} value={''}/>
44+
</div>
45+
)
46+
}

client/src/config/firebase-cloud.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Import the functions you need from the SDKs you need
22
import { initializeApp } from "firebase/app";
33
import { GoogleAuthProvider, getAuth, signInWithPopup } from "firebase/auth";
4-
import { getStorage, ref } from "firebase/storage";
4+
import { getStorage } from "firebase/storage";
55

66
// TODO: Add SDKs for Firebase products that you want to use
77
// https://firebase.google.com/docs/web/setup#available-libraries
@@ -23,10 +23,8 @@ const app = initializeApp(firebaseConfig);
2323
// const analytics = getAnalytics(app);
2424
const auth = getAuth();
2525

26-
const storage = getStorage(app);
26+
export const storage = getStorage(app);
2727

28-
// Create a storage reference from our storage service
29-
export const storageRef = ref(storage);
3028
export const providerGoogle = new GoogleAuthProvider();
3129
providerGoogle.setCustomParameters({ prompt: "select_account" });
3230

0 commit comments

Comments
 (0)