import variables from 'config/variables';
import { useState } from 'react';
import {
Header,
Row,
Content,
Action,
PreferencesWrapper,
Section,
} from 'components/Layout/Settings';
import { Checkbox, Switch, Text } from 'components/Form/Settings';
import { TextareaAutosize } from '@mui/material';
import { Button } from 'components/Elements';
import defaultEvents from '../events.json';
import { MdEventNote, MdAdd, MdCancel, MdRefresh } from 'react-icons/md';
const GreetingOptions = () => {
const [customEvents, setCustomEvents] = useState(
JSON.parse(localStorage.getItem('customEvents')) || [],
);
const [events, setEvents] = useState(false);
const [birthday, setBirthday] = useState(
new Date(localStorage.getItem('birthday')) || new Date(),
);
const changeDate = (e) => {
const newDate = e.target.value ? new Date(e.target.value) : new Date();
localStorage.setItem('birthday', newDate);
setBirthday(newDate);
};
const GREETING_SECTION = 'modals.main.settings.sections.greeting';
function addEvent() {
// Retrieve the current array of events from localStorage
const customEvents = JSON.parse(localStorage.getItem('customEvents')) || [];
// Create a new event
const newEvent = {
id: 'widgets.greeting.halloween',
name: '',
month: 10,
date: 31,
};
// Add the new event to the array
const updatedEvents = [...customEvents, newEvent];
// Add the new event to the array
customEvents.push(newEvent);
// Store the updated array back in localStorage
localStorage.setItem('customEvents', JSON.stringify(customEvents));
setCustomEvents(updatedEvents);
}
function removeEvent(index) {
// Remove the event at the given index
const updatedEvents = customEvents.filter((_, i) => i !== index);
// Store the updated array back in localStorage
localStorage.setItem('customEvents', JSON.stringify(updatedEvents));
// Update the state
setCustomEvents(updatedEvents);
}
function resetEvents() {
// Reset the events array in localStorage
localStorage.setItem('customEvents', JSON.stringify(defaultEvents));
// Update the state
setCustomEvents(defaultEvents);
}
function updateEvent(index, updatedEvent) {
// Update the event in your state
setCustomEvents((prevEvents) => {
const newEvents = [...prevEvents];
newEvents[index] = updatedEvent;
return newEvents;
});
// Update the event in localStorage
const customEvents = JSON.parse(localStorage.getItem('customEvents') || '[]');
customEvents[index] = updatedEvent;
localStorage.setItem('customEvents', JSON.stringify(customEvents));
}
const AdditionalOptions = () => {
return (
{variables.getMessage(`${GREETING_SECTION}.birthday_date`)}