// Main application logic
document.addEventListener('DOMContentLoaded', function() {
// Check if user is logged in
const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
if (isLoggedIn) {
updateUIForLoggedInUser();
}
// Instagram connection handler
document.getElementById('connectInstagram')?.addEventListener('click', function() {
if (!isLoggedIn) {
alert('Por favor, faça login primeiro.');
document.querySelector('custom-auth-modal').shadowRoot.querySelector('.modal').classList.remove('hidden');
return;
}
// In a real app, this would redirect to Instagram OAuth
alert('Redirecionando para o Instagram para autenticação...');
// Simulate loading reels after connection
setTimeout(() => {
loadSampleReels();
}, 1500);
});
});
function updateUIForLoggedInUser() {
const username = localStorage.getItem('username');
const navbar = document.querySelector('custom-navbar');
if (navbar && navbar.shadowRoot) {
const loginBtn = navbar.shadowRoot.querySelector('#loginBtn');
const userMenu = navbar.shadowRoot.querySelector('#userMenu');
if (loginBtn) loginBtn.classList.add('hidden');
if (userMenu) {
userMenu.classList.remove('hidden');
userMenu.querySelector('span').textContent = username;
}
}
}
function loadSampleReels() {
const reelsContainer = document.getElementById('reelsContainer');
if (!reelsContainer) return;
reelsContainer.innerHTML = '';
// Sample reels data - in a real app, this would come from an API
const sampleReels = [
{ id: 1, thumbnail: 'http://static.photos/travel/320x240/1', caption: 'Viagem incrível!', comments: 24 },
{ id: 2, thumbnail: 'http://static.photos/food/320x240/2', caption: 'Receita nova 🍕', comments: 42 },
{ id: 3, thumbnail: 'http://static.photos/nature/320x240/3', caption: 'Pôr do sol maravilhoso', comments: 15 },
{ id: 4, thumbnail: 'http://static.photos/sport/320x240/4', caption: 'Treino pesado hoje!', comments: 8 },
{ id: 5, thumbnail: 'http://static.photos/technology/320x240/5', caption: 'Novo gadget!', comments: 31 },
{ id: 6, thumbnail: 'http://static.photos/minimal/320x240/6', caption: 'Design limpo', comments: 12 }
];
sampleReels.forEach(reel => {
const reelElement = document.createElement('div');
reelElement.className = 'bg-white rounded-xl overflow-hidden shadow-sm reel-card';
reelElement.innerHTML = `
${reel.caption}