+
@@ -147,8 +147,8 @@
Buat Postingan Baru
// --------------------------------------------------------------------------------
// SUPABASE INITIALIZATION
// --------------------------------------------------------------------------------
- const SUPABASE_URL = 'https://spjdrgckbnjnctfgereg.supabase.co';
- const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNwamRyZ2NrYm5qbmN0ZmdlcmVnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTg2Mjg1NjQsImV4cCI6MjA3NDIwNDU2NH0.7VDu-KvNdRrxcRtX6SvhUPEJqVfLeDSGN9yqazii78w';
+ const SUPABASE_URL = 'https://xalacqxnlhjelpcqexle.supabase.co';
+ const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhhbGFjcXhubGhqZWxwY3FleGxlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTg5NDYwNzIsImV4cCI6MjA3NDUyMjA3Mn0.t4eaDIvIxkZQVg5pDIg_Kt5_xg2pIG7sfdsmL6poMjQ';
const { createClient } = supabase;
const db = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
@@ -186,17 +186,28 @@
Buat Postingan Baru
const loginBtn = document.getElementById('loginBtn');
if (user) {
+ // Immediately show the user menu and hide the login button for a responsive feel.
+ userMenu.classList.remove('hidden');
+ loginBtn.classList.add('hidden');
+ document.getElementById('userName').textContent = 'Memuat...'; // Placeholder text
+ document.getElementById('userAvatar').src = `https://picsum.photos/seed/${user.id}/40/40`;
+
const { data: profile, error } = await db
.from('profiles')
.select('full_name, avatar_url')
.eq('id', user.id)
.single();
+ if (error && error.code !== 'PGRST116') { // PGRST116 means no rows found, which is okay
+ console.error('Error fetching profile:', error);
+ }
+
if (profile) {
- userMenu.classList.remove('hidden');
- loginBtn.classList.add('hidden');
document.getElementById('userName').textContent = profile.full_name || user.email;
document.getElementById('userAvatar').src = profile.avatar_url || `https://picsum.photos/seed/${user.id}/40/40`;
+ } else {
+ // Fallback if profile is not available
+ document.getElementById('userName').textContent = user.email;
}
} else {
userMenu.classList.add('hidden');
@@ -423,7 +434,7 @@
Buat Postingan Baru
function createPostElement(post) {
const div = document.createElement('div');
- div.className = 'bg-white rounded-lg shadow-md p-6 post-card fade-in';
+ div.className = 'bg-white rounded-xl shadow-md border border-gray-200 p-6 post-card fade-in';
const isLiked = currentUser && post.likes.some(like => like.user_id === currentUser.id);
const likeCount = post.likes.length;
@@ -431,52 +442,53 @@
Buat Postingan Baru
div.innerHTML = `
-

+
-
${post.profiles.full_name || 'Anonymous'}
+
${post.profiles.full_name || 'Anonymous'}
${formatDate(post.created_at)}
-
${post.content}
- ${post.image_url ? `

` : ''}
-
+
${post.content}
+ ${post.image_url ? `

` : ''}
+
-
- ${post.image_url ? `
+ ${post.image_url ? `
` : ''}
-