import React, { useState } from "react"; import { View, Text, FlatList, StyleSheet, TouchableOpacity, Image, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; const dataPengaduan = [ { id: "1", judul: "TPS Liar", lokasi: "Jl. Sukarno - Jl. Sukarno, Nganjuk", tanggal: "05 Januari 2025", waktu: "14.32 WIB", status: "selesai", color: "#D2F3D1", adminResponse: "Terimakasih telah melaporkan sampah. Berikut bukti foto yang sudah ditindaklanjuti.", image: "https://5.imimg.com/data5/SELLER/Default/2022/4/LC/DM/QX/8088277/rakshak-self-watering-tree-guard-1000x1000.jpg", // Replace with actual image URL }, { id: "2", judul: "Sampah berserakan", lokasi: "Pasar Lama - Jl. Sukarno, Nganjuk", tanggal: "03 Januari 2025", waktu: "10.12 WIB", status: "dalam proses", color: "#E4D9FB", adminResponse: "", image: "", }, { id: "3", judul: "Banyak Sampah ini", lokasi: "Depan Rumah Ijo - Jl Letjen S Parman", tanggal: "03 Januari 2025", waktu: "10.12 WIB", status: "sedang diverifikasi", color: "#FFF8C5", adminResponse: "", image: "", }, { id: "4", judul: "Sampah numpuk", lokasi: "Depan masjid - Jl Letjen S Parman", tanggal: "03 Januari 2025", waktu: "10.12 WIB", status: "ditolak", color: "#FBE2DE", reason: "Lokasi tidak sesuai dengan TPS yang valid", // Added reason for rejection adminResponse: "", image: "", }, ]; const StatusPengaduan = () => { const navigation = useNavigation(); const [filterStatus, setFilterStatus] = useState("all"); const handlePress = (item) => { navigation.navigate("DetailPengaduan", { item }); }; const handleFilterChange = (status) => { setFilterStatus(status); }; const filteredData = filterStatus === "all" ? dataPengaduan : dataPengaduan.filter((item) => item.status === filterStatus); const renderItem = ({ item }) => ( handlePress(item)} activeOpacity={0.8} > {item.judul} {item.tanggal} {item.lokasi} {item.status === "ditolak" && item.reason && ( {item.reason} )} {item.waktu} {/* Admin Response Section */} {item.adminResponse && ( {item.adminResponse} {item.image ? ( Bukti Foto: ) : null} )} ); return ( {/* Header */} navigation.goBack()}> STATUS PENGADUAN {/* Filter Buttons */} handleFilterChange("sedang diverifikasi")} > Sedang Verifikasi handleFilterChange("dalam proses")} > Dalam Proses handleFilterChange("selesai")} > Selesai handleFilterChange("ditolak")} > Ditolak handleFilterChange("all")} > All {/* List */} item.id} renderItem={renderItem} contentContainerStyle={{ padding: 16 }} /> ); }; const StatusBadge = ({ status }) => { let bgColor = "#ccc"; let textColor = "#000"; switch (status) { case "selesai": bgColor = "#FFF"; textColor = "#000"; break; case "dalam proses": bgColor = "#FFF"; textColor = "#000"; break; case "sedang diverifikasi": bgColor = "#FFF"; textColor = "#000"; break; case "ditolak": bgColor = "#FFF"; textColor = "#000"; break; } return ( {status} ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", }, header: { flexDirection: "row", alignItems: "center", padding: 20, backgroundColor: "#fff", borderBottomWidth: 1, borderColor: "#fff", marginTop: 40, }, headerText: { fontSize: 22, fontWeight: "bold", color: "#000", marginLeft: 10, }, filterContainer: { flexDirection: "row", justifyContent: "space-between", padding: 16, borderColor: "#000", }, filterButton: { paddingVertical: 8, paddingHorizontal: 12, backgroundColor: "#fff", borderRadius: 20, borderColor: "#000", borderWidth: 0.5, }, selectedFilter: { backgroundColor: "#ddd", }, filterText: { fontSize: 14, color: "#000", }, card: { padding: 14, borderRadius: 12, marginBottom: 16, borderWidth: 1, borderColor: "#000", }, cardHeader: { flexDirection: "row", justifyContent: "space-between", }, judul: { fontSize: 16, fontWeight: "bold", }, tanggal: { fontSize: 12, color: "#555", }, lokasi: { fontSize: 13, color: "#444", marginVertical: 4, }, cardFooter: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginTop: 8, }, waktu: { fontSize: 12, color: "#666", }, statusBadge: { paddingHorizontal: 10, paddingVertical: 4, borderRadius: 20, borderWidth: 0.5, }, statusText: { fontSize: 12, fontWeight: "600", }, rejectionReason: { fontSize: 12, color: "#000", marginTop: 4, fontStyle: "italic", }, adminResponseContainer: { marginTop: 12, padding: 10, backgroundColor: "#f4f4f4", borderRadius: 8, borderWidth: 1, borderColor: "#ddd", }, adminResponse: { fontSize: 14, fontStyle: "italic", color: "#555", }, imageContainer: { marginTop: 8, }, imageText: { fontSize: 14, fontWeight: "bold", }, image: { width: 200, height: 150, marginTop: 8, borderRadius: 8, }, }); export default StatusPengaduan;