From a8bfe5ab0332fe5c6aa6afb45dc2cda2a99a1a9b Mon Sep 17 00:00:00 2001 From: Irul24 Date: Fri, 7 Feb 2025 16:59:10 +0700 Subject: [PATCH] Second Commit --- App.tsx | 60 ++ assets/icon/dell.png | Bin 0 -> 232 bytes assets/icon/edit.png | Bin 0 -> 383 bytes package-lock.json | 7 + package.json | 1 + src/component/collectscreen.tsx | 3 +- .../{sentscreen copy 2.tsx => draftPJU.tsx} | 466 +++++++------ ...reen copy 3.tsx => draftscreen copy 2.tsx} | 466 +++++++------ src/component/draftscreen copy 3.tsx | 646 ++++++++++++++++++ src/component/inboxPDAM.tsx | 339 +++++++++ src/component/inboxPJU.tsx | 343 ++++++++++ src/component/inboxPermit.tsx | 328 +++++++++ src/component/sentPDAM.tsx | 291 ++++++++ src/component/sentPJU.tsx | 402 ++++------- src/component/sentPermit.tsx | 287 ++++++++ src/component/sentscreen.tsx | 5 +- src/component/surveyPDAM.tsx | 8 +- src/component/surveyPERMIT.tsx | 12 +- src/component/surveyPJU.tsx | 4 +- 19 files changed, 2994 insertions(+), 674 deletions(-) create mode 100644 assets/icon/dell.png create mode 100644 assets/icon/edit.png rename src/component/{sentscreen copy 2.tsx => draftPJU.tsx} (63%) rename src/component/{sentscreen copy 3.tsx => draftscreen copy 2.tsx} (63%) create mode 100644 src/component/draftscreen copy 3.tsx create mode 100644 src/component/inboxPDAM.tsx create mode 100644 src/component/inboxPJU.tsx create mode 100644 src/component/inboxPermit.tsx create mode 100644 src/component/sentPDAM.tsx create mode 100644 src/component/sentPermit.tsx diff --git a/App.tsx b/App.tsx index 9564a1b..c5c631a 100644 --- a/App.tsx +++ b/App.tsx @@ -19,7 +19,12 @@ import MainScreen from './src/component/mainscreen'; import CollectScreen from './src/component/collectscreen'; import SendListScreen from './src/component/sentscreen'; import SentListPJU from './src/component/sentPJU'; +import SentListPDAM from './src/component/sentPDAM'; +import SentListPermit from './src/component/sentPermit'; import InboxListScreen from './src/component/inboxscreen'; +import InboxPJU from './src/component/inboxPJU'; +import InboxPDAM from './src/component/inboxPDAM'; +import InboxPermit from './src/component/inboxPermit'; import MapViewScreen from './src/component/mapviewscreen'; import EditScreen from './src/component/editscreen'; import LoginScreen from './src/component/loginscreen'; @@ -422,6 +427,28 @@ export const Nav = () => { fontSize:20 } }}/> + + { fontSize:20 } }}/> + + + HaU7bSzT10y=?vcngbOJAL)EOcXs8^2es@g70P?Ob=EFCIMZp;lg$6$ zS#%u#EL2I9 Yd#8rFTfvdjU%~U?gQr~(?Pk8e zw1P?OjCi|EMBH(u5jOSxF^^>ytfN#xe~)k8W_j3f!#)98?Svmvt*q5&=uo+tkCx7e2R00{{wo_%VFN;x8dfG$A}A!9!197 d3POCmJXa}s#}~pBMV|lw002ovPDHLkV1lpUn>7Fc literal 0 HcmV?d00001 diff --git a/package-lock.json b/package-lock.json index e527323..656ef91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "react-native-maps": "^1.18.2", "react-native-modal": "^13.0.1", "react-native-paper": "^5.12.5", + "react-native-popup-menu": "^0.16.1", "react-native-safe-area-context": "^4.14.0", "react-native-screens": "^4.0.0", "react-native-svg": "^15.8.0", @@ -13289,6 +13290,12 @@ "react": ">=16.8" } }, + "node_modules/react-native-popup-menu": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/react-native-popup-menu/-/react-native-popup-menu-0.16.1.tgz", + "integrity": "sha512-xRS7mRh0exwu7Iw8PPVHdM11d13A/KzYjy0/fZx3zVtxISxPkNaDGayau6oa7HqO3Nj0oS9ulFCYjcQfG6vahA==", + "license": "ISC" + }, "node_modules/react-native-safe-area-context": { "version": "4.14.0", "resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.14.0.tgz", diff --git a/package.json b/package.json index 8fcf7db..cafeee1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "react-native-maps": "^1.18.2", "react-native-modal": "^13.0.1", "react-native-paper": "^5.12.5", + "react-native-popup-menu": "^0.16.1", "react-native-safe-area-context": "^4.14.0", "react-native-screens": "^4.0.0", "react-native-svg": "^15.8.0", diff --git a/src/component/collectscreen.tsx b/src/component/collectscreen.tsx index 49682f6..c1ef846 100644 --- a/src/component/collectscreen.tsx +++ b/src/component/collectscreen.tsx @@ -279,7 +279,8 @@ function CollectScreen({route,navigation}: collectScreenProps) { ).then(async (resp) => { Alert.alert("Success") setAlertOnline(false); - navigation.navigate('Property Survey', { screen: 'Property Survey'}) + // navigation.navigate('Property Survey', { screen: 'Property Survey'}) + navigation.navigate('Survey Penerangan Jalan Umum', { screen: 'Survey Penerangan Jalan Umum'}) } ) }); diff --git a/src/component/sentscreen copy 2.tsx b/src/component/draftPJU.tsx similarity index 63% rename from src/component/sentscreen copy 2.tsx rename to src/component/draftPJU.tsx index 12c2f3d..2f27536 100644 --- a/src/component/sentscreen copy 2.tsx +++ b/src/component/draftPJU.tsx @@ -14,16 +14,21 @@ import { Dimensions } from 'react-native'; +import {useNavigation,NavigationContainer,useIsFocused} from '@react-navigation/native'; +import {createNativeStackNavigator} from '@react-navigation/native-stack'; import AsyncStorage from '@react-native-async-storage/async-storage'; -import {useNavigation,NavigationContainer,useIsFocused} from '@react-navigation/native'; import { useCallback, useEffect, useState } from 'react'; +import { width } from '@fortawesome/free-solid-svg-icons/faMugSaucer'; import { SelectList } from 'react-native-dropdown-select-list'; +import { PDAM_API_URL, PERMIT_API_URL, PJU_API_URL } from '../../urlConfig'; import AwesomeAlert from 'react-native-awesome-alerts'; import NetInfo from "@react-native-community/netinfo"; -import { PJU_API_URL } from '../../urlConfig'; +import Moment from 'moment'; +import RNFetchBlob from 'rn-fetch-blob'; + type sendListDataProps = {route: any,navigation: any}; -function SentListScreen({route,navigation}: sendListDataProps) { +function DraftListScreen({route,navigation}: sendListDataProps) { const survey_Type = [ {key:'PJU', value:'PJU'}, {key:'PERMIT', value:'PERMIT'}, @@ -43,7 +48,7 @@ function SentListScreen({route,navigation}: sendListDataProps) { const [alertOffline, setAlertOffline] = useState(false); const [connected, setConnected] = useState(true) const storeData = async (value:any) => { - console.log("key",value.case_name) + // console.log("key",value.case_name) try { const jsonValue = JSON.stringify(value); @@ -63,7 +68,7 @@ function SentListScreen({route,navigation}: sendListDataProps) { //save error } - console.log("Done.") + // console.log("Done.") } const deleteById = (name:string) => { if(selectedSurveyType==="PJU"){ @@ -81,18 +86,17 @@ function SentListScreen({route,navigation}: sendListDataProps) { return oldValues.filter((local_data:any) => local_data.company_name !== name) }) } - } const removeValue = async (key:string) => { try { - console.log("keyDelete",key); + // console.log("keyDelete",key); await AsyncStorage.removeItem(key) // await getCount(); } catch(e) { } } const selectSurveyType = () => { - console.log(selectedSurveyType); + // console.log(selectedSurveyType); if(selectedSurveyType==='PJU'){ getDataPJU() } @@ -103,29 +107,57 @@ function SentListScreen({route,navigation}: sendListDataProps) { getDataPermit() } } - + const getDataPJU = async () => { + setLocalStorage([]) + try { + const jsonValue = await AsyncStorage.getAllKeys() + // console.log("All Key",jsonValue) + if(jsonValue.length != 0) { + jsonValue.map((item) => { + if(item != "USER_DATA" && item != "my-jwt"){ + let splited = item.split(" / "); + const objectItem = { + pju_name:splited[0], + pju_type:splited[1], + installation_date:splited[2], + status:splited[3], + keterangan:splited[4], + long:splited[5], + lat:splited[6] + } + // console.log(objectItem); + + if(splited[7] === 'draftPJU'){ + setLocalStorage(oldArray => [...oldArray,objectItem]) + } + } + }) + } + } catch (e) { + // error reading value + } + }; const getDataPDAM = async () => { setLocalStorage([]) try { const jsonValue = await AsyncStorage.getAllKeys() - console.log("All Key",jsonValue) + // console.log("All Key",jsonValue.length) if(jsonValue.length != 0) { jsonValue.map((item) => { if(item != "USER_DATA" && item != "my-jwt"){ let splited = item.split(" / "); - if(splited.length === 8){ + if(splited.length === 7){ const objectItem = { - id:splited[0], - pipe_name:splited[1], - pipe_type:splited[2], - installation_date:splited[3], - status:splited[4], - keterangan:splited[5], - geom:splited[6].split(",") + pipe_name:splited[0], + pipe_type:splited[1], + installation_date:splited[2], + status:splited[3], + keterangan:splited[4], + geom:splited[5].split(",") } - console.log(objectItem); + // console.log(objectItem); - if(splited[7] === 'sentPDAM'){ + if(splited[6] === 'draftPDAM'){ setLocalStorage(oldArray => [...oldArray,objectItem]) } } @@ -146,17 +178,18 @@ function SentListScreen({route,navigation}: sendListDataProps) { jsonValue.map((item) => { if(item != "USER_DATA" && item != "my-jwt"){ let splited = item.split(" / "); - if(splited.length === 6){ + console.log(splited.length); + + if(splited.length === 5){ const objectItem = { - id:splited[0], - company_name:splited[1], - permit_status:splited[2], - location:splited[3], - geom:splited[4].split(",") + company_name:splited[0], + permit_status:splited[1], + location:splited[2], + geom:splited[3].split(",") } - console.log("aaa",objectItem); + // console.log(objectItem); - if(splited[5] === 'sentPermit'){ + if(splited[4] === 'draftPermit'){ setLocalStorage(oldArray => [...oldArray,objectItem]) } } @@ -167,43 +200,10 @@ function SentListScreen({route,navigation}: sendListDataProps) { } catch (error) { } - } - const getDataPJU = async () => { - setLocalStorage([]) - try { - const jsonValue = await AsyncStorage.getAllKeys() - console.log("All Key",jsonValue) - if(jsonValue.length != 0) { - jsonValue.map((item) => { - if(item != "USER_DATA" && item != "my-jwt"){ - let splited = item.split(" / "); - const objectItem = { - id:splited[0], - pju_name:splited[1], - pju_type:splited[2], - installation_date:splited[3], - status:splited[4], - keterangan:splited[5], - long:splited[6], - lat:splited[7] - } - - if(splited[8] === 'sentPJU'){ - setLocalStorage(oldArray => [...oldArray,objectItem]) - } - } - }) - } - } catch (e) { - // error reading value - } - }; const isFocused = useIsFocused(); useEffect(() => { if(isFocused){ - // getData() - // .catch(console.error); const unsubscribe = NetInfo.addEventListener((state) => { setConnected(state.isConnected!) }); @@ -236,7 +236,7 @@ function SentListScreen({route,navigation}: sendListDataProps) { }; const [stringFilter,setStingFilter] = useState('') const handleSearch = (text:string) => { - console.log(text); + // console.log(text); const formattedQuery = text.toLowerCase(); const filteredData = localStorage.filter(data => @@ -248,7 +248,7 @@ function SentListScreen({route,navigation}: sendListDataProps) { const getDataAll = async () => { try { const jsonValue = await AsyncStorage.getAllKeys() - console.log("All",jsonValue) + // console.log("All",jsonValue) // return jsonValue != null ? JSON.parse(jsonValue) : null; } catch (e) { // error reading value @@ -257,7 +257,7 @@ function SentListScreen({route,navigation}: sendListDataProps) { const getDataItem = async () => { try { const jsonValue = await AsyncStorage.getItem("120 / test1 / Structure Damage Missing / SDM-1 / 1. High") - console.log("pure",jsonValue) + // console.log("pure",jsonValue) return jsonValue != null ? JSON.parse(jsonValue) : null; } catch (e) { // error reading value @@ -271,38 +271,115 @@ function SentListScreen({route,navigation}: sendListDataProps) { } const reSend = async (data:any) => { if(connected){ - let result = await fetch(`${PJU_API_URL}/addData`, { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - nama: data.nama, - jenis: data.jenis, - tanggal_installasi: data.date, - status: data.status, - keterangan: data.keterangan, - geom: `POINT(${data.long} ${data.lat})` - }) - }); - const status = result.status - if (status == 201) { - deleteById(data.nama); - removeValue(data.nama+" / "+data.jenis+" / "+data.date+" / "+data.status+" / "+data.keterangan+" / "+data.long+" / "+data.lat+" / draftPJU"); + if(selectedSurveyType==="PJU"){ + try { + const result = { + status: 0, + body: {}, + } + await RNFetchBlob.config({ + trusty : true + }).fetch('POST', `${PJU_API_URL}/addData`,{ + "Accept": 'application/json', + "Content-Type": "application/json", + }, + JSON.stringify({ + nama: data.nama, + jenis: data.jenis, + tanggal_installasi: data.date, + status: data.status, + keterangan: data.keterangan, + geom: `POINT(${data.long} ${data.lat})` + }) + ).then(async (resp) => { + const status = resp.respInfo.status + if (status == 201) { + deleteById(data.nama); + removeValue(data.nama+" / "+data.jenis+" / "+data.date+" / "+data.status+" / "+data.keterangan+" / "+data.long+" / "+data.lat+" / draftPJU"); + } + else { + Alert.alert("Internal Server Error") + } + }) + } catch (error) { + Alert.alert("Internal Server Error") + } } - else { - Alert.alert("Internal Server Error") + if(selectedSurveyType==="PDAM"){ + try { + const obj = { + nama: data.nama, + jenis: data.jenis, + tanggal_installasi: data.date, + status: data.status, + keterangan: data.keterangan, + geom: `MULTILINESTRING((${data.geom}))` + }; + await RNFetchBlob.config({ + trusty : true + }).fetch('POST', `${PDAM_API_URL}/addData`,{ + "Content-Type": "application/json", + }, + JSON.stringify(obj) + ).then(async(resp) => { + const json = resp.json(); + const status = resp.respInfo.status + if (status == 201) { + deleteById(data.nama); + removeValue(data.nama+" / "+data.jenis+" / "+data.date+" / "+data.status+" / "+data.keterangan+" / "+data.geom+" / draftPDAM"); + } + else { + Alert.alert("Internal Server Error") + } + }) + } catch (error) { + Alert.alert("Internal Server Error"); + } + } - } - else{ + if(selectedSurveyType==="PERMIT"){ + try { + const obj = { + company_name: data.company_name, + location: data.location, + permit_status: data.permit_status, + geom: `MULTIPOLYGON (((${data.geom},${String(data.geom).split(",")[0]})))` + } + await RNFetchBlob.config({ + trusty : true + }).fetch('POST', `${PERMIT_API_URL}/addData`,{ + "Content-Type": "application/json", + }, + JSON.stringify(obj) + ).then(async(resp) => { + const json = await resp.json(); + const status = resp.respInfo.status; + if (status == 201) { + deleteById(data.company_name); + removeValue(data.company_name+" / "+data.permit_status+" / "+data.location+" / "+data.geom+" / draftPermit"); + } + else { + Alert.alert("Internal Server Error") + } + }) + } catch (error) { + Alert.alert("Internal Server Error") + } + + } + } + else{ setAlertOffline(true) } - } - const gotoEdit = () => { - } return( + {/* */} + {/* {handleSearch(queryText),setStingFilter(queryText)}} + /> */} }> {selectedSurveyType=="PJU" && localStorage.length != 0? - localStorage.map((item:any,index:number) => ( - - - - Nama JPU - Jenis - Tanggal Installasi - Status - - - : {item.pju_name} - : {item.pju_type} - : {item.installation_date} - : {item.status} - - - - - { - deleteById(item.pju_name); - removeValue(item.id+" / "+item.pju_name+" / "+item.pju_type+" / "+item.installation_date+" / "+item.status+" / "+item.keterangan+" / "+item.long+" / "+item.lat+" / sentPJU"); - }}> - - - - - - - - - { - navigation.navigate('Edit',{ screen: 'Edit',data: { - id:item.id, - nama:item.pju_name, - jenis:item.pju_type, - tanggal_installasi:item.installation_date, - status:item.status, - keterangan:item.keterangan, - long:item.long, - lat:item.lat - }}); - // setLocalStorage([]) - }}> - - - {/* View */} - - - - - - - - - )) - : - selectedSurveyType=="PDAM" && localStorage.length != 0 ? localStorage.map((item:any,index:number) => ( - Nama Pipa + Nama JPU Jenis Tanggal Installasi Status - : {item.pipe_name} - : {item.pipe_type} + : {item.pju_name} + : {item.pju_type} : {item.installation_date} : {item.status} @@ -407,34 +414,33 @@ function SentListScreen({route,navigation}: sendListDataProps) { { - deleteById(item.pipe_name); - removeValue(item.id+" / "+item.pipe_name+" / "+item.pipe_type+" / "+item.installation_date+" / "+item.status+" / "+item.keterangan+" / "+item.geom+" / sentPDAM"); + deleteById(item.pju_name); + removeValue(item.pju_name+" / "+item.pju_type+" / "+item.installation_date+" / "+item.status+" / "+item.keterangan+" / "+item.long+" / "+item.lat+" / draftPJU"); }}> + {/* View */} - { - navigation.navigate('PDAM Editing',{ screen: 'Edit',data: { - id:item.id, - nama:item.pipe_name, - jenis:item.pipe_type, - tanggal_installasi:item.installation_date, + {reSend({ + nama:item.pju_name, + jenis:item.pju_type, + date:Moment(new Date(item.installation_date)).format('YYYY-MM-DD'), status:item.status, keterangan:item.keterangan, - }}); - // setLocalStorage([]) - }}> + long:item.long, + lat:item.lat + })}}> {/* View */} @@ -455,26 +461,28 @@ function SentListScreen({route,navigation}: sendListDataProps) { )) : - selectedSurveyType=="PERMIT" && localStorage.length != 0 ? + selectedSurveyType=="PDAM" && localStorage.length != 0 ? localStorage.map((item:any,index:number) => ( - Company Name - Permit Status - Location + Nama Pipa + Jenis + Tanggal Installasi + Status - : {item.company_name} - : {item.permit_status} - : {item.location} + : {item.pipe_name} + : {item.pipe_type} + : {item.installation_date} + : {item.status} { - deleteById(item.company_name); - removeValue(item.id+" / "+item.company_name+" / "+item.permit_status+" / "+item.location+" / "+item.geom+" / sentPermit"); + deleteById(item.pipe_name); + removeValue(item.pipe_name+" / "+item.pipe_type+" / "+item.installation_date+" / "+item.status+" / "+item.keterangan+" / "+item.geom+" / draftPDAM"); }}> + + + {reSend({ + nama:item.pipe_name, + jenis:item.pipe_type, + date:Moment(new Date(item.installation_date)).format('YYYY-MM-DD'), + status:item.status, + keterangan:item.keterangan, + geom:item.geom + })}}> + + + {/* View */} + + + + + + + + + )) + : + selectedSurveyType=="PERMIT" && localStorage.length != 0 ? + localStorage.map((item:any,index:number) => ( + + + + Company Name + Permit Status + Location + + + : {item.company_name} + : {item.permit_status} + : {item.location} + + - { - navigation.navigate('Permit Editing',{ screen: 'Edit',data: { - id:item.id, - company_name:item.company_name, - permit_status:item.permit_status, - location:item.location, - }}); - // setLocalStorage([]) + { + deleteById(item.company_name); + removeValue(item.company_name+" / "+item.permit_status+" / "+item.location+" / "+item.geom+" / draftPermit"); }}> - {/* View */} + + + {reSend({ + company_name:item.company_name, + permit_status:item.permit_status, + location:item.location, + geom:item.geom + })}}> + + + {/* View */} + + + + - )) - : - Data Kosong - + )) + : + + Data Kosong + } + {/*