Düzenlemeler ve hata giderme

This commit is contained in:
batuhancoskun 2025-06-13 21:37:18 +03:00
parent dc772c89d5
commit eb4f02238d
12 changed files with 65 additions and 17 deletions

View File

@ -20,6 +20,7 @@ export default function App() {
const [popup, setPopup] = useState(""); const [popup, setPopup] = useState("");
const globalState = { const globalState = {
title: "Arslanşah",
states: { states: {
rightMenu, setRightMenu, leftMenu, setLeftMenu, popup, setPopup rightMenu, setRightMenu, leftMenu, setLeftMenu, popup, setPopup
} }

View File

@ -2,17 +2,22 @@ import React, { useContext, useEffect, useState } from 'react'
import { GSContext } from '../../../../../middlewares/GlobalStore'; import { GSContext } from '../../../../../middlewares/GlobalStore';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { I18nContext } from '../../../../../middlewares/Locale'; 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 { globalState } = useContext(GSContext);
const { locale } = useContext(I18nContext); const { locale } = useContext(I18nContext);
const [profileKeys, setProfileKeys] = useState(); const [profileKeys, setProfileKeys] = useState();
const [profile, setProfile] = useState();
useEffect(()=>{ useEffect(()=>{
if(profile){ if(username){
setProfileKeys(Object.keys(profile)); getProfileDetails(3001, username).then(res => {
setProfile(res);
setProfileKeys(Object.keys(res));
});
}; };
},[profile]); },[username]);
if(profile){ if(profile){

View File

@ -8,7 +8,6 @@ export default function ProfileMenuBox() {
useEffect(()=>{ useEffect(()=>{
setLoading(false); setLoading(false);
console.log(globalState, 567891);
},[]); },[]);
if(loading === true){ if(loading === true){
@ -16,7 +15,7 @@ export default function ProfileMenuBox() {
}else{ }else{
return ( return (
<Link to={`/profile/${globalState.user.username}/posts`} className={'flex h-24 w-full p-2 gap-2 bg-white rounded-2xl shadow-lg'}> <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 className='flex flex-col items-center justify-center gap-1'>
<div> <div>
<p className='font-bold text-sm'>{globalState.user.first_name} {globalState.user.second_name}</p> <p className='font-bold text-sm'>{globalState.user.first_name} {globalState.user.second_name}</p>

View File

@ -9,8 +9,11 @@ export default function PostSave({data, localeCode}) {
<div className='flex gap-1 justify-between'> <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 justify-center rounded-full m-1 aspect-square bg-pc'/> */}
<div className='flex items-center gap-1'> <div className='flex items-center gap-1'>
<Link to={data.user.href} className='font-bold'>{data.user.name}</Link> <p>
<Link to={data.blog.href} className=''>{locale[localeCode]}.</Link> <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>
<div className='flex items-center'> <div className='flex items-center'>
<p>{data.datetime.createdAt.differance[data.datetime.createdAt.differance.current]} {locale[data.datetime.createdAt.differance.current]}</p> <p>{data.datetime.createdAt.differance[data.datetime.createdAt.differance.current]} {locale[data.datetime.createdAt.differance.current]}</p>

View File

@ -6,7 +6,7 @@ import FollowRight from '../../menus/right/Profile/Follow/FollowRight';
export default function User({people}) { export default function User({people}) {
const {globalState} = useContext(GSContext); const {globalState} = useContext(GSContext);
return ( 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.first_name} {people.second_name}</p>
<p>@{people.username}</p> <p>@{people.username}</p>
</div> </div>

View File

@ -8,10 +8,13 @@ import PostComments from './PostComments';
import { openPopup, renderPopup } from '../../../middlewares/popups/popup'; import { openPopup, renderPopup } from '../../../middlewares/popups/popup';
import { GSContext } from '../../../middlewares/GlobalStore'; import { GSContext } from '../../../middlewares/GlobalStore';
import Popup from '../../popup/Popup'; import Popup from '../../popup/Popup';
import { convertHTML } from '../../../middlewares/general/Text';
export default function Post({data}) { export default function Post({data}) {
const {globalState} = useContext(GSContext); const {globalState} = useContext(GSContext);
console.log();
if(data.reblog === true){ if(data.reblog === true){
return ( return (
<div key={data.id} className='flex bg-white rounded-2xl overflow-hidden w-full'> <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>
<div> <div>
<p className='font-bold'>{data.title}</p> <p className='font-bold'>{data.title}</p>
<p>{data.text}</p> <p dangerouslySetInnerHTML={{ __html: convertHTML(data.text) }}></p>
</div> </div>
{/* <div className='flex max-h-96 bg-black rounded-2xl'> {/* <div className='flex max-h-96 bg-black rounded-2xl'>
<img className='w-full object-contain' src='/profile-photo.svg'></img> <img className='w-full object-contain' src='/profile-photo.svg'></img>

View File

@ -1,11 +1,13 @@
import React from 'react' import React, { useContext } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { GSContext } from '../../middlewares/GlobalStore';
export default function () { export default function () {
const { globalState } = useContext(GSContext);
return ( return (
<nav className='flex z-50 bg-pc sticky top-0 shadow-md justify-between p-navbar rounded-b-2xl mx-4'> <nav className='flex z-50 bg-pc sticky top-0 shadow-md justify-between p-navbar rounded-b-2xl mx-4'>
<div> <div>
<Link className='font-bold' to={'/'}>BAŞLIK</Link> <Link className='font-bold' to={'/'}>{globalState.title}</Link>
</div> </div>
<div> <div>
<a className='p-2 rounded-lg cursor-pointer hover:bg-white hover:bg-opacity-70 hover:font-bold'>Çıkış Yap</a> <a className='p-2 rounded-lg cursor-pointer hover:bg-white hover:bg-opacity-70 hover:font-bold'>Çıkış Yap</a>

View File

@ -15,13 +15,13 @@ export default function Notifications() {
},[]); },[]);
return ( 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'> <div className='flex items-center p-2 justify-between'>
<p className='font-bold'>{locale["notifications"]}</p> <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> <p onClick={() => {getNotifications().then(get => globalState.setNotifications(get))}} className='p-2 rounded-lg cursor-pointer hover:bg-pc'>Yenile</p>
</div> </div>
<hr/> <hr/>
<div className='flex flex-col gap-1'> <div className='flex flex-col gap-1 overflow-hidden overflow-y-scroll'>
{ {
globalState.notifications.map((get) => globalState.notifications.map((get) =>
<Notification key={get.id} data={get} notifications={get}/> <Notification key={get.id} data={get} notifications={get}/>

View File

@ -1,6 +1,6 @@
import React, { useContext } from 'react' import React, { useContext } from 'react'
import { Link } from 'react-router-dom'; 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 { GSContext } from '../../../middlewares/GlobalStore';
import FollowRight from '../../menus/right/Profile/Follow/FollowRight'; import FollowRight from '../../menus/right/Profile/Follow/FollowRight';
@ -9,7 +9,7 @@ export default function UserBox({uid="default", user, button = null}) {
if(uid === "default"){ if(uid === "default"){
return ( return (
<div className='flex items-center justify-between w-full border-solid border-b-2 p-2'> <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'> {/* <div className='flex h-16 aspect-square'>
<img className='aspect-square' src='/profile-photo.svg'></img> <img className='aspect-square' src='/profile-photo.svg'></img>
</div> */} </div> */}
@ -19,7 +19,7 @@ export default function UserBox({uid="default", user, button = null}) {
</div> </div>
</div> </div>
<div className='flex'> <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>
</div> </div>
); );

View File

@ -0,0 +1,6 @@
import React from 'react'
export function convertHTML(text) {
const splitText = text.replaceAll("\n", "<br>");
return splitText;
};

View File

@ -43,6 +43,28 @@ export function postFollowSvar(e, userId, svar){
.then(res => console.log(res)); .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){ export function getFollow(username){
return FetchPOST({ return FetchPOST({
port: 3001, port: 3001,

View File

@ -14,3 +14,10 @@ export async function getProfile(port, username, setProfile, setLoading) {
]); ]);
return data; return data;
}; };
export async function getProfileDetails(port, username) {
return FetchPOST({
port: port,
pathname: "/get/user/details/" + username
});
};