Hr SocialPost interface

This commit is contained in:
Sedat Öztürk 2025-10-28 00:08:36 +03:00
parent 181930905e
commit 0203ffb8b3
9 changed files with 126 additions and 195 deletions

View file

@ -14,19 +14,13 @@ import {
SocialPost, SocialPost,
} from '@/types/intranet' } from '@/types/intranet'
// Mevcut çalışanları kullan - "Siz" kullanıcısı mockEmployees[0] (Ali Öztürk) olacak
const currentUser = { ...mockEmployees[0], fullName: 'Siz' } // Ali Öztürk'ü "Siz" olarak kullan
export const mockSocialPosts: SocialPost[] = [ export const mockSocialPosts: SocialPost[] = [
{ {
id: '1', id: '1',
author: { author: mockEmployees[2], // Mehmet Yılmaz
id: 'user1',
name: 'Ahmet Yılmaz',
avatar: 'https://i.pravatar.cc/150?img=12',
title: 'Yazılım Geliştirici',
email: 'ahmet.yilmaz@sozsoft.com',
phone: '+90 532 123 45 67',
department: 'Yazılım Geliştirme',
location: 'İstanbul, Türkiye',
},
content: content:
'Yeni proje üzerinde çalışıyoruz! React ve TypeScript ile harika bir deneyim oluşturuyoruz. Ekip çalışması harika gidiyor! 🚀', 'Yeni proje üzerinde çalışıyoruz! React ve TypeScript ile harika bir deneyim oluşturuyoruz. Ekip çalışması harika gidiyor! 🚀',
creationTime: new Date('2024-10-15T10:30:00'), creationTime: new Date('2024-10-15T10:30:00'),
@ -45,29 +39,18 @@ export const mockSocialPosts: SocialPost[] = [
likes: { likes: {
count: 24, count: 24,
isLiked: true, isLiked: true,
users: [ users: [mockEmployees[1], mockEmployees[3]], // Ayşe Kaya, Selin Demir
{ id: 'user2', name: 'Ayşe Demir', avatar: 'https://i.pravatar.cc/150?img=5' },
{ id: 'user3', name: 'Mehmet Kaya', avatar: 'https://i.pravatar.cc/150?img=8' },
],
}, },
comments: [ comments: [
{ {
id: 'c1', id: 'c1',
author: { author: mockEmployees[1], // Ayşe Kaya
id: 'user2',
name: 'Ayşe Demir',
avatar: 'https://i.pravatar.cc/150?img=5',
},
content: 'Harika görünüyor! Başarılar 👏', content: 'Harika görünüyor! Başarılar 👏',
creationTime: new Date('2024-10-15T11:00:00'), creationTime: new Date('2024-10-15T11:00:00'),
}, },
{ {
id: 'c2', id: 'c2',
author: { author: mockEmployees[3], // Selin Demir
id: 'user3',
name: 'Mehmet Kaya',
avatar: 'https://i.pravatar.cc/150?img=8',
},
content: 'TypeScript gerçekten fark yaratıyor!', content: 'TypeScript gerçekten fark yaratıyor!',
creationTime: new Date('2024-10-15T11:30:00'), creationTime: new Date('2024-10-15T11:30:00'),
}, },
@ -76,12 +59,7 @@ export const mockSocialPosts: SocialPost[] = [
}, },
{ {
id: '2', id: '2',
author: { author: currentUser,
id: 'currentUser',
name: 'Siz',
avatar: 'https://i.pravatar.cc/150?img=1',
title: 'Proje Yöneticisi',
},
content: content:
'Bu hafta sprint planlamasını yaptık. Ekibimizle birlikte yeni özellikleri değerlendirdik. Heyecan verici bir hafta olacak!', 'Bu hafta sprint planlamasını yaptık. Ekibimizle birlikte yeni özellikleri değerlendirdik. Heyecan verici bir hafta olacak!',
creationTime: new Date('2024-10-16T09:00:00'), creationTime: new Date('2024-10-16T09:00:00'),
@ -108,11 +86,7 @@ export const mockSocialPosts: SocialPost[] = [
comments: [ comments: [
{ {
id: 'c3', id: 'c3',
author: { author: mockEmployees[4], // Ahmet Çelik
id: 'user4',
name: 'Fatma Şahin',
avatar: 'https://i.pravatar.cc/150?img=9',
},
content: 'Mesajlaşma özelliğine kesinlikle ihtiyacımız var!', content: 'Mesajlaşma özelliğine kesinlikle ihtiyacımız var!',
creationTime: new Date('2024-10-16T10:15:00'), creationTime: new Date('2024-10-16T10:15:00'),
}, },
@ -121,12 +95,7 @@ export const mockSocialPosts: SocialPost[] = [
}, },
{ {
id: '3', id: '3',
author: { author: mockEmployees[5], // Zeynep Arslan
id: 'user5',
name: 'Zeynep Arslan',
avatar: 'https://i.pravatar.cc/150?img=10',
title: 'UI/UX Tasarımcı',
},
content: content:
'Yeni tasarım sistemimizin ilk prototipini hazırladık! Kullanıcı deneyimini iyileştirmek için çok çalıştık. Geri bildirimlerinizi bekliyorum! 🎨', 'Yeni tasarım sistemimizin ilk prototipini hazırladık! Kullanıcı deneyimini iyileştirmek için çok çalıştık. Geri bildirimlerinizi bekliyorum! 🎨',
creationTime: new Date('2024-10-17T14:20:00'), creationTime: new Date('2024-10-17T14:20:00'),
@ -141,26 +110,18 @@ export const mockSocialPosts: SocialPost[] = [
likes: { likes: {
count: 42, count: 42,
isLiked: true, isLiked: true,
users: [{ id: 'user1', name: 'Ahmet Yılmaz', avatar: 'https://i.pravatar.cc/150?img=12' }], users: [mockEmployees[2]], // Mehmet Yılmaz
}, },
comments: [ comments: [
{ {
id: 'c4', id: 'c4',
author: { author: mockEmployees[6], // Burak Koç
id: 'user6',
name: 'Can Öztürk',
avatar: 'https://i.pravatar.cc/150?img=11',
},
content: 'Tasarımlar çok şık! Renk paleti özellikle güzel 😍', content: 'Tasarımlar çok şık! Renk paleti özellikle güzel 😍',
creationTime: new Date('2024-10-17T15:00:00'), creationTime: new Date('2024-10-17T15:00:00'),
}, },
{ {
id: 'c5', id: 'c5',
author: { author: mockEmployees[7], // Elif Şahin
id: 'user7',
name: 'Elif Yıldız',
avatar: 'https://i.pravatar.cc/150?img=20',
},
content: 'Dark mode opsiyonu da olacak mı?', content: 'Dark mode opsiyonu da olacak mı?',
creationTime: new Date('2024-10-17T15:30:00'), creationTime: new Date('2024-10-17T15:30:00'),
}, },
@ -169,12 +130,7 @@ export const mockSocialPosts: SocialPost[] = [
}, },
{ {
id: '4', id: '4',
author: { author: mockEmployees[6], // Burak Koç
id: 'user8',
name: 'Burak Çelik',
avatar: 'https://i.pravatar.cc/150?img=13',
title: 'DevOps Mühendisi',
},
content: content:
'CI/CD pipeline güncellememiz tamamlandı! Deployment süremiz %40 azaldı. Otomasyonun gücü 💪', 'CI/CD pipeline güncellememiz tamamlandı! Deployment süremiz %40 azaldı. Otomasyonun gücü 💪',
creationTime: new Date('2024-10-18T08:45:00'), creationTime: new Date('2024-10-18T08:45:00'),
@ -190,11 +146,7 @@ export const mockSocialPosts: SocialPost[] = [
comments: [ comments: [
{ {
id: 'c6', id: 'c6',
author: { author: mockEmployees[8], // Canan Öztürk
id: 'user9',
name: 'Deniz Koç',
avatar: 'https://i.pravatar.cc/150?img=14',
},
content: 'Harika iş! Detayları paylaşabilir misin?', content: 'Harika iş! Detayları paylaşabilir misin?',
creationTime: new Date('2024-10-18T09:15:00'), creationTime: new Date('2024-10-18T09:15:00'),
}, },
@ -203,12 +155,7 @@ export const mockSocialPosts: SocialPost[] = [
}, },
{ {
id: '5', id: '5',
author: { author: mockEmployees[7], // Elif Şahin
id: 'user10',
name: 'Selin Aydın',
avatar: 'https://i.pravatar.cc/150?img=15',
title: 'İK Müdürü',
},
content: content:
'Ekip üyelerimize yeni eğitim programımızı duyurmak istiyorum! 🎓 React, TypeScript ve Modern Web Geliştirme konularında kapsamlı bir program hazırladık.', 'Ekip üyelerimize yeni eğitim programımızı duyurmak istiyorum! 🎓 React, TypeScript ve Modern Web Geliştirme konularında kapsamlı bir program hazırladık.',
creationTime: new Date('2024-10-14T16:00:00'), creationTime: new Date('2024-10-14T16:00:00'),
@ -220,21 +167,13 @@ export const mockSocialPosts: SocialPost[] = [
comments: [ comments: [
{ {
id: 'c7', id: 'c7',
author: { author: mockEmployees[2], // Mehmet Yılmaz
id: 'user1',
name: 'Ahmet Yılmaz',
avatar: 'https://i.pravatar.cc/150?img=12',
},
content: 'Ne zaman başlıyor?', content: 'Ne zaman başlıyor?',
creationTime: new Date('2024-10-14T16:30:00'), creationTime: new Date('2024-10-14T16:30:00'),
}, },
{ {
id: 'c8', id: 'c8',
author: { author: mockEmployees[7], // Elif Şahin
id: 'user10',
name: 'Selin Aydın',
avatar: 'https://i.pravatar.cc/150?img=15',
},
content: 'Gelecek hafta başlıyoruz! Kayıt linki mail ile paylaşılacak.', content: 'Gelecek hafta başlıyoruz! Kayıt linki mail ile paylaşılacak.',
creationTime: new Date('2024-10-14T17:00:00'), creationTime: new Date('2024-10-14T17:00:00'),
}, },
@ -243,12 +182,7 @@ export const mockSocialPosts: SocialPost[] = [
}, },
{ {
id: '6', id: '6',
author: { author: mockEmployees[9], // Murat Aydın
id: 'user11',
name: 'Deniz Öztürk',
avatar: 'https://i.pravatar.cc/150?img=20',
title: 'Proje Yöneticisi',
},
content: 'Bugün müşteri ile harika bir toplantı yaptık! Yeni projenin detaylarını konuştuk. 🎯', content: 'Bugün müşteri ile harika bir toplantı yaptık! Yeni projenin detaylarını konuştuk. 🎯',
creationTime: new Date('2024-10-17T14:00:00'), creationTime: new Date('2024-10-17T14:00:00'),
location: { location: {

View file

@ -232,77 +232,49 @@ export interface Visitor {
photo?: string photo?: string
} }
// Sosyal Duvar // Sosyal Duvar - Comment Interface
export interface SocialPost { export interface SocialComment {
id: string id: string
author: { author: HrEmployee
id: string
name: string
avatar: string
title: string
email?: string
phone?: string
department?: string
location?: string
}
content: string content: string
creationTime: Date creationTime: Date
location?: {
id: string
name: string
address: string
lat: number
lng: number
placeId?: string
} }
media?: {
type: 'image' | 'video' | 'poll' // Sosyal Duvar - Likes Interface
url?: string export interface SocialLikes {
urls?: string[] count: number
poll?: { isLiked: boolean
question: string users: HrEmployee[]
options: Array<{ }
// Sosyal Duvar - Poll Option Interface
export interface SocialPollOption {
id: string id: string
text: string text: string
votes: number votes: number
}> }
// Sosyal Duvar - Poll Interface
export interface SocialPoll {
question: string
options: SocialPollOption[]
totalVotes: number totalVotes: number
endsAt: Date endsAt: Date
userVote?: string userVote?: string
} }
}
likes: {
count: number
isLiked: boolean
users: Array<{ id: string; name: string; avatar: string }>
}
comments: Array<{
id: string
author: {
id: string
name: string
avatar: string
}
content: string
creationTime: Date
}>
isOwnPost: boolean
}
export interface MediaItem { // Unified Media interface for all media-related operations
id: string export interface SocialMedia {
type: 'image' | 'video' id?: string
url: string type: 'image' | 'video' | 'poll'
file?: File
}
export interface LightboxMedia {
type: 'image' | 'video'
url?: string url?: string
urls?: string[] urls?: string[]
file?: File
poll?: SocialPoll
} }
export interface Location { // Sosyal Duvar - Social Location
export interface SocialLocation {
id: string id: string
name: string name: string
address: string address: string
@ -310,3 +282,16 @@ export interface Location {
lng: number lng: number
placeId?: string placeId?: string
} }
// Sosyal Duvar - Ana Interface
export interface SocialPost {
id: string
author: HrEmployee
content: string
creationTime: Date
location?: SocialLocation
media?: SocialMedia
likes: SocialLikes
comments: SocialComment[]
isOwnPost: boolean
}

View file

@ -11,15 +11,15 @@ import {
} from 'react-icons/fa' } from 'react-icons/fa'
import MediaManager from './MediaManager' import MediaManager from './MediaManager'
import LocationPicker from './LocationPicker' import LocationPicker from './LocationPicker'
import { Location, MediaItem } from '@/types/intranet' import { SocialLocation, SocialMedia } from '@/types/intranet'
interface CreatePostProps { interface CreatePostProps {
onCreatePost: (post: { onCreatePost: (post: {
content: string content: string
location?: Location location?: SocialLocation
media?: { media?: {
type: 'mixed' | 'poll' type: 'mixed' | 'poll'
mediaItems?: MediaItem[] mediaItems?: SocialMedia[]
poll?: { poll?: {
question: string question: string
options: Array<{ text: string }> options: Array<{ text: string }>
@ -31,8 +31,8 @@ interface CreatePostProps {
const CreatePost: React.FC<CreatePostProps> = ({ onCreatePost }) => { const CreatePost: React.FC<CreatePostProps> = ({ onCreatePost }) => {
const [content, setContent] = useState('') const [content, setContent] = useState('')
const [mediaType, setMediaType] = useState<'media' | 'poll' | null>(null) const [mediaType, setMediaType] = useState<'media' | 'poll' | null>(null)
const [mediaItems, setMediaItems] = useState<MediaItem[]>([]) const [mediaItems, setMediaItems] = useState<SocialMedia[]>([])
const [location, setLocation] = useState<Location | null>(null) const [location, setLocation] = useState<SocialLocation | null>(null)
const [pollQuestion, setPollQuestion] = useState('') const [pollQuestion, setPollQuestion] = useState('')
const [pollOptions, setPollOptions] = useState(['', '']) const [pollOptions, setPollOptions] = useState(['', ''])
const [isExpanded, setIsExpanded] = useState(false) const [isExpanded, setIsExpanded] = useState(false)
@ -126,7 +126,8 @@ const CreatePost: React.FC<CreatePostProps> = ({ onCreatePost }) => {
setPollOptions(['', '']) setPollOptions(['', ''])
} }
const removeMediaItem = (id: string) => { const removeMediaItem = (id: string | undefined) => {
if (!id) return
setMediaItems(mediaItems.filter((m) => m.id !== id)) setMediaItems(mediaItems.filter((m) => m.id !== id))
} }

View file

@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import { FaExternalLinkAlt, FaMapMarkerAlt } from 'react-icons/fa' import { FaExternalLinkAlt, FaMapMarkerAlt } from 'react-icons/fa'
import { Location } from '@/types/intranet' import { SocialLocation } from '@/types/intranet'
interface LocationMapProps { interface LocationMapProps {
location: Location location: SocialLocation
className?: string className?: string
showDirections?: boolean showDirections?: boolean
} }

View file

@ -2,10 +2,10 @@ import React, { useState, useEffect, useRef } from 'react'
import { motion } from 'framer-motion' import { motion } from 'framer-motion'
import { FaTimes, FaSearch, FaMapMarkerAlt } from 'react-icons/fa' import { FaTimes, FaSearch, FaMapMarkerAlt } from 'react-icons/fa'
import classNames from 'classnames' import classNames from 'classnames'
import { Location } from '@/types/intranet' import { SocialLocation } from '@/types/intranet'
interface LocationPickerProps { interface LocationPickerProps {
onSelect: (location: Location) => void onSelect: (location: SocialLocation) => void
onClose: () => void onClose: () => void
} }
@ -21,8 +21,8 @@ declare global {
const LocationPicker: React.FC<LocationPickerProps> = ({ onSelect, onClose }) => { const LocationPicker: React.FC<LocationPickerProps> = ({ onSelect, onClose }) => {
const [searchQuery, setSearchQuery] = useState('') const [searchQuery, setSearchQuery] = useState('')
const [locations, setLocations] = useState<Location[]>([]) const [locations, setLocations] = useState<SocialLocation[]>([])
const [selectedLocation, setSelectedLocation] = useState<Location | null>(null) const [selectedLocation, setSelectedLocation] = useState<SocialLocation | null>(null)
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState<string | null>(null) const [error, setError] = useState<string | null>(null)
const [isGoogleLoaded, setIsGoogleLoaded] = useState(false) const [isGoogleLoaded, setIsGoogleLoaded] = useState(false)
@ -146,7 +146,7 @@ const LocationPicker: React.FC<LocationPickerProps> = ({ onSelect, onClose }) =>
} }
// Her bir prediction için detaylı bilgi al // Her bir prediction için detaylı bilgi al
const detailedLocations: Location[] = [] const detailedLocations: SocialLocation[] = []
let completed = 0 let completed = 0
predictions.forEach((prediction: any) => { predictions.forEach((prediction: any) => {
@ -193,7 +193,7 @@ const LocationPicker: React.FC<LocationPickerProps> = ({ onSelect, onClose }) =>
} }
}, [searchQuery, isGoogleLoaded]) }, [searchQuery, isGoogleLoaded])
const handleSelect = (location: Location) => { const handleSelect = (location: SocialLocation) => {
setSelectedLocation(location) setSelectedLocation(location)
} }

View file

@ -5,12 +5,12 @@ import Video from 'yet-another-react-lightbox/plugins/video'
import Zoom from 'yet-another-react-lightbox/plugins/zoom' import Zoom from 'yet-another-react-lightbox/plugins/zoom'
import Counter from 'yet-another-react-lightbox/plugins/counter' import Counter from 'yet-another-react-lightbox/plugins/counter'
import 'yet-another-react-lightbox/plugins/counter.css' import 'yet-another-react-lightbox/plugins/counter.css'
import { LightboxMedia } from '@/types/intranet' import { SocialMedia } from '@/types/intranet'
interface MediaLightboxProps { interface MediaLightboxProps {
isOpen: boolean isOpen: boolean
onClose: () => void onClose: () => void
media: LightboxMedia media: SocialMedia
startIndex?: number startIndex?: number
} }

View file

@ -2,11 +2,11 @@ import React, { useState } from 'react'
import { motion } from 'framer-motion' import { motion } from 'framer-motion'
import { FaTimes, FaLink, FaUpload } from 'react-icons/fa' import { FaTimes, FaLink, FaUpload } from 'react-icons/fa'
import classNames from 'classnames' import classNames from 'classnames'
import { MediaItem } from '@/types/intranet' import { SocialMedia } from '@/types/intranet'
interface MediaManagerProps { interface MediaManagerProps {
media: MediaItem[] media: SocialMedia[]
onChange: (media: MediaItem[]) => void onChange: (media: SocialMedia[]) => void
onClose: () => void onClose: () => void
} }
@ -19,7 +19,7 @@ const MediaManager: React.FC<MediaManagerProps> = ({ media, onChange, onClose })
const files = e.target.files const files = e.target.files
if (!files) return if (!files) return
const newMedia: MediaItem[] = Array.from(files).map((file) => ({ const newMedia: SocialMedia[] = Array.from(files).map((file) => ({
id: Math.random().toString(36).substr(2, 9), id: Math.random().toString(36).substr(2, 9),
type: file.type.startsWith('video/') ? 'video' : 'image', type: file.type.startsWith('video/') ? 'video' : 'image',
url: URL.createObjectURL(file), url: URL.createObjectURL(file),
@ -33,7 +33,7 @@ const MediaManager: React.FC<MediaManagerProps> = ({ media, onChange, onClose })
const handleUrlAdd = () => { const handleUrlAdd = () => {
if (!urlInput.trim()) return if (!urlInput.trim()) return
const newMedia: MediaItem = { const newMedia: SocialMedia = {
id: Math.random().toString(36).substr(2, 9), id: Math.random().toString(36).substr(2, 9),
type: mediaType, type: mediaType,
url: urlInput url: urlInput
@ -43,7 +43,8 @@ const MediaManager: React.FC<MediaManagerProps> = ({ media, onChange, onClose })
setUrlInput('') setUrlInput('')
} }
const removeMedia = (id: string) => { const removeMedia = (id: string | undefined) => {
if (!id) return
onChange(media.filter((m) => m.id !== id)) onChange(media.filter((m) => m.id !== id))
} }

View file

@ -281,22 +281,34 @@ const PostItem: React.FC<PostItemProps> = ({ post, onLike, onComment, onDelete,
onMouseLeave={() => setShowUserCard(false)} onMouseLeave={() => setShowUserCard(false)}
> >
<img <img
src={post.author.avatar} src={post.author.avatar || 'https://i.pravatar.cc/150?img=1'}
alt={post.author.name} alt={post.author.fullName}
className="w-12 h-12 rounded-full object-cover cursor-pointer ring-2 ring-transparent hover:ring-blue-500 transition-all" className="w-12 h-12 rounded-full object-cover cursor-pointer ring-2 ring-transparent hover:ring-blue-500 transition-all"
/> />
<AnimatePresence> <AnimatePresence>
{showUserCard && ( {showUserCard && (
<UserProfileCard user={post.author} position="bottom" /> <UserProfileCard
user={{
id: post.author.id,
name: post.author.fullName,
avatar: post.author.avatar || 'https://i.pravatar.cc/150?img=1',
title: post.author.jobPosition?.name || 'Çalışan',
email: post.author.email,
phone: post.author.phone,
department: post.author.department?.name,
location: post.author.workLocation
}}
position="bottom"
/>
)} )}
</AnimatePresence> </AnimatePresence>
</div> </div>
<div> <div>
<h3 className="font-semibold text-gray-900 dark:text-gray-100"> <h3 className="font-semibold text-gray-900 dark:text-gray-100">
{post.author.name} {post.author.fullName}
</h3> </h3>
<p className="text-sm text-gray-600 dark:text-gray-400"> <p className="text-sm text-gray-600 dark:text-gray-400">
{post.author.title} {dayjs(post.creationTime).fromNow()} {post.author.jobPosition?.name || 'Çalışan'} {dayjs(post.creationTime).fromNow()}
</p> </p>
</div> </div>
</div> </div>
@ -391,8 +403,8 @@ const PostItem: React.FC<PostItemProps> = ({ post, onLike, onComment, onDelete,
onMouseLeave={() => setHoveredCommentAuthor(null)} onMouseLeave={() => setHoveredCommentAuthor(null)}
> >
<img <img
src={comment.author.avatar} src={comment.author.avatar || 'https://i.pravatar.cc/150?img=1'}
alt={comment.author.name} alt={comment.author.fullName}
className="w-8 h-8 rounded-full object-cover cursor-pointer ring-2 ring-transparent hover:ring-blue-500 transition-all" className="w-8 h-8 rounded-full object-cover cursor-pointer ring-2 ring-transparent hover:ring-blue-500 transition-all"
/> />
<AnimatePresence> <AnimatePresence>
@ -400,9 +412,9 @@ const PostItem: React.FC<PostItemProps> = ({ post, onLike, onComment, onDelete,
<UserProfileCard <UserProfileCard
user={{ user={{
id: comment.author.id, id: comment.author.id,
name: comment.author.name, name: comment.author.fullName,
avatar: comment.author.avatar, avatar: comment.author.avatar || 'https://i.pravatar.cc/150?img=1',
title: 'Çalışan' // Default title for comments title: comment.author.jobPosition?.name || 'Çalışan'
}} }}
position="bottom" position="bottom"
/> />
@ -412,7 +424,7 @@ const PostItem: React.FC<PostItemProps> = ({ post, onLike, onComment, onDelete,
<div className="flex-1"> <div className="flex-1">
<div className="bg-gray-100 dark:bg-gray-700 rounded-lg px-4 py-2"> <div className="bg-gray-100 dark:bg-gray-700 rounded-lg px-4 py-2">
<h4 className="font-semibold text-sm text-gray-900 dark:text-gray-100"> <h4 className="font-semibold text-sm text-gray-900 dark:text-gray-100">
{comment.author.name} {comment.author.fullName}
</h4> </h4>
<p className="text-sm text-gray-800 dark:text-gray-200">{comment.content}</p> <p className="text-sm text-gray-800 dark:text-gray-200">{comment.content}</p>
</div> </div>

View file

@ -1,21 +1,26 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import { AnimatePresence } from 'framer-motion' import { AnimatePresence } from 'framer-motion'
import PostItem from './PostItem' import PostItem from './PostItem'
import { MediaItem } from './MediaManager' import { SocialMedia } from '@/types/intranet'
import CreatePost from './CreatePost' import CreatePost from './CreatePost'
import { Location, SocialPost } from '@/types/intranet' import { SocialLocation, SocialPost } from '@/types/intranet'
import { HrEmployee } from '@/types/hr'
import { mockSocialPosts } from '@/mocks/mockIntranet' import { mockSocialPosts } from '@/mocks/mockIntranet'
import { mockEmployees } from '@/mocks/mockEmployees'
const SocialWall: React.FC = () => { const SocialWall: React.FC = () => {
const [posts, setPosts] = useState<SocialPost[]>(mockSocialPosts) const [posts, setPosts] = useState<SocialPost[]>(mockSocialPosts)
const [filter, setFilter] = useState<'all' | 'mine'>('all') const [filter, setFilter] = useState<'all' | 'mine'>('all')
// Ali Öztürk'ü "Siz" kullanıcısı olarak kullan
const currentUserAuthor: HrEmployee = { ...mockEmployees[0], fullName: 'Siz' }
const handleCreatePost = (postData: { const handleCreatePost = (postData: {
content: string content: string
location?: Location location?: SocialLocation
media?: { media?: {
type: 'mixed' | 'poll' type: 'mixed' | 'poll'
mediaItems?: MediaItem[] mediaItems?: SocialMedia[]
poll?: { poll?: {
question: string question: string
options: Array<{ text: string }> options: Array<{ text: string }>
@ -33,7 +38,7 @@ const SocialWall: React.FC = () => {
if (images.length > 0 && videos.length === 0) { if (images.length > 0 && videos.length === 0) {
mediaForPost = { mediaForPost = {
type: 'image' as const, type: 'image' as const,
urls: images.map(i => i.url) urls: images.map(i => i.url).filter(url => url !== undefined) as string[]
} }
} else if (videos.length > 0 && images.length === 0) { } else if (videos.length > 0 && images.length === 0) {
mediaForPost = { mediaForPost = {
@ -44,7 +49,7 @@ const SocialWall: React.FC = () => {
// Mixed media - use first image for now // Mixed media - use first image for now
mediaForPost = { mediaForPost = {
type: 'image' as const, type: 'image' as const,
urls: images.map(i => i.url) urls: images.map(i => i.url).filter(url => url !== undefined) as string[]
} }
} }
} else if (postData.media.type === 'poll' && postData.media.poll) { } else if (postData.media.type === 'poll' && postData.media.poll) {
@ -66,12 +71,7 @@ const SocialWall: React.FC = () => {
const newPost: SocialPost = { const newPost: SocialPost = {
id: Date.now().toString(), id: Date.now().toString(),
author: { author: currentUserAuthor,
id: 'currentUser',
name: 'Siz',
avatar: 'https://i.pravatar.cc/150?img=1',
title: 'Çalışan'
},
content: postData.content, content: postData.content,
creationTime: new Date(), creationTime: new Date(),
media: mediaForPost, media: mediaForPost,
@ -110,13 +110,11 @@ const SocialWall: React.FC = () => {
setPosts( setPosts(
posts.map((post) => { posts.map((post) => {
if (post.id === postId) { if (post.id === postId) {
const commentAuthor = currentUserAuthor
const newComment = { const newComment = {
id: Date.now().toString(), id: Date.now().toString(),
author: { author: commentAuthor,
id: 'currentUser',
name: 'Siz',
avatar: 'https://i.pravatar.cc/150?img=1'
},
content, content,
creationTime: new Date() creationTime: new Date()
} }