Skip to content

feat: add admin pages for announcements and user management#29

Merged
Ardelyo merged 1 commit intomainfrom
massif-kontributor-dan-branding
Dec 24, 2025
Merged

feat: add admin pages for announcements and user management#29
Ardelyo merged 1 commit intomainfrom
massif-kontributor-dan-branding

Conversation

@Ardelyo
Copy link
Copy Markdown
Collaborator

@Ardelyo Ardelyo commented Dec 24, 2025

📋 Deskripsi

Jelaskan perubahan yang kamu buat secara singkat.

🔗 Issue Terkait

Fixes #(nomor issue)

🔄 Tipe Perubahan

  • 🐛 Bug fix (perubahan yang memperbaiki issue)
  • ✨ Fitur baru (perubahan yang menambah fungsionalitas)
  • 📝 Dokumentasi (perubahan pada dokumentasi)
  • 🎨 Style (formatting, tidak ada perubahan kode)
  • ♻️ Refactor (perubahan kode tanpa menambah fitur/fix)
  • 🔧 Chore (maintenance, dependencies)

📸 Screenshot (jika UI berubah)

Sebelum Sesudah
(screenshot) (screenshot)

✅ Checklist

  • Kode saya mengikuti standar proyek
  • Saya sudah melakukan self-review
  • Saya sudah menambahkan komentar di bagian yang kompleks
  • Saya sudah update dokumentasi yang terkait
  • Perubahan saya tidak menghasilkan warning baru
  • Saya sudah test perubahan saya secara lokal

📝 Catatan untuk Reviewer

Tambahkan catatan atau pertanyaan untuk reviewer di sini.

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ourcreativity Ready Ready Preview, Comment Dec 24, 2025 1:08pm

@Ardelyo Ardelyo merged commit e0fc4c7 into main Dec 24, 2025
2 checks passed
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @Ardelyo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Pull request ini berfokus pada peningkatan fungsionalitas halaman admin yang sudah ada. Perubahan utama melibatkan migrasi manajemen data pengumuman ke @tanstack/react-query untuk performa dan pengalaman pengembang yang lebih baik, serta penambahan fitur penting untuk menghapus pengguna dari sistem. Ini bertujuan untuk memberikan kontrol administratif yang lebih kuat dan antarmuka yang lebih responsif.

Highlights

  • Refaktor Pengumuman: Halaman admin pengumuman kini menggunakan @tanstack/react-query untuk manajemen data yang lebih efisien, termasuk pengambilan, penyimpanan, dan penghapusan pengumuman.
  • Fungsionalitas Hapus Pengguna: Menambahkan kemampuan untuk menghapus pengguna secara permanen dari halaman admin manajemen pengguna.
  • Indikator Pemuatan: Menambahkan indikator pemuatan pada tombol simpan dan hapus untuk memberikan umpan balik visual kepada pengguna selama operasi data.
  • Peningkatan UI Modal: Menyesuaikan gaya modal pengumuman untuk penanganan overflow yang lebih baik.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Pull request ini melakukan refactor yang bagus dengan mengadopsi @tanstack/react-query untuk manajemen data pada halaman admin, yang meningkatkan efisiensi dan pengalaman developer. Penambahan fungsionalitas untuk mengelola pengumuman dan pengguna juga merupakan langkah yang baik.

Ulasan saya berfokus pada beberapa area untuk perbaikan:

  1. Keamanan Tipe (Type Safety): Menghindari penggunaan any dan mendefinisikan interface untuk struktur data akan membuat kode lebih kuat dan mudah dipelihara.
  2. Pengalaman Pengguna (UX): Mengganti alert() dengan notifikasi non-blocking (seperti toast) dan memastikan konsistensi pada indikator loading.
  3. Integritas Data: Terdapat isu kritis terkait proses penghapusan pengguna yang berpotensi meninggalkan data yatim (orphaned data) di sistem autentikasi, yang perlu segera ditangani.

Secara keseluruhan, ini adalah kontribusi yang solid. Perbaikan pada poin-poin di atas akan membuat fitur ini lebih andal dan matang.

Comment thread pages/Admin/Users.tsx
Comment on lines +77 to +93
const deleteMutation = useMutation({
mutationFn: async (userId: string) => {
const { error } = await supabase
.from('profiles')
.delete()
.eq('id', userId);
if (error) throw error;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['users'] });
alert('Pengguna berhasil dihapus.');
},
onError: (error) => {
console.error('Delete failed:', error);
alert('Gagal menghapus pengguna.');
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Operasi penghapusan ini hanya menargetkan tabel profiles. Hal ini sangat berisiko meninggalkan data pengguna di auth.users (menjadi orphaned user). Pengguna yang profilnya telah dihapus kemungkinan masih bisa login, yang dapat menyebabkan error pada aplikasi jika data profilnya tidak ditemukan setelah login.

Untuk memastikan integritas data, proses penghapusan harus mencakup data di auth.users juga. Pendekatan yang disarankan adalah membuat fungsi di database (melalui RPC di Supabase) yang menangani penghapusan dari kedua tabel (profiles dan auth.users) secara atomik.

Comment on lines +24 to +35
const { data: announcements = [], isLoading } = useQuery({
queryKey: ['announcements'],
queryFn: async () => {
const { data, error } = await supabase
.from('announcements')
.select('id, title, subtitle, description, date, type, status, color, is_active')
.select('id, title, subtitle, description, date, type, status, color, is_active, content, category, highlights')
.order('date', { ascending: false });

if (error) throw error;
setAnnouncements(data || []);
} catch (error) {
console.error('Error fetching announcements:', error);
} finally {
setLoading(false);
}
};

useEffect(() => {
fetchAnnouncements();
}, []);
return data;
},
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Untuk meningkatkan keamanan tipe (type safety), sebaiknya berikan tipe data yang eksplisit untuk hasil dari useQuery. Anda bisa mendefinisikan sebuah interface untuk Announcement dan menggunakannya seperti useQuery<Announcement[]>(...). Ini akan memberikan tipe yang benar untuk variabel announcements dan menghindari penggunaan any di bagian lain kode, seperti pada saat melakukan map.

Contoh interface:

interface Announcement {
  id: string;
  title: string;
  subtitle: string;
  description: string;
  date: string;
  type: string;
  status: string;
  color: string;
  is_active: boolean;
  content: string;
  category: string;
  highlights: string[];
}

onError: (error) => {
console.error('Error saving announcement:', error);
alert('Failed to save announcement.');
alert('Gagal menyimpan pengumuman.');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Penggunaan alert() untuk menampilkan pesan error dapat mengganggu pengalaman pengguna karena sifatnya yang blocking. Sebaiknya, pertimbangkan untuk menggunakan komponen notifikasi yang tidak blocking, seperti toast atau snackbar, untuk memberikan umpan balik yang lebih baik kepada pengguna tanpa menghentikan interaksi mereka dengan aplikasi.

Comment thread pages/Admin/Users.tsx
title="Hapus Pengguna"
disabled={deleteMutation.isPending}
>
<Trash2 size={18} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Tombol hapus ini sudah dinonaktifkan saat proses penghapusan berjalan, namun tidak menampilkan indikator loading. Untuk konsistensi UI dengan bagian lain di aplikasi (seperti di halaman Pengumuman) dan untuk memberikan umpan balik visual yang lebih baik kepada pengguna, sebaiknya tambahkan ikon Loader2 saat deleteMutation.isPending.

Pengecekan terhadap deleteMutation.variables juga akan memastikan ikon loading hanya muncul pada baris yang sedang diproses.

Suggested change
<Trash2 size={18} />
{deleteMutation.isPending && deleteMutation.variables === user.id ? <Loader2 size={18} className="animate-spin" /> : <Trash2 size={18} />}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant