update interface, diary

This commit is contained in:
2025-12-04 15:54:49 +07:00
parent 4d60ce279e
commit 0672f8adf9
10 changed files with 291 additions and 90 deletions

View File

@@ -1,5 +1,12 @@
import { useState } from "react";
import { Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { useEffect, useState } from "react";
import {
Platform,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Ionicons } from "@expo/vector-icons";
import SearchBar from "@/components/diary/SearchBar";
@@ -7,6 +14,7 @@ import FilterButton from "@/components/diary/FilterButton";
import TripCard from "@/components/diary/TripCard";
import FilterModal, { FilterValues } from "@/components/diary/FilterModal";
import { MOCK_TRIPS } from "@/components/diary/mockData";
import { useThings } from "@/state/use-thing";
export default function diary() {
const [searchText, setSearchText] = useState("");
@@ -16,6 +24,23 @@ export default function diary() {
startDate: null,
endDate: null,
});
// Body things (đang fix cứng)
const payloadThings: Model.SearchThingBody = {
offset: 0,
limit: 200,
order: "name",
dir: "asc",
metadata: {
not_empty: "ship_name, ship_reg_number",
},
};
// Gọi API things
const { things, getThings } = useThings();
useEffect(() => {
getThings(payloadThings);
}, []);
console.log(things);
// Filter trips based on search text and filters
const filteredTrips = MOCK_TRIPS.filter((trip) => {
@@ -73,6 +98,31 @@ export default function diary() {
console.log("Trip pressed:", tripId);
};
const handleViewTrip = (tripId: string) => {
console.log("View trip:", tripId);
// TODO: Navigate to trip detail view
};
const handleEditTrip = (tripId: string) => {
console.log("Edit trip:", tripId);
// TODO: Navigate to trip edit screen
};
const handleViewTeam = (tripId: string) => {
console.log("View team:", tripId);
// TODO: Navigate to team management
};
const handleSendTrip = (tripId: string) => {
console.log("Send trip:", tripId);
// TODO: Send trip for approval
};
const handleDeleteTrip = (tripId: string) => {
console.log("Delete trip:", tripId);
// TODO: Show confirmation dialog and delete trip
};
return (
<SafeAreaView style={styles.safeArea}>
<View style={styles.container}>
@@ -80,7 +130,7 @@ export default function diary() {
<Text style={styles.titleText}>Nhật chuyến đi</Text>
{/* Search Bar */}
<SearchBar onSearch={handleSearch} style={{marginBottom: 10}}/>
<SearchBar onSearch={handleSearch} style={{ marginBottom: 10 }} />
{/* Filter Button */}
<FilterButton onPress={handleFilter} />
@@ -90,7 +140,7 @@ export default function diary() {
<Text style={styles.countText}>
Danh sách chuyến đi ({filteredTrips.length})
</Text>
<TouchableOpacity
<TouchableOpacity
style={styles.addButton}
onPress={() => console.log("Add trip")}
activeOpacity={0.7}
@@ -111,6 +161,11 @@ export default function diary() {
key={trip.id}
trip={trip}
onPress={() => handleTripPress(trip.id)}
onView={() => handleViewTrip(trip.id)}
onEdit={() => handleEditTrip(trip.id)}
onTeam={() => handleViewTeam(trip.id)}
onSend={() => handleSendTrip(trip.id)}
onDelete={() => handleDeleteTrip(trip.id)}
/>
))}
@@ -141,13 +196,13 @@ const styles = StyleSheet.create({
},
container: {
flex: 1,
padding: 16,
padding: 10,
},
titleText: {
fontSize: 28,
fontWeight: "700",
lineHeight: 36,
marginBottom: 20,
marginBottom: 10,
color: "#111827",
fontFamily: Platform.select({
ios: "System",