224 lines
8.1 KiB
JavaScript
224 lines
8.1 KiB
JavaScript
import React, { createContext, useContext, useState } from 'react'
|
|
|
|
const AdminPanelContext = createContext()
|
|
|
|
export const useAdminPanel = () => {
|
|
const context = useContext(AdminPanelContext)
|
|
if (!context) {
|
|
throw new Error('useAdminPanel must be used within AdminPanelProvider')
|
|
}
|
|
return context
|
|
}
|
|
|
|
export const AdminPanelProvider = ({ children }) => {
|
|
const [sectionData, setSectionData] = useState({
|
|
BannerSectionForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Summer Sale Banner',
|
|
description: 'Promotional banner for summer sale campaign',
|
|
image: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 22, 2024'
|
|
}
|
|
],
|
|
CTASectionForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Get Started CTA',
|
|
description: 'Primary call-to-action for new users',
|
|
image: 'https://images.unsplash.com/photo-1559136555-9303baea8ebd?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 21, 2024'
|
|
}
|
|
],
|
|
EcosystemForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Smart City Solutions',
|
|
description: 'Comprehensive urban development platform integrating IoT, data analytics, and citizen engagement.',
|
|
image: 'https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 21, 2024'
|
|
},
|
|
{
|
|
id: 2,
|
|
title: 'Healthcare Innovation Hub',
|
|
description: 'Connected healthcare ecosystem with telemedicine, AI diagnostics, and patient management.',
|
|
image: 'https://images.unsplash.com/photo-1559757148-5c350d0d3c56?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'medium',
|
|
date: 'Dec 20, 2024'
|
|
}
|
|
],
|
|
FaqSectionForm: [
|
|
{
|
|
id: 1,
|
|
title: 'How to Get Started',
|
|
description: 'Step-by-step guide for new users to begin using our platform',
|
|
image: 'https://images.unsplash.com/photo-1522202176988-66273c2fd55f?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 20, 2024'
|
|
}
|
|
],
|
|
FooterForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Main Footer',
|
|
description: 'Primary footer with contact information and links',
|
|
image: 'https://images.unsplash.com/photo-1557804506-669a67965ba0?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'medium',
|
|
date: 'Dec 19, 2024'
|
|
}
|
|
],
|
|
HeroSectionForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Support the Environment',
|
|
description: 'Environmental conservation through waste management, and sustainable practices for a better future.',
|
|
image: 'https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'medium',
|
|
date: 'Dec 19, 2024'
|
|
},
|
|
{
|
|
id: 2,
|
|
title: 'Water, Sanitation & Hygiene',
|
|
description: 'Providing clean water access, sanitation facilities, hygiene education to improve community health and wellbeing.',
|
|
image: 'https://images.unsplash.com/photo-1559027615-cd4628902d4a?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 18, 2024'
|
|
}
|
|
],
|
|
OfferingsForm: [
|
|
{
|
|
id: 1,
|
|
title: 'Digital Transformation',
|
|
description: 'Comprehensive digital solutions to modernize your business operations and enhance customer experience.',
|
|
image: 'https://images.unsplash.com/photo-1551434678-e076c223a692?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 18, 2024'
|
|
},
|
|
{
|
|
id: 2,
|
|
title: 'Cloud Infrastructure',
|
|
description: 'Scalable cloud solutions for secure data storage, processing, and seamless business operations.',
|
|
image: 'https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'medium',
|
|
date: 'Dec 17, 2024'
|
|
}
|
|
],
|
|
TrendingAppsForm: [
|
|
{
|
|
id: 1,
|
|
name: 'PozoPay',
|
|
description: 'Secure mobile payment solution with advanced encryption and fraud protection.',
|
|
icon: 'https://images.unsplash.com/photo-1563013544-824ae1b704d3?w=100&h=100&fit=crop',
|
|
category: 'Finance',
|
|
rating: 4.8,
|
|
downloads: '1.2M',
|
|
status: 'active',
|
|
priority: 'high',
|
|
date: 'Dec 22, 2024'
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'SmartInventory',
|
|
description: 'AI-powered inventory management system with real-time tracking and analytics.',
|
|
icon: 'https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=100&h=100&fit=crop',
|
|
category: 'Business',
|
|
rating: 4.6,
|
|
downloads: '850K',
|
|
status: 'active',
|
|
priority: 'medium',
|
|
date: 'Dec 21, 2024'
|
|
},
|
|
{
|
|
id: 3,
|
|
name: 'HealthTracker',
|
|
description: 'Comprehensive health monitoring app with wearable device integration.',
|
|
icon: 'https://images.unsplash.com/photo-1559757175-0eb30cd8c063?w=100&h=100&fit=crop',
|
|
category: 'Health',
|
|
rating: 4.9,
|
|
downloads: '2.1M',
|
|
status: 'active',
|
|
priority: 'high',
|
|
date: 'Dec 20, 2024'
|
|
}
|
|
],
|
|
AppDemo: [
|
|
{
|
|
id: 1,
|
|
title: 'Product Demo Video',
|
|
description: 'Comprehensive demonstration of our latest product features and capabilities',
|
|
image: 'https://images.unsplash.com/photo-1574717024653-61fd2cf4d44d?w=400&h=300&fit=crop',
|
|
active: true,
|
|
priority: 'high',
|
|
date: 'Dec 19, 2024'
|
|
}
|
|
]
|
|
})
|
|
|
|
const addItem = (sectionKey, item) => {
|
|
setSectionData(prev => ({
|
|
...prev,
|
|
[sectionKey]: [...prev[sectionKey], { ...item, id: Date.now() }]
|
|
}))
|
|
}
|
|
|
|
const updateItem = (sectionKey, itemId, updatedItem) => {
|
|
setSectionData(prev => ({
|
|
...prev,
|
|
[sectionKey]: prev[sectionKey].map(item =>
|
|
item.id === itemId ? { ...item, ...updatedItem } : item
|
|
)
|
|
}))
|
|
}
|
|
|
|
const deleteItem = (sectionKey, itemId) => {
|
|
setSectionData(prev => ({
|
|
...prev,
|
|
[sectionKey]: prev[sectionKey].filter(item => item.id !== itemId)
|
|
}))
|
|
}
|
|
|
|
const toggleItemStatus = (sectionKey, itemId) => {
|
|
setSectionData(prev => ({
|
|
...prev,
|
|
[sectionKey]: prev[sectionKey].map(item =>
|
|
item.id === itemId ? { ...item, active: !item.active } : item
|
|
)
|
|
}))
|
|
}
|
|
|
|
const updateSectionData = (sectionKey, newData) => {
|
|
setSectionData(prev => ({
|
|
...prev,
|
|
[sectionKey]: newData
|
|
}))
|
|
}
|
|
|
|
const value = {
|
|
sectionData,
|
|
addItem,
|
|
updateItem,
|
|
deleteItem,
|
|
toggleItemStatus,
|
|
updateSectionData
|
|
}
|
|
|
|
return (
|
|
<AdminPanelContext.Provider value={value}>
|
|
{children}
|
|
</AdminPanelContext.Provider>
|
|
)
|
|
}
|