fix: Implémenter fonctionnalité Create Post dans SocialPage

- Remplacer toast placeholder par ouverture du modal CreatePostModal
- Intégrer socialService.createPost pour créer des posts
- Ajouter gestion d'erreurs avec logger
- Le bouton Create Post ouvre maintenant le modal fonctionnel
This commit is contained in:
senke 2026-01-18 13:34:44 +01:00
parent 64265f5438
commit 4e2bf1d60c

View file

@ -2,10 +2,14 @@ import { useState } from 'react';
import { Users, Heart, MessageCircle, Share2, TrendingUp } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { useToast } from '@/hooks/useToast';
import { CreatePostModal } from '@/components/social/CreatePostModal';
import { socialService } from '@/services/socialService';
import { logger } from '@/utils/logger';
export function SocialPage() {
const { toast } = useToast();
const [posts] = useState([
const [showCreateModal, setShowCreateModal] = useState(false);
const [posts, setPosts] = useState([
{
id: 1,
author: 'DJ Nova',
@ -47,9 +51,7 @@ export function SocialPage() {
</div>
<Button
className="bg-kodo-cyan hover:bg-kodo-cyan/80 text-black"
onClick={() =>
toast({ message: 'Post creation coming soon!', type: 'info' })
}
onClick={() => setShowCreateModal(true)}
>
Create Post
</Button>
@ -160,6 +162,31 @@ export function SocialPage() {
Discover Artists
</Button>
</div>
{/* Create Post Modal */}
{showCreateModal && (
<CreatePostModal
onClose={() => setShowCreateModal(false)}
onCreate={async (postData) => {
try {
// FIX: socialService.createPost attend { content, attachments? }
const res = await socialService.createPost({
content: postData.content,
attachments: postData.type !== 'text' ? { type: postData.type } : undefined,
});
setPosts([res.post, ...posts]);
toast.success('Post published successfully');
setShowCreateModal(false);
} catch (error) {
logger.error('Failed to create post', {
error: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined,
});
toast.error('Failed to create post. Please try again.');
}
}}
/>
)}
</div>
);
}