import React, { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Calendar as CalendarIcon, ChevronLeft, ChevronRight, Plus, Clock, Layers, Image, FileText, Video, Filter, Settings, Sparkles, Check, X, GripVertical } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Calendar } from '@/components/ui/calendar'; import { Checkbox } from '@/components/ui/checkbox'; import { Label } from '@/components/ui/label'; import { Slider } from '@/components/ui/slider'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; import { format, addDays, startOfWeek, endOfWeek, eachDayOfInterval, isSameDay, isToday } from 'date-fns'; import { Link } from 'react-router-dom'; import { createPageUrl } from '@/utils'; const products = [ { id: 'ocr', name: 'Document Parsing (OCR)', shortName: 'OCR', color: 'blue' }, { id: 'p2p', name: 'Purchase To Pay', shortName: 'P2P', color: 'emerald', subCategories: ['Budget Approval', 'Purchase Request', 'Accounts Payable'] }, { id: 'o2c', name: 'Order to Cash', shortName: 'O2C', color: 'violet', subCategories: ['Quotation', 'Sales Order', 'PickSlip Delivery', 'Accounts Receivable'] }, ]; const postTypes = [ { id: 'carousel', name: 'Carousel', icon: Layers, description: 'Multi-slide visual story' }, { id: 'cover_content', name: 'Cover Image + Content', icon: Image, description: 'Featured image with text' }, { id: 'content_only', name: 'Content Only', icon: FileText, description: 'Text-based post' }, { id: 'webinar', name: 'Webinar Invite', icon: Video, description: 'Event promotion' }, ]; const scheduledPosts = [ { id: 1, title: 'OCR Automation Benefits', type: 'carousel', product: 'ocr', time: '10:00 AM', date: new Date(), status: 'scheduled' }, { id: 2, title: 'P2P Efficiency Guide', type: 'cover_content', product: 'p2p', time: '2:00 PM', date: new Date(), status: 'draft' }, { id: 3, title: 'O2C Webinar', type: 'webinar', product: 'o2c', time: '11:00 AM', date: addDays(new Date(), 1), status: 'scheduled' }, { id: 4, title: 'Invoice Processing Tips', type: 'content_only', product: 'ocr', time: '3:00 PM', date: addDays(new Date(), 1), status: 'scheduled' }, { id: 5, title: 'Budget Approval Flow', type: 'carousel', product: 'p2p', time: '9:00 AM', date: addDays(new Date(), 2), status: 'scheduled' }, { id: 6, title: 'Sales Order Demo', type: 'cover_content', product: 'o2c', time: '1:00 PM', date: addDays(new Date(), 3), status: 'draft' }, ]; export default function Scheduler() { const [selectedDate, setSelectedDate] = useState(new Date()); const [currentWeekStart, setCurrentWeekStart] = useState(startOfWeek(new Date(), { weekStartsOn: 1 })); const [campaignDialogOpen, setCampaignDialogOpen] = useState(false); const [selectedProducts, setSelectedProducts] = useState(['ocr', 'p2p', 'o2c']); const [selectedPostTypes, setSelectedPostTypes] = useState(['carousel', 'cover_content']); const [dateRange, setDateRange] = useState({ from: new Date(), to: addDays(new Date(), 30) }); const [postsPerWeek, setPostsPerWeek] = useState([5]); const weekDays = eachDayOfInterval({ start: currentWeekStart, end: endOfWeek(currentWeekStart, { weekStartsOn: 1 }) }); const navigateWeek = (direction) => { setCurrentWeekStart(prev => addDays(prev, direction === 'next' ? 7 : -7)); }; const getPostsForDate = (date) => { return scheduledPosts.filter(post => isSameDay(post.date, date)); }; const getProductColor = (productId) => { const product = products.find(p => p.id === productId); return product?.color || 'slate'; }; const getPostTypeIcon = (typeId) => { const type = postTypes.find(t => t.id === typeId); return type?.icon || FileText; }; const toggleProduct = (productId) => { setSelectedProducts(prev => prev.includes(productId) ? prev.filter(id => id !== productId) : [...prev, productId] ); }; const togglePostType = (typeId) => { setSelectedPostTypes(prev => prev.includes(typeId) ? prev.filter(id => id !== typeId) : [...prev, typeId] ); }; return (
{/* Header */}

Content Scheduler

Plan and schedule your LinkedIn content calendar

Configure Campaign
{/* Date Range */}
setDateRange(prev => ({ ...prev, from: date }))} />
setDateRange(prev => ({ ...prev, to: date }))} />
{/* Products to Focus */}
{products.map(product => (
toggleProduct(product.id)} className={`flex items-center gap-3 p-3 rounded-xl border cursor-pointer transition-all ${ selectedProducts.includes(product.id) ? `border-${product.color}-300 bg-${product.color}-50` : 'border-slate-200 hover:border-slate-300' }`} >
{selectedProducts.includes(product.id) ? ( ) : ( )}

{product.name}

{product.subCategories && (

{product.subCategories.join(', ')}

)}
))}
{/* Post Types Mix */}
{postTypes.map(type => (
togglePostType(type.id)} className={`flex items-center gap-3 p-3 rounded-xl border cursor-pointer transition-all ${ selectedPostTypes.includes(type.id) ? 'border-blue-300 bg-blue-50' : 'border-slate-200 hover:border-slate-300' }`} >

{type.name}

{type.description}

))}
{/* Posting Frequency */}
{postsPerWeek[0]}
1 post 14 posts
{/* Calendar Sidebar */} {/* Quick Stats */} This Week
Scheduled 12 posts
Drafts 4 posts
Published 8 posts
{/* Product Filter */} Filter by Product {products.map(product => (
); }