thêm quét QR đăng nhập, sửa lại logic để gọi api bằng ip thiết bị
This commit is contained in:
@@ -7,16 +7,7 @@ export default function Warning() {
|
||||
const [isShowModal, setIsShowModal] = useState(false);
|
||||
return (
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<View style={styles.container}>
|
||||
<CreateOrUpdateHaulModal
|
||||
fishingLog={fishingLogData}
|
||||
isVisible={isShowModal}
|
||||
onClose={function (): void {
|
||||
setIsShowModal(false);
|
||||
}}
|
||||
/>
|
||||
<Button title="Thêm thu hoạch" onPress={() => setIsShowModal(true)} />
|
||||
</View>
|
||||
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
@@ -54,118 +45,3 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
const fishingLogData:Model.FishingLog = {
|
||||
fishing_log_id: "124b2701-a5d6-4eb0-ba3b-6789473c14a9",
|
||||
trip_id: "d84caab6-ebb0-4cf7-abf9-31e5617d23b9",
|
||||
start_at: "2025-11-07T10:50:01.693193764Z",
|
||||
end_at: "2025-11-07T10:50:31.693027729Z",
|
||||
start_lat: 11.59141,
|
||||
start_lon: 109.0489,
|
||||
haul_lat: 11.590274,
|
||||
haul_lon: 109.049284,
|
||||
status: 1,
|
||||
weather_description: "Stormy",
|
||||
info: [
|
||||
{
|
||||
fish_species_id: 8,
|
||||
fish_name: "Cá hồng phớn",
|
||||
catch_number: 1309,
|
||||
catch_unit: "kg",
|
||||
fish_size: 173,
|
||||
fish_rarity: 3,
|
||||
fish_condition: "Còn sống",
|
||||
gear_usage: "Câu vàng",
|
||||
},
|
||||
{
|
||||
fish_species_id: 18,
|
||||
fish_name: "Cá đuối quạt",
|
||||
catch_number: 731,
|
||||
catch_unit: "kg",
|
||||
fish_size: 16,
|
||||
fish_rarity: 4,
|
||||
fish_condition: "Chết",
|
||||
gear_usage: "Bẫy lưới",
|
||||
},
|
||||
{
|
||||
fish_species_id: 7,
|
||||
fish_name: "Cá bơn vàng",
|
||||
catch_number: 1224,
|
||||
catch_unit: "kg",
|
||||
fish_size: 12,
|
||||
fish_rarity: 1,
|
||||
fish_condition: "Chết",
|
||||
gear_usage: "",
|
||||
},
|
||||
{
|
||||
fish_species_id: 16,
|
||||
fish_name: "Cá rồng biển",
|
||||
catch_number: 838,
|
||||
catch_unit: "kg",
|
||||
fish_size: 164,
|
||||
fish_rarity: 3,
|
||||
fish_condition: "Chết",
|
||||
gear_usage: "Lưới rê",
|
||||
},
|
||||
{
|
||||
fish_species_id: 9,
|
||||
fish_name: "Cá hổ Napoleon",
|
||||
catch_number: 1410,
|
||||
catch_unit: "kg",
|
||||
fish_size: 104,
|
||||
fish_rarity: 4,
|
||||
fish_condition: "Bị thương",
|
||||
gear_usage: "Câu vàng",
|
||||
},
|
||||
{
|
||||
fish_species_id: 3,
|
||||
fish_name: "Cá chim trắng",
|
||||
catch_number: 1184,
|
||||
catch_unit: "kg",
|
||||
fish_size: 104,
|
||||
fish_rarity: 2,
|
||||
fish_condition: "Còn sống",
|
||||
gear_usage: "",
|
||||
},
|
||||
{
|
||||
fish_species_id: 5,
|
||||
fish_name: "Cá mú đỏ",
|
||||
catch_number: 987,
|
||||
catch_unit: "kg",
|
||||
fish_size: 171,
|
||||
fish_rarity: 2,
|
||||
fish_condition: "Bị thương",
|
||||
gear_usage: "",
|
||||
},
|
||||
{
|
||||
fish_species_id: 13,
|
||||
fish_name: "Cá song đỏ",
|
||||
catch_number: 1676,
|
||||
catch_unit: "kg",
|
||||
fish_size: 99,
|
||||
fish_rarity: 2,
|
||||
fish_condition: "Bị thương",
|
||||
gear_usage: "",
|
||||
},
|
||||
{
|
||||
fish_species_id: 11,
|
||||
fish_name: "Cá ngừ đại dương",
|
||||
catch_number: 462,
|
||||
catch_unit: "kg",
|
||||
fish_size: 11,
|
||||
fish_rarity: 1,
|
||||
fish_condition: "Bị thương",
|
||||
gear_usage: "",
|
||||
},
|
||||
{
|
||||
fish_species_id: 2,
|
||||
fish_name: "Cá nục",
|
||||
catch_number: 496,
|
||||
catch_unit: "kg",
|
||||
fish_size: 125,
|
||||
fish_rarity: 1,
|
||||
fish_condition: "Còn sống",
|
||||
gear_usage: "",
|
||||
},
|
||||
],
|
||||
sync: true,
|
||||
};
|
||||
|
||||
@@ -46,8 +46,9 @@ export default function HomeScreen() {
|
||||
const [circleRadius, setCircleRadius] = useState(100);
|
||||
const [zoomLevel, setZoomLevel] = useState(10);
|
||||
const [isFirstLoad, setIsFirstLoad] = useState(true);
|
||||
const [polylineCoordinates, setPolylineCoordinates] =
|
||||
useState<PolylineWithLabelProps | null>(null);
|
||||
const [polylineCoordinates, setPolylineCoordinates] = useState<
|
||||
PolylineWithLabelProps[]
|
||||
>([]);
|
||||
const [polygonCoordinates, setPolygonCoordinates] = useState<
|
||||
PolygonWithLabelProps[]
|
||||
>([]);
|
||||
@@ -69,7 +70,7 @@ export default function HomeScreen() {
|
||||
} else {
|
||||
setGpsData(null);
|
||||
setPolygonCoordinates([]);
|
||||
setPolylineCoordinates(null);
|
||||
setPolylineCoordinates([]);
|
||||
}
|
||||
};
|
||||
const queryAlarmData = (alarmData: Model.AlarmResponse) => {
|
||||
@@ -121,7 +122,7 @@ export default function HomeScreen() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setPolylineCoordinates(null);
|
||||
setPolylineCoordinates([]);
|
||||
setPolygonCoordinates([]);
|
||||
if (!entityData) return;
|
||||
if (!banzoneData) return;
|
||||
@@ -139,11 +140,14 @@ export default function HomeScreen() {
|
||||
}
|
||||
// Nếu danh sách zone rỗng, clear tất cả
|
||||
if (zones.length === 0) {
|
||||
setPolylineCoordinates(null);
|
||||
setPolylineCoordinates([]);
|
||||
setPolygonCoordinates([]);
|
||||
return;
|
||||
}
|
||||
|
||||
let polylines: PolylineWithLabelProps[] = [];
|
||||
let polygons: PolygonWithLabelProps[] = [];
|
||||
|
||||
for (const zone of zones) {
|
||||
// console.log("Zone Data: ", zone);
|
||||
const geom = banzoneData.find((b) => b.id === zone.zone_id);
|
||||
@@ -161,7 +165,7 @@ export default function HomeScreen() {
|
||||
geom_lines || ""
|
||||
);
|
||||
if (coordinates.length > 0) {
|
||||
setPolylineCoordinates({
|
||||
polylines.push({
|
||||
coordinates: coordinates.map((coord) => ({
|
||||
latitude: coord[0],
|
||||
longitude: coord[1],
|
||||
@@ -169,25 +173,31 @@ export default function HomeScreen() {
|
||||
label: zone?.zone_name ?? "",
|
||||
content: zone?.message ?? "",
|
||||
});
|
||||
} else {
|
||||
console.log("Không tìm thấy polyline trong alarm");
|
||||
}
|
||||
} else if (geom_type === 1) {
|
||||
// foundPolygon = true;
|
||||
const coordinates = convertWKTtoLatLngString(geom_poly || "");
|
||||
if (coordinates.length > 0) {
|
||||
// console.log("Polygon Coordinate: ", coordinates);
|
||||
setPolygonCoordinates(
|
||||
coordinates.map((polygon) => ({
|
||||
coordinates: polygon.map((coord) => ({
|
||||
latitude: coord[0],
|
||||
longitude: coord[1],
|
||||
})),
|
||||
label: zone?.zone_name ?? "",
|
||||
content: zone?.message ?? "",
|
||||
}))
|
||||
);
|
||||
const zonePolygons = coordinates.map((polygon) => ({
|
||||
coordinates: polygon.map((coord) => ({
|
||||
latitude: coord[0],
|
||||
longitude: coord[1],
|
||||
})),
|
||||
label: zone?.zone_name ?? "",
|
||||
content: zone?.message ?? "",
|
||||
}));
|
||||
polygons.push(...zonePolygons);
|
||||
} else {
|
||||
console.log("Không tìm thấy polygon trong alarm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setPolylineCoordinates(polylines);
|
||||
setPolygonCoordinates(polygons);
|
||||
}
|
||||
}, [banzoneData, entityData]);
|
||||
|
||||
@@ -301,7 +311,7 @@ export default function HomeScreen() {
|
||||
// console.log(`Rendering circle ${index}:`, point);
|
||||
return (
|
||||
<Circle
|
||||
key={index}
|
||||
key={`circle-${index}`}
|
||||
center={{
|
||||
latitude: point.lat,
|
||||
longitude: point.lon,
|
||||
@@ -315,27 +325,27 @@ export default function HomeScreen() {
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{polylineCoordinates && (
|
||||
<PolylineWithLabel
|
||||
key={`polyline-${gpsData?.lat || 0}-${gpsData?.lon || 0}`}
|
||||
coordinates={polylineCoordinates.coordinates}
|
||||
label={polylineCoordinates.label}
|
||||
content={polylineCoordinates.content}
|
||||
strokeColor="#FF5733"
|
||||
strokeWidth={4}
|
||||
showDistance={false}
|
||||
// zIndex={50}
|
||||
/>
|
||||
{polylineCoordinates.length > 0 && (
|
||||
<>
|
||||
{polylineCoordinates.map((polyline, index) => (
|
||||
<PolylineWithLabel
|
||||
key={`polyline-${index}-${gpsData?.lat || 0}-${
|
||||
gpsData?.lon || 0
|
||||
}`}
|
||||
coordinates={polyline.coordinates}
|
||||
label={polyline.label}
|
||||
content={polyline.content}
|
||||
strokeColor="#FF5733"
|
||||
strokeWidth={4}
|
||||
showDistance={false}
|
||||
// zIndex={50}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
{polygonCoordinates.length > 0 && (
|
||||
<>
|
||||
{polygonCoordinates.map((polygon, index) => {
|
||||
// Tạo key ổn định từ tọa độ đầu tiên của polygon
|
||||
const polygonKey =
|
||||
polygon.coordinates.length > 0
|
||||
? `polygon-${polygon.coordinates[0].latitude}-${polygon.coordinates[0].longitude}-${index}`
|
||||
: `polygon-${index}`;
|
||||
|
||||
return (
|
||||
<PolygonWithLabel
|
||||
key={`polygon-${index}-${gpsData?.lat || 0}-${
|
||||
@@ -365,11 +375,6 @@ export default function HomeScreen() {
|
||||
latitude: gpsData.lat,
|
||||
longitude: gpsData.lon,
|
||||
}}
|
||||
title={
|
||||
platform === IOS_PLATFORM
|
||||
? "Tàu của mình - iOS"
|
||||
: "Tàu của mình - Android"
|
||||
}
|
||||
zIndex={20}
|
||||
anchor={
|
||||
platform === IOS_PLATFORM
|
||||
|
||||
@@ -4,7 +4,7 @@ import { StyleSheet } from "react-native";
|
||||
import { ThemedText } from "@/components/themed-text";
|
||||
import { ThemedView } from "@/components/themed-view";
|
||||
import { api } from "@/config";
|
||||
import { TOKEN } from "@/constants";
|
||||
import { DOMAIN, TOKEN } from "@/constants";
|
||||
import { removeStorageItem } from "@/utils/storage";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -37,9 +37,10 @@ export default function SettingScreen() {
|
||||
<ThemedText type="title">Settings</ThemedText>
|
||||
<ThemedView
|
||||
style={styles.button}
|
||||
onTouchEnd={() => {
|
||||
removeStorageItem(TOKEN);
|
||||
router.replace("/auth/login");
|
||||
onTouchEnd={async () => {
|
||||
await removeStorageItem(TOKEN);
|
||||
await removeStorageItem(DOMAIN);
|
||||
router.navigate("/auth/login");
|
||||
}}
|
||||
>
|
||||
<ThemedText type="defaultSemiBold">Đăng xuất</ThemedText>
|
||||
|
||||
Reference in New Issue
Block a user