Düzenlemeler ve hata giderme
This commit is contained in:
parent
dc772c89d5
commit
eb4f02238d
@ -20,6 +20,7 @@ export default function App() {
|
||||
const [popup, setPopup] = useState("");
|
||||
|
||||
const globalState = {
|
||||
title: "Arslanşah",
|
||||
states: {
|
||||
rightMenu, setRightMenu, leftMenu, setLeftMenu, popup, setPopup
|
||||
}
|
||||
|
||||
@ -2,17 +2,22 @@ import React, { useContext, useEffect, useState } from 'react'
|
||||
import { GSContext } from '../../../../../middlewares/GlobalStore';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { I18nContext } from '../../../../../middlewares/Locale';
|
||||
import { getProfileDetails } from '../../../../../middlewares/profiles/getProfile';
|
||||
|
||||
export default function FollowRight({profile}) {
|
||||
export default function FollowRight({username}) {
|
||||
const { globalState } = useContext(GSContext);
|
||||
const { locale } = useContext(I18nContext);
|
||||
const [profileKeys, setProfileKeys] = useState();
|
||||
const [profile, setProfile] = useState();
|
||||
|
||||
useEffect(()=>{
|
||||
if(profile){
|
||||
setProfileKeys(Object.keys(profile));
|
||||
if(username){
|
||||
getProfileDetails(3001, username).then(res => {
|
||||
setProfile(res);
|
||||
setProfileKeys(Object.keys(res));
|
||||
});
|
||||
};
|
||||
},[profile]);
|
||||
},[username]);
|
||||
|
||||
|
||||
if(profile){
|
||||
|
||||
@ -8,7 +8,6 @@ export default function ProfileMenuBox() {
|
||||
|
||||
useEffect(()=>{
|
||||
setLoading(false);
|
||||
console.log(globalState, 567891);
|
||||
},[]);
|
||||
|
||||
if(loading === true){
|
||||
@ -16,7 +15,7 @@ export default function ProfileMenuBox() {
|
||||
}else{
|
||||
return (
|
||||
<Link to={`/profile/${globalState.user.username}/posts`} className={'flex h-24 w-full p-2 gap-2 bg-white rounded-2xl shadow-lg'}>
|
||||
<img src='/1.1.jpg' className='h-full rounded-2xl'></img>
|
||||
{/* <img src='/1.1.jpg' className='h-full rounded-2xl'></img> */}
|
||||
<div className='flex flex-col items-center justify-center gap-1'>
|
||||
<div>
|
||||
<p className='font-bold text-sm'>{globalState.user.first_name} {globalState.user.second_name}</p>
|
||||
|
||||
@ -9,8 +9,11 @@ export default function PostSave({data, localeCode}) {
|
||||
<div className='flex gap-1 justify-between'>
|
||||
{/* <div className='flex items-center justify-center rounded-full m-1 aspect-square bg-pc'/> */}
|
||||
<div className='flex items-center gap-1'>
|
||||
<Link to={data.user.href} className='font-bold'>{data.user.name}</Link>
|
||||
<Link to={data.blog.href} className=''>{locale[localeCode]}.</Link>
|
||||
<p>
|
||||
<Link to={data.user.href} className='font-bold'>{data.user.name}</Link>
|
||||
<br/>
|
||||
<Link to={data.blog.href} className=''>{locale[localeCode]}.</Link>
|
||||
</p>
|
||||
</div>
|
||||
<div className='flex items-center'>
|
||||
<p>{data.datetime.createdAt.differance[data.datetime.createdAt.differance.current]} {locale[data.datetime.createdAt.differance.current]}</p>
|
||||
|
||||
@ -6,7 +6,7 @@ import FollowRight from '../../menus/right/Profile/Follow/FollowRight';
|
||||
export default function User({people}) {
|
||||
const {globalState} = useContext(GSContext);
|
||||
return (
|
||||
<div to={"/profile/" + people.username} onClick={() => globalState.states.setRightMenu(<FollowRight profile={people}/>)} className='flex flex-col justify-center p-2 gap-1 cursor-pointer hover:bg-pc'>
|
||||
<div to={"/profile/" + people.username} onClick={() => globalState.states.setRightMenu(<FollowRight username={people.username}/>)} className='flex flex-col justify-center p-2 gap-1 cursor-pointer hover:bg-pc'>
|
||||
<p>{people.first_name} {people.second_name}</p>
|
||||
<p>@{people.username}</p>
|
||||
</div>
|
||||
|
||||
@ -8,10 +8,13 @@ import PostComments from './PostComments';
|
||||
import { openPopup, renderPopup } from '../../../middlewares/popups/popup';
|
||||
import { GSContext } from '../../../middlewares/GlobalStore';
|
||||
import Popup from '../../popup/Popup';
|
||||
import { convertHTML } from '../../../middlewares/general/Text';
|
||||
|
||||
export default function Post({data}) {
|
||||
const {globalState} = useContext(GSContext);
|
||||
|
||||
console.log();
|
||||
|
||||
if(data.reblog === true){
|
||||
return (
|
||||
<div key={data.id} className='flex bg-white rounded-2xl overflow-hidden w-full'>
|
||||
@ -87,7 +90,7 @@ export default function Post({data}) {
|
||||
</div>
|
||||
<div>
|
||||
<p className='font-bold'>{data.title}</p>
|
||||
<p>{data.text}</p>
|
||||
<p dangerouslySetInnerHTML={{ __html: convertHTML(data.text) }}></p>
|
||||
</div>
|
||||
{/* <div className='flex max-h-96 bg-black rounded-2xl'>
|
||||
<img className='w-full object-contain' src='/profile-photo.svg'></img>
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import React from 'react'
|
||||
import React, { useContext } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { GSContext } from '../../middlewares/GlobalStore';
|
||||
|
||||
export default function () {
|
||||
const { globalState } = useContext(GSContext);
|
||||
return (
|
||||
<nav className='flex z-50 bg-pc sticky top-0 shadow-md justify-between p-navbar rounded-b-2xl mx-4'>
|
||||
<div>
|
||||
<Link className='font-bold' to={'/'}>BAŞLIK</Link>
|
||||
<Link className='font-bold' to={'/'}>{globalState.title}</Link>
|
||||
</div>
|
||||
<div>
|
||||
<a className='p-2 rounded-lg cursor-pointer hover:bg-white hover:bg-opacity-70 hover:font-bold'>Çıkış Yap</a>
|
||||
|
||||
@ -15,13 +15,13 @@ export default function Notifications() {
|
||||
},[]);
|
||||
|
||||
return (
|
||||
<div className='flex flex-col bg-white rounded-2xl p-1 gap-2 w-full'>
|
||||
<div className='flex flex-col bg-white rounded-2xl p-1 gap-2 w-full h-96'>
|
||||
<div className='flex items-center p-2 justify-between'>
|
||||
<p className='font-bold'>{locale["notifications"]}</p>
|
||||
<p onClick={() => {getNotifications().then(get => globalState.setNotifications(get))}} className='p-2 rounded-lg cursor-pointer hover:bg-pc'>Yenile</p>
|
||||
</div>
|
||||
<hr/>
|
||||
<div className='flex flex-col gap-1'>
|
||||
<div className='flex flex-col gap-1 overflow-hidden overflow-y-scroll'>
|
||||
{
|
||||
globalState.notifications.map((get) =>
|
||||
<Notification key={get.id} data={get} notifications={get}/>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { Link } from 'react-router-dom';
|
||||
import { postFollow, postFollowSvar } from '../../../middlewares/profiles/follow';
|
||||
import { postFollow, postFollowDestroy, postFollowSvar } from '../../../middlewares/profiles/follow';
|
||||
import { GSContext } from '../../../middlewares/GlobalStore';
|
||||
import FollowRight from '../../menus/right/Profile/Follow/FollowRight';
|
||||
|
||||
@ -9,7 +9,7 @@ export default function UserBox({uid="default", user, button = null}) {
|
||||
if(uid === "default"){
|
||||
return (
|
||||
<div className='flex items-center justify-between w-full border-solid border-b-2 p-2'>
|
||||
<div to={"/profile/" + user.username} onClick={() => {globalState.states.setRightMenu(<FollowRight profile={user}/>)}} className='flex items-center gap-2 cursor-pointer'>
|
||||
<div to={"/profile/" + user.username} onClick={() => {globalState.states.setRightMenu(<FollowRight username={user.username}/>)}} className='flex items-center gap-2 cursor-pointer'>
|
||||
{/* <div className='flex h-16 aspect-square'>
|
||||
<img className='aspect-square' src='/profile-photo.svg'></img>
|
||||
</div> */}
|
||||
@ -19,7 +19,7 @@ export default function UserBox({uid="default", user, button = null}) {
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex'>
|
||||
<a onClick={(e) => postFollow(e, user.id)} className='cursor-pointer p-2 rounded-lg ml-auto hover:bg-pc'>{button.text}</a>
|
||||
<a onClick={(e) => {return (button.isDestroy === true) ? postFollowDestroy(e, user.id) : postFollow(e, user.id) }} className='cursor-pointer p-2 rounded-lg ml-auto hover:bg-pc'>{button.text}</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
6
src/middlewares/general/Text.jsx
Normal file
6
src/middlewares/general/Text.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react'
|
||||
|
||||
export function convertHTML(text) {
|
||||
const splitText = text.replaceAll("\n", "<br>");
|
||||
return splitText;
|
||||
};
|
||||
@ -43,6 +43,28 @@ export function postFollowSvar(e, userId, svar){
|
||||
.then(res => console.log(res));
|
||||
}
|
||||
|
||||
export function postFollowDestroy(e, userId){
|
||||
return 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 => {
|
||||
e.target.remove();
|
||||
console.log(e.target.parent);
|
||||
// e.target.text = res.follow.title;
|
||||
});
|
||||
};
|
||||
|
||||
export function getFollow(username){
|
||||
return FetchPOST({
|
||||
port: 3001,
|
||||
|
||||
@ -14,3 +14,10 @@ export async function getProfile(port, username, setProfile, setLoading) {
|
||||
]);
|
||||
return data;
|
||||
};
|
||||
|
||||
export async function getProfileDetails(port, username) {
|
||||
return FetchPOST({
|
||||
port: port,
|
||||
pathname: "/get/user/details/" + username
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user