diff --git a/src/components/Pages.jsx b/src/components/Pages.jsx index daa09a2..6caa7c3 100644 --- a/src/components/Pages.jsx +++ b/src/components/Pages.jsx @@ -15,6 +15,11 @@ import Services from '../pages/Services'; import Settings from '../pages/Settings'; import SettingsProfile from './profiles/settings/Profile'; import Password from './profiles/settings/Password'; +import Follow from './profiles/Follow/Follow'; +import Follower from './profiles/Follow/Follower'; +import Following from './profiles/Follow/Following'; +import Request from './profiles/Follow/Request'; +import Default from './profiles/Follow/Default'; export default function Pages(props) { const importData = { @@ -30,12 +35,25 @@ export default function Pages(props) { }> }> }> + }> + }> + {/* }> */} }> }> {/* }> */} + }> + }> + }/> + }> + + }> + }/> + }> + + }> }/> }/> diff --git a/src/components/profiles/Follow/Default.jsx b/src/components/profiles/Follow/Default.jsx new file mode 100644 index 0000000..09d6d61 --- /dev/null +++ b/src/components/profiles/Follow/Default.jsx @@ -0,0 +1,36 @@ +import React, { useEffect, useState } from 'react' +import { Link, Outlet, useOutletContext, useParams } from 'react-router-dom' +import User from './components/User'; +import { FetchPOST } from '../../../middlewares/Fetch'; + +export default function Default() { + const {setSelectedMenu, buttonAction, data, username} = useOutletContext(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + console.log(data, 5) + setLoading(false); + },[]); + + if(loading){ return (<>) }; + + return ( +
+ +

Gönderdiğim İstekler ({data.requests.length})

+ +
+ { + (data.isNull === 0) ? +
+

Hiçbir Takipçiniz yok

+
+ : + data.current.map(get => + + ) + } +
+
+ ); +}; \ No newline at end of file diff --git a/src/components/profiles/Follow/Follow.jsx b/src/components/profiles/Follow/Follow.jsx new file mode 100644 index 0000000..53e0ffc --- /dev/null +++ b/src/components/profiles/Follow/Follow.jsx @@ -0,0 +1,49 @@ +import React, { useState } from 'react' +import { Link, Outlet } from 'react-router-dom' +import { FetchPOST } from '../../../middlewares/Fetch'; + +export default function Follow() { + const [selectedMenu, setSelectedMenu] = useState(1); + + return ( +
+
+
+ Takip Edilen +
+
+ Takipçiler +
+
+
+ +
+
+ ); +}; + +const friendPOST = (e, userId) => { + FetchPOST({ + port: 3001, + pathname: "/post/follow", + fetchData:{ + method: "POST", + credentials: 'include', + headers: { + 'Accept' : 'application/json', + 'Content-Type' : 'application/json' + }, + body: JSON.stringify({ + userId: userId + }) + } + }).then(res => { + if(res.follow){ + e.target.innerText = res.follow.title; + console.log(res) + if(res.follow.statu === true){ + e.target.classList.add("bg-pc", "bg-opacity-40") + } + }; + }); + }; \ No newline at end of file diff --git a/src/components/profiles/Follow/Follower.jsx b/src/components/profiles/Follow/Follower.jsx new file mode 100644 index 0000000..607141a --- /dev/null +++ b/src/components/profiles/Follow/Follower.jsx @@ -0,0 +1,84 @@ +import React, { useEffect, useState } from 'react' +import { Link, Outlet, useOutletContext, useParams } from 'react-router-dom'; +import User from './components/User'; +import { FetchPOST } from '../../../middlewares/Fetch'; +import Loading from '../../Loading'; + +export default function Follower() { + const {setSelectedMenu, buttonAction} = useOutletContext(); + const [followers, setFollowers] = useState([]); + const [loading, setLoading] = useState(true); + const { username } = useParams(); + + useEffect(() => { + setSelectedMenu(2); + FetchPOST({ + port: 3001, + pathname: "/get/follow/followers/" + username, + fetchData: { + method: "GET" + } + }) + .then(res => { + setFollowers(res.data); + setLoading(false); + }); + },[]); + + if(loading) { return (<>) }; + + return ( +
+ +
+ ); +}; + +// const followPOST = (e, userId) => { +// FetchPOST({ +// port: 3001, +// pathname: "/post/follow", +// fetchData:{ +// method: "POST", +// credentials: 'include', +// headers: { +// 'Accept' : 'application/json', +// 'Content-Type' : 'application/json' +// }, +// body: JSON.stringify({ +// userId: userId +// }) +// } +// }).then(res => { +// if(res.follow){ +// e.target.innerText = res.follow.title; +// console.log(res) +// if(res.follow.statu === true){ +// e.target.classList.add("bg-pc", "bg-opacity-40") +// } +// }; +// }); +// }; + +const destroyFollowerPOST = (e, userId) => { + FetchPOST({ + port: 3001, + pathname: "/post/follow/follower/destroy", + fetchData:{ + method: "POST", + credentials: 'include', + headers: { + 'Accept' : 'application/json', + 'Content-Type' : 'application/json' + }, + body: JSON.stringify({ + userId: userId + }) + } + }) + .then(res => { + if(res.process === true){ + e.target.parentElement.parentElement.remove(); + }; + }); +}; \ No newline at end of file diff --git a/src/components/profiles/Follow/Following.jsx b/src/components/profiles/Follow/Following.jsx new file mode 100644 index 0000000..a199eaf --- /dev/null +++ b/src/components/profiles/Follow/Following.jsx @@ -0,0 +1,33 @@ +import React, { useEffect, useState } from 'react'; +import { Outlet, useOutletContext, useParams } from 'react-router-dom'; +import { FetchPOST } from '../../../middlewares/Fetch'; + +export default function Following() { + const { selectedMenu, setSelectedMenu, followPOST } = useOutletContext(); + const {username} = useParams(); + const [loading, setLoading] = useState(true); + const [followings, setFollowings] = useState(); + + useEffect(()=>{ + setSelectedMenu(1); + FetchPOST({ + port: 3001, + pathname: "/get/follow/followings/" + username, + fetchData: { + method: "GET" + } + }) + .then(res => { + setFollowings(res.data); + setLoading(false); + }); + },[window.location.pathname]); + + if(loading) { return (<>) }; + + return ( +
+ +
+ ); +}; \ No newline at end of file diff --git a/src/components/profiles/Follow/Request.jsx b/src/components/profiles/Follow/Request.jsx new file mode 100644 index 0000000..40ce780 --- /dev/null +++ b/src/components/profiles/Follow/Request.jsx @@ -0,0 +1,55 @@ +import React, { useEffect, useState } from 'react' +import { Link, useOutletContext } from 'react-router-dom'; +import User from './components/User'; +import { FetchPOST } from '../../../middlewares/Fetch'; + +export default function Request() { + const { data, buttonAction, uid } = useOutletContext(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + console.log(data, uid) + setLoading(false); + },[]); + + if(loading){ + return(<>); + }; + + return ( +
+
+ + Geri Git + +
+
+ { + data.requests.map(get => + + ) + } +
+
+ ); +}; + +const requestPOST = (e, userId, svar) => { + FetchPOST({ + port: 3001, + pathname: "/post/follow/request", + fetchData:{ + method: "POST", + credentials: 'include', + headers: { + 'Accept' : 'application/json', + 'Content-Type' : 'application/json' + }, + body: JSON.stringify({ + userId: userId, + svar: svar + }) + } + }) + .then(res => console.log(res)); +}; \ No newline at end of file diff --git a/src/components/profiles/Follow/components/User.jsx b/src/components/profiles/Follow/components/User.jsx new file mode 100644 index 0000000..d4989b6 --- /dev/null +++ b/src/components/profiles/Follow/components/User.jsx @@ -0,0 +1,35 @@ +import React, { useEffect } from 'react' +import { Link } from 'react-router-dom'; + +export default function User({data, button, buttonAction, uid="default"}) { + console.log(uid) + if(uid === "default"){ + return ( +
+ +

{data.first_name} {data.second_name}

+

@{data.username}

+ + { + (button.isMy === false) && + + } +
+ ); + }else if(uid === "me-request"){ + return ( +
+ +

{data.first_name} {data.second_name}

+

@{data.username}

+ + +
+ ); + } +}; \ No newline at end of file diff --git a/src/components/profiles/components/Header.jsx b/src/components/profiles/components/Header.jsx index f9d3bda..cac2a03 100644 --- a/src/components/profiles/components/Header.jsx +++ b/src/components/profiles/components/Header.jsx @@ -1,7 +1,9 @@ import React from 'react' import { FetchPOST } from '../../../middlewares/Fetch'; +import { Link, useParams } from 'react-router-dom'; export default function Header({data}) { + const {username} = useParams(); const friendPOST = (e) => { FetchPOST({ port: 3001, @@ -36,28 +38,31 @@ export default function Header({data}) {

{data.user.first_name} {data.user.second_name}

-
+

Takipçi

-

50

+

{data.user.followers.length}

-
+

{data.user.about}

-
+

Takip Edilen

-

50

+

{data.user.followings.length}

-
- + + { + (data.isMy === false) && + + }
diff --git a/src/components/profiles/settings/Profile.jsx b/src/components/profiles/settings/Profile.jsx index 62de60d..91fa134 100644 --- a/src/components/profiles/settings/Profile.jsx +++ b/src/components/profiles/settings/Profile.jsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react' import { FetchPOST } from '../../../middlewares/Fetch' import { useOutletContext } from 'react-router-dom'; +import Loading from '../../Loading'; export default function Profile(props) { const { selectedMenu, setSelectedMenu } = useOutletContext(); @@ -83,7 +84,9 @@ export default function Profile(props) { },[]); if(loading){ - return (<>); + return ( + + ); } return ( diff --git a/src/pages/Profile.jsx b/src/pages/Profile.jsx index 1d43da9..446a7cd 100644 --- a/src/pages/Profile.jsx +++ b/src/pages/Profile.jsx @@ -22,5 +22,5 @@ export default function Profile({selectedMenu, setSelectedMenu, uid}) {
- ) -} \ No newline at end of file + ); +}; \ No newline at end of file