esoftplay-event 0.0.0-i → 0.0.0-j

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,7 +132,7 @@ export default function m(props: EventExchange_ticketProps): any {
132
132
  function doSubmit() {
133
133
  inputAccessCode.current?.blur()
134
134
  if (inputAccessCode.current?.getText() == '') {
135
- LibToastProperty.show(esp.lang("visitor/index", "alert_error_not_empty_code"))
135
+ LibToastProperty.show(esp.lang("event/visitor_index", "alert_error_not_empty_code"))
136
136
  inputAccessCode.current?.focus()
137
137
  return
138
138
  }
@@ -220,7 +220,7 @@ export default function m(props: EventExchange_ticketProps): any {
220
220
 
221
221
  <TouchableOpacity onPress={() => { doSubmit() }}>
222
222
  <View style={{ margin: 15, marginTop: 20, height: 35, borderRadius: 5, backgroundColor: "#6c432c", justifyContent: 'center', alignItems: 'center', paddingHorizontal: 9 }} >
223
- <Text allowFontScaling={false} style={{ fontFamily: "ArialBold", fontSize: 12, textAlign: "center", textAlignVertical: 'center', color: 'white', marginRight: 13, marginLeft: 10 }} >{esp.lang("visitor/index", "submit")}</Text>
223
+ <Text allowFontScaling={false} style={{ fontFamily: "ArialBold", fontSize: 12, textAlign: "center", textAlignVertical: 'center', color: 'white', marginRight: 13, marginLeft: 10 }} >{esp.lang("event/visitor_index", "submit")}</Text>
224
224
  </View>
225
225
  </TouchableOpacity>
226
226
 
@@ -0,0 +1,261 @@
1
+ // // noPage
2
+ // // useLibs
3
+
4
+ // import { getAuth } from '@react-native-firebase/auth';
5
+ // import { get, getDatabase, onValue, ref, set } from '@react-native-firebase/database';
6
+ // import { collection, getCountFromServer, getDocs, getFirestore, orderBy, query, where } from '@react-native-firebase/firestore';
7
+ // import { EventTms_homeProperty } from 'esoftplay/cache/event/tms_home/import';
8
+ // import { LibCurl } from 'esoftplay/cache/lib/curl/import';
9
+ // import { LibObject } from 'esoftplay/cache/lib/object/import';
10
+ // import { LibToastProperty } from 'esoftplay/cache/lib/toast/import';
11
+ // import esp from 'esoftplay/esp';
12
+ // import useGlobalState from 'esoftplay/global';
13
+ // import { createTimeout, useInterval } from 'esoftplay/timeout';
14
+
15
+ // function getEventPath() {
16
+ // return "event" + (esp.isDebug("cc") ? "BBT" : "BBO")
17
+ // }
18
+ // function getRandomSuffix(time: number): number {
19
+ // return Number(time + "" + (Math.floor(Math.random() * 9000) + 1000))
20
+ // }
21
+
22
+
23
+ // export const eventIdQueue = useGlobalState(0)
24
+ // export const eventQueueConfig = useGlobalState<any>({})
25
+ // const state = useGlobalState(0)
26
+ // export const lastKeyInPages = useGlobalState<string[]>([])
27
+ // export const userIdKeyReplacer = useGlobalState<any>({})
28
+
29
+ // export default function useFirebaseSocket() {
30
+ // const [status] = state.useState()
31
+ // const isDirect = EventTms_homeProperty.state()
32
+
33
+ // function isInLocal(state: any[], code: string) {
34
+ // const encodedCode = encodeURIComponent(code)
35
+ // return state.findIndex(([url, post]) => (post.qr == encodedCode || post.user_qr == encodedCode)) == -1 ? false : true
36
+ // }
37
+
38
+ // const auth = () => {
39
+ // return getAuth()
40
+ // }
41
+ // const db = () => {
42
+ // return getDatabase()
43
+
44
+ // }
45
+
46
+ // const signInAnonym = () => { }
47
+
48
+ // // ini get yang di live
49
+ // async function _get(path: string, gate_id: string, onDone: (res: any) => void) {
50
+ // let hasDone = false
51
+ // if (isDirect.get()) {
52
+ // new LibCurl('gate_check/' + path + '?t=' + new Date().getTime(), { gate_id }, (res) => {
53
+ // hasDone = true
54
+ // onDone(res)
55
+ // }, (res) => {
56
+ // onDone(res)
57
+ // hasDone = true
58
+ // }, 1)
59
+ // return
60
+ // }
61
+
62
+ // get(ref(getDatabase(), path))
63
+ // .then((sn) => {
64
+ // hasDone = true
65
+ // if (sn.exists()) {
66
+ // onDone(sn.val())
67
+ // } else {
68
+ // onDone(null)
69
+ // }
70
+ // })
71
+ // .catch((e) => {
72
+ // // if (e && !hasDone) {
73
+ // // getBackup(path, (res) => {
74
+ // // if (res) {
75
+ // // onDone(res)
76
+ // // } else {
77
+ // // onDone(null)
78
+ // // }
79
+ // // })
80
+ // // }
81
+ // })
82
+ // }
83
+
84
+ // function listenChangeTime(merchant_id: string, callback: (params: any) => void): () => void {
85
+ // const onChildChange = onValue(ref(getDatabase(), 'merchant_offline/' + merchant_id), (sn) => {
86
+ // if (sn.exists()) {
87
+ // callback(sn.val());
88
+ // }
89
+ // })
90
+ // return () => onChildChange
91
+ // }
92
+
93
+ // async function _set(path: string, data: any, onDone?: (res: any) => void) {
94
+ // const timeout = createTimeout()
95
+ // if (state.get() == 1)
96
+ // set(ref(getDatabase(), path), data)
97
+ // else
98
+ // timeout.set(() => {
99
+ // _set(path, data,)
100
+ // timeout.clear()
101
+ // }, 300);
102
+ // }
103
+
104
+ // function path(...paths: any[]): string {
105
+ // return paths.join('/')
106
+ // }
107
+
108
+ // function addQueue(path: string, event_id: string, onSuccess?: () => void) {
109
+ // const instance: any = esp.mod("firestore/index")().instance()
110
+ // const db = getFirestore(instance)
111
+
112
+ // if (userIdKeyReplacer.get()?.priority == 1) {
113
+ // const coll = collection(db, [getEventPath(), path, event_id].join('/'));
114
+ // const q = query(coll, orderBy('t', 'asc'), where("t", "==", userIdKeyReplacer.get().t));
115
+ // getDocs(q).then((doc) => {
116
+ // if (doc.size == 0) {
117
+ // LibToastProperty.show(esp.lang("event/firebase_socket", "priority_queue_used"))
118
+ // userIdKeyReplacer.set(LibObject.set(userIdKeyReplacer.get(), 0)('priority'))
119
+ // addQueue(path, event_id, onSuccess)
120
+ // } else if (doc.size == 1) {
121
+ // // console.log("SIJI")
122
+ // doc.forEach((d) => {
123
+ // userIdKeyReplacer.set(LibObject.set(userIdKeyReplacer.get(), d.id)('id'))
124
+ // updateQueueExp(path, event_id)
125
+ // new LibCurl('event_booking_waiting_allotment_use', { event_id: event_id })
126
+ // if (onSuccess) onSuccess?.()
127
+ // })
128
+ // } else {
129
+ // LibToastProperty.show("Antrian lebih dari 1", doc.size)
130
+ // }
131
+ // // console.log("SIZE", doc.size)
132
+ // })
133
+ // } else {
134
+ // // console.log("ora")
135
+ // if (userIdKeyReplacer.get()?.id)
136
+ // esp.mod("firestore/index")().deleteDocument?.(instance, [getEventPath?.(), path, event_id, userIdKeyReplacer.get()?.id], () => { }, (e) => { })
137
+ // const ctime = getDateTimebyGmt7().getTime()
138
+ // const time = getRandomSuffix(ctime)
139
+ // const data = { t: ctime, s: time }
140
+ // // console.log(data)
141
+ // esp.mod("firestore/index")().addCollection?.(instance, [getEventPath?.(), path, event_id], data, (dt) => {
142
+ // // console.log("KENE",)
143
+ // userIdKeyReplacer.set?.({
144
+ // id: dt?.id,
145
+ // ...data
146
+ // })
147
+ // if (onSuccess) onSuccess?.()
148
+ // }, (err) => {
149
+ // // console.log(err)
150
+ // })
151
+ // }
152
+ // }
153
+
154
+ // function getDateTimebyGmt7() {
155
+ // const ori = new Date()
156
+ // // const gmt = setTimeOffset(ori)
157
+ // return ori
158
+ // }
159
+
160
+ // // get weather function
161
+
162
+ // function getQueue(path: string, event_id: string, _limit: number, cb: (idx: number, key: string) => void) {
163
+ // const instance: any = esp.mod("firestore/index")().instance()
164
+ // const db = getFirestore(instance)
165
+ // const coll = collection(db, [getEventPath(), path, event_id].join('/'));
166
+ // const q = query(coll, orderBy('s', 'asc'), where("s", "<", userIdKeyReplacer.get().s));
167
+
168
+ // getCountFromServer(q).then((v) => {
169
+ // cb(v.data().count, userIdKeyReplacer.get().id)
170
+ // }).catch((e) => {
171
+ // getQueue(path, event_id, _limit, cb)
172
+ // console.log({ e })
173
+ // })
174
+ // // /* cleanup */
175
+ // // const cdate = getDateTimebyGmt7().getTime()
176
+ // // if (!cdate) {
177
+ // // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_1"))
178
+ // // return
179
+ // // }
180
+ // // if (!_limit) {
181
+ // // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_2"))
182
+ // // return
183
+ // // }
184
+ // // if (!userIdKeyReplacer?.get()?.s) {
185
+ // // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_3"))
186
+ // // return
187
+ // // }
188
+ // // const exp = query(collection(instance, [getEventPath(), path, event_id].join('/')), where("t", "<", cdate - _limit), orderBy('t', 'asc'), limit(10));
189
+ // // const batch = writeBatch(instance);
190
+ // // getDocs(exp).then((expd) => {
191
+ // // expd.forEach((doc) => {
192
+ // // if (Number(doc.data().s) < Number(userIdKeyReplacer.get().s))
193
+ // // batch.delete(doc.ref)
194
+ // // // console.log(doc.data().t < cdate - limit, doc.data().t, cdate - limit, cdate - limit - doc.data().t)
195
+ // // // console.log('->' + moment(new Date(Number(doc.data().t))).localeFormat('DD MMMM YYYY HH:mm:ss'))
196
+ // // // console.log('-->' + moment(new Date(cdate - limit)).localeFormat('DD MMMM YYYY HH:mm:ss') + '\n\n')
197
+ // // })
198
+ // // batch.commit()
199
+ // // })
200
+ // // /* end cleanup */
201
+ // }
202
+
203
+ // function updateQueueExp(path: string, event_id: string) {
204
+ // const instance: any = esp.mod("firestore/index")().instance()
205
+ // esp.mod("firestore/index")().updateDocument(instance, [getEventPath(), path, event_id, userIdKeyReplacer.get().id], [{ key: 't', value: getDateTimebyGmt7().getTime() }], () => { }, (e) => {
206
+ // // updateQueueExp(path, event_id, key)
207
+ // })
208
+ // }
209
+
210
+ // function doneQueue(path: string, event_id: string, key: string, cb: Function) {
211
+ // if (key) {
212
+ // const instance: any = esp.mod("firestore/index")().instance()
213
+ // esp.mod("firestore/index")().deleteDocument(instance, [getEventPath(), path, event_id, key], () => {
214
+ // cb()
215
+ // userIdKeyReplacer.reset()
216
+ // }, (e) => {
217
+ // console.warn(e)
218
+ // })
219
+ // }
220
+ // }
221
+
222
+ // function isInPricingQueueConfig(event_id: string) {
223
+ // return eventQueueConfig.get(event_id) && eventQueueConfig.get(event_id).limit > 0
224
+ // }
225
+
226
+ // function useQueueConfigListener() {
227
+ // function action() {
228
+ // fetch(esp.config("events", "queue") + "?t=" + new Date().getTime(), { "method": "GET" })
229
+ // .then(res => res.json())
230
+ // .then((re) => {
231
+ // eventQueueConfig.set(re)
232
+ // })
233
+
234
+ // }
235
+ // const timeout = useInterval()
236
+ // action()
237
+ // timeout(() => {
238
+ // action()
239
+ // }, 10000)
240
+ // }
241
+
242
+ // return {
243
+ // status,
244
+ // auth,
245
+ // db,
246
+ // signInAnonymously: signInAnonym,
247
+ // get: _get,
248
+ // set: _set,
249
+ // isInLocal,
250
+ // // getQueueConfig,
251
+ // isInPricingQueueConfig,
252
+ // useQueueConfigListener,
253
+ // // isInBookingQueueConfig,
254
+ // addQueue,
255
+ // getQueue,
256
+ // doneQueue,
257
+ // updateQueueExp,
258
+ // listenChangeTime,
259
+ // path
260
+ // }
261
+ // }
@@ -0,0 +1,337 @@
1
+ // noPage
2
+ // useLibs
3
+
4
+ import { EventTms_homeProperty } from 'esoftplay/cache/event/tms_home/import';
5
+ import { LibCurl } from 'esoftplay/cache/lib/curl/import';
6
+ import { LibObject } from 'esoftplay/cache/lib/object/import';
7
+ import { LibToastProperty } from 'esoftplay/cache/lib/toast/import';
8
+ import { LibUtils } from 'esoftplay/cache/lib/utils/import';
9
+ import { UserClass } from 'esoftplay/cache/user/class/import';
10
+ import esp from 'esoftplay/esp';
11
+ import useGlobalState from 'esoftplay/global';
12
+ import { createTimeout, useInterval } from 'esoftplay/timeout';
13
+ import { initializeApp } from 'firebase/app';
14
+ import { createUserWithEmailAndPassword, getAuth, signInWithEmailAndPassword } from 'firebase/auth';
15
+ import { get, getDatabase, onValue, ref, set } from 'firebase/database';
16
+ import { collection, getCountFromServer, getDocs, orderBy, query, where } from 'firebase/firestore';
17
+ import { useLayoutEffect, useRef } from "react";
18
+
19
+ function readDeepObj(obj: any) {
20
+ return function (param?: string, ...params: string[]): any {
21
+ let out: any = obj
22
+ if (param) {
23
+ var _params = [param, ...params]
24
+ if (_params.length > 0)
25
+ for (let i = 0; i < _params.length; i++) {
26
+ out = out?.[_params[i]];
27
+ if (out == undefined) {
28
+ break;
29
+ }
30
+ }
31
+ }
32
+ return out;
33
+ }
34
+ }
35
+
36
+
37
+
38
+ function getBackup(path: string, onDone: (res: any) => void): any {
39
+ // let data = stateBackup.get();
40
+ // const paths = path.split('/');
41
+ // onDone(readDeepObj(data)(...paths))
42
+ }
43
+
44
+ var _installationID: any;
45
+ (async () => {
46
+ _installationID = await LibUtils.getInstallationID()
47
+ })();
48
+
49
+ function getEventPath() {
50
+ return "event" + (esp.isDebug("cc") ? "BBT" : "BBO")
51
+ }
52
+ function getRandomSuffix(time: number): number {
53
+ return Number(time + "" + (Math.floor(Math.random() * 9000) + 1000))
54
+ }
55
+
56
+
57
+ export const eventIdQueue = useGlobalState(0)
58
+ export const eventQueueConfig = useGlobalState<any>({})
59
+ const state = useGlobalState(0)
60
+ export const lastKeyInPages = useGlobalState<string[]>([])
61
+ export const userIdKeyReplacer = useGlobalState<any>({})
62
+
63
+ export default function useFirebaseSocket() {
64
+ const [status] = state.useState()
65
+ const userEmail = UserClass.state().useSelector(t => t?.email)
66
+ const userId = UserClass.state().useSelector(t => t?.id)
67
+ const app = useRef(initializeApp(esp.config().firebase, "BBOGATEv")).current
68
+ const db = useRef(getDatabase(app)).current
69
+ const auth = useRef(getAuth(app)).current
70
+ const isDirect = EventTms_homeProperty.state()
71
+
72
+ function initAppCustom() {
73
+ return esp.mod("firestore/index")().init("CUSTOM", esp.config().firebase)
74
+ }
75
+
76
+ useLayoutEffect(() => {
77
+ if (state.get() == 0 && userEmail && userId) {
78
+ signInAnonym()
79
+ initAppCustom()
80
+ }
81
+ }, [userEmail, userId])
82
+
83
+ function signInAnonym(cb?: () => void) {
84
+ const pass = LibUtils.shorten(userEmail + "" + userId)
85
+ const password = esp.mod("firestore/index")().generatePassword(pass, userEmail)
86
+
87
+ if (state.get() == 1) {
88
+ cb?.()
89
+ return
90
+ } else
91
+ doSign(userEmail, password, cb)
92
+ }
93
+
94
+ function doSign(email: string, password: string, cb?: () => void) {
95
+ signInWithEmailAndPassword(auth, email, password).then(() => {
96
+ state.set(1)
97
+ cb?.()
98
+ }).catch((err) => {
99
+ if (err.code == "auth/user-not-found") {
100
+ doRegisterFirebase(email, password, cb)
101
+ } else {
102
+ throw "ERROR : " + err.code
103
+ }
104
+ })
105
+ }
106
+
107
+ function doRegisterFirebase(email: string, password: string, cb?: () => void) {
108
+ createUserWithEmailAndPassword(auth, email, password)
109
+ .then((userCredential) => {
110
+ state.set(1)
111
+ cb?.()
112
+ })
113
+ .catch((error) => {
114
+ if (error.code == "auth/email-already-in-use") {
115
+ doSign(email, password, cb)
116
+ } else {
117
+ throw "ERROR : " + error.code
118
+ }
119
+ });
120
+ }
121
+
122
+ function isInLocal(state: any[], code: string) {
123
+ const encodedCode = encodeURIComponent(code)
124
+ return state.findIndex(([url, post]) => (post.qr == encodedCode || post.user_qr == encodedCode)) == -1 ? false : true
125
+ }
126
+
127
+ // ini get yang di live
128
+ async function _get(path: string, gate_id: string, onDone: (res: any) => void) {
129
+ let hasDone = false
130
+ if (isDirect.get()) {
131
+ new LibCurl('gate_check/' + path + '?t=' + new Date().getTime(), { gate_id }, (res) => {
132
+ hasDone = true
133
+ onDone(res)
134
+ }, (res) => {
135
+ onDone(res)
136
+ hasDone = true
137
+ }, 1)
138
+ return
139
+ }
140
+
141
+ get(ref(db, path))
142
+ .then((sn) => {
143
+ hasDone = true
144
+ if (sn.exists()) {
145
+ onDone(sn.val())
146
+ } else {
147
+ onDone(null)
148
+ }
149
+ })
150
+ .catch((e) => {
151
+ // if (e && !hasDone) {
152
+ // getBackup(path, (res) => {
153
+ // if (res) {
154
+ // onDone(res)
155
+ // } else {
156
+ // onDone(null)
157
+ // }
158
+ // })
159
+ // }
160
+ })
161
+ }
162
+
163
+ function listenChangeTime(merchant_id: string, callback: (params: any) => void): () => void {
164
+ const onChildChange = onValue(ref(db, 'merchant_offline/' + merchant_id), (sn) => {
165
+ if (sn.exists()) {
166
+ callback(sn.val());
167
+ }
168
+ })
169
+ return () => onChildChange
170
+ }
171
+
172
+ async function _set(path: string, data: any, onDone?: (res: any) => void) {
173
+ const timeout = createTimeout()
174
+ if (state.get() == 1)
175
+ set(ref(db, path), data)
176
+ else
177
+ timeout.set(() => {
178
+ _set(path, data,)
179
+ timeout.clear()
180
+ }, 300);
181
+ }
182
+
183
+ function path(...paths: any[]): string {
184
+ return paths.join('/')
185
+ }
186
+
187
+ function addQueue(path: string, event_id: string, onSuccess?: () => void) {
188
+ const instance = initAppCustom()
189
+ if (userIdKeyReplacer.get()?.priority == 1) {
190
+ const coll = collection(instance.db, [getEventPath(), path, event_id].join('/'));
191
+ const q = query(coll, orderBy('t', 'asc'), where("t", "==", userIdKeyReplacer.get().t));
192
+ getDocs(q).then((doc) => {
193
+ if (doc.size == 0) {
194
+ LibToastProperty.show(esp.lang("lib/firebase_socket", "priority_queue_used"))
195
+ userIdKeyReplacer.set(LibObject.set(userIdKeyReplacer.get(), 0)('priority'))
196
+ addQueue(path, event_id, onSuccess)
197
+ } else if (doc.size == 1) {
198
+ // console.log("SIJI")
199
+ doc.forEach((d) => {
200
+ userIdKeyReplacer.set(LibObject.set(userIdKeyReplacer.get(), d.id)('id'))
201
+ updateQueueExp(path, event_id)
202
+ new LibCurl('event_booking_waiting_allotment_use', { event_id: event_id })
203
+ if (onSuccess) onSuccess?.()
204
+ })
205
+ } else {
206
+ LibToastProperty.show("Antrian lebih dari 1", doc.size)
207
+ }
208
+ // console.log("SIZE", doc.size)
209
+ })
210
+ } else {
211
+ // console.log("ora")
212
+ if (userIdKeyReplacer.get()?.id)
213
+ esp.mod("firestore/index")().deleteDocument?.(instance.db, [getEventPath?.(), path, event_id, userIdKeyReplacer.get()?.id], () => { }, (e) => { })
214
+ const ctime = getDateTimebyGmt7().getTime()
215
+ const time = getRandomSuffix(ctime)
216
+ const data = { t: ctime, s: time }
217
+ // console.log(data)
218
+ esp.mod("firestore/index")().addCollection?.(instance.db, [getEventPath?.(), path, event_id], data, (dt) => {
219
+ // console.log("KENE",)
220
+ userIdKeyReplacer.set?.({
221
+ id: dt.id,
222
+ ...data
223
+ })
224
+ if (onSuccess) onSuccess?.()
225
+ }, (err) => {
226
+ // console.log(err)
227
+ })
228
+ }
229
+ }
230
+
231
+ function getDateTimebyGmt7() {
232
+ const ori = new Date()
233
+ // const gmt = setTimeOffset(ori)
234
+ return ori
235
+ }
236
+
237
+ // get weather function
238
+
239
+ function getQueue(path: string, event_id: string, _limit: number, cb: (idx: number, key: string) => void) {
240
+ const instance = initAppCustom()
241
+ const coll = collection(instance.db, [getEventPath(), path, event_id].join('/'));
242
+ const q = query(coll, orderBy('s', 'asc'), where("s", "<", userIdKeyReplacer.get().s));
243
+
244
+ getCountFromServer(q).then((v) => {
245
+ cb(v.data().count, userIdKeyReplacer.get().id)
246
+ }).catch((e) => {
247
+ getQueue(path, event_id, _limit, cb)
248
+ console.log({ e })
249
+ })
250
+ // /* cleanup */
251
+ // const cdate = getDateTimebyGmt7().getTime()
252
+ // if (!cdate) {
253
+ // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_1"))
254
+ // return
255
+ // }
256
+ // if (!_limit) {
257
+ // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_2"))
258
+ // return
259
+ // }
260
+ // if (!userIdKeyReplacer?.get()?.s) {
261
+ // LibToastProperty.show(esp.lang("lib/firebase_socket", "something_wrong_3"))
262
+ // return
263
+ // }
264
+ // const exp = query(collection(instance.db, [getEventPath(), path, event_id].join('/')), where("t", "<", cdate - _limit), orderBy('t', 'asc'), limit(10));
265
+ // const batch = writeBatch(instance.db);
266
+ // getDocs(exp).then((expd) => {
267
+ // expd.forEach((doc) => {
268
+ // if (Number(doc.data().s) < Number(userIdKeyReplacer.get().s))
269
+ // batch.delete(doc.ref)
270
+ // // console.log(doc.data().t < cdate - limit, doc.data().t, cdate - limit, cdate - limit - doc.data().t)
271
+ // // console.log('->' + moment(new Date(Number(doc.data().t))).localeFormat('DD MMMM YYYY HH:mm:ss'))
272
+ // // console.log('-->' + moment(new Date(cdate - limit)).localeFormat('DD MMMM YYYY HH:mm:ss') + '\n\n')
273
+ // })
274
+ // batch.commit()
275
+ // })
276
+ // /* end cleanup */
277
+ }
278
+
279
+ function updateQueueExp(path: string, event_id: string) {
280
+ const instance = initAppCustom()
281
+ esp.mod("firestore/index")().updateDocument(instance.db, [getEventPath(), path, event_id, userIdKeyReplacer.get().id], [{ key: 't', value: getDateTimebyGmt7().getTime() }], () => { }, (e) => {
282
+ // updateQueueExp(path, event_id, key)
283
+ })
284
+ }
285
+
286
+ function doneQueue(path: string, event_id: string, key: string, cb: Function) {
287
+ if (key) {
288
+ const instance = initAppCustom()
289
+ esp.mod("firestore/index")().deleteDocument(instance.db, [getEventPath(), path, event_id, key], () => {
290
+ cb()
291
+ userIdKeyReplacer.reset()
292
+ }, () => {
293
+ console.warn()
294
+ })
295
+ }
296
+ }
297
+
298
+ function isInPricingQueueConfig(event_id: string) {
299
+ return eventQueueConfig.get(event_id) && eventQueueConfig.get(event_id).limit > 0
300
+ }
301
+
302
+ function useQueueConfigListener() {
303
+ function action() {
304
+ fetch(esp.config("events", "queue") + "?t=" + new Date().getTime(), { "method": "GET" })
305
+ .then(res => res.json())
306
+ .then((re) => {
307
+ eventQueueConfig.set(re)
308
+ });
309
+
310
+ }
311
+ const timeout = useInterval()
312
+ action()
313
+ timeout(() => {
314
+ action()
315
+ }, 10000)
316
+ }
317
+
318
+ return {
319
+ status,
320
+ auth,
321
+ db,
322
+ signInAnonymously: signInAnonym,
323
+ get: _get,
324
+ set: _set,
325
+ isInLocal,
326
+ // getQueueConfig,
327
+ isInPricingQueueConfig,
328
+ useQueueConfigListener,
329
+ // isInBookingQueueConfig,
330
+ addQueue,
331
+ getQueue,
332
+ doneQueue,
333
+ updateQueueExp,
334
+ listenChangeTime,
335
+ path
336
+ }
337
+ }
@@ -8,17 +8,10 @@ import { EventTms_homeProperty } from 'esoftplay/cache/event/tms_home/import';
8
8
  import { LibCurl } from 'esoftplay/cache/lib/curl/import';
9
9
  import { LibObject } from 'esoftplay/cache/lib/object/import';
10
10
  import { LibToastProperty } from 'esoftplay/cache/lib/toast/import';
11
- import { LibUtils } from 'esoftplay/cache/lib/utils/import';
12
11
  import esp from 'esoftplay/esp';
13
12
  import useGlobalState from 'esoftplay/global';
14
13
  import { createTimeout, useInterval } from 'esoftplay/timeout';
15
14
 
16
-
17
- var _installationID: any;
18
- (async () => {
19
- _installationID = await LibUtils.getInstallationID()
20
- })();
21
-
22
15
  function getEventPath() {
23
16
  return "event" + (esp.isDebug("cc") ? "BBT" : "BBO")
24
17
  }
package/event/header.tsx CHANGED
@@ -35,9 +35,11 @@ export interface EventHeaderProps {
35
35
  onPressMore?: () => void,
36
36
  onPressLogout?: () => void,
37
37
  onPressShare?: () => void,
38
+ showCountry?: boolean
38
39
  }
39
40
  export default function m(props: EventHeaderProps): any {
40
41
  const counter = UserNotification.state().useSelector(s => s.unread)
42
+ const countryImage = esp.modProp("user/location_gps").currentCountryState.useSelector((s: any) => s?.image)
41
43
  let inputSearch: any = useRef<TextInput>(null)
42
44
  let query: string = ''
43
45
 
@@ -113,6 +115,16 @@ export default function m(props: EventHeaderProps): any {
113
115
  <LibIcon name="sort-variant" color="#6F442D" />
114
116
  </TouchableOpacity>
115
117
  }
118
+ {/* {
119
+ props?.showCountry &&
120
+ <Pressable onPress={() => {
121
+ LibNavigation.navigateForResult("user/location_country_server", undefined, 15).then((value) => {
122
+ esp.modProp("user/location_gps").findCountryByCountryCode(value.code)
123
+ })
124
+ }} style={{ alignItems: "center", justifyContent: "center", width: 30, height: 30, borderRadius: 15, borderWidth: 1, borderColor: "#e6e6e6", overflow: "hidden" }} >
125
+ <LibPicture source={{ uri: countryImage || "https://cdn.jsdelivr.net/npm/round-flag-icons@1.3.0/flags/id.svg" }} style={{ width: 30, height: 30 }} resizeMode='contain' />
126
+ </Pressable>
127
+ } */}
116
128
  </View>
117
129
  </View>
118
130
  )
@@ -61,14 +61,14 @@ export default function m(props: EventHeader_homeProps): any {
61
61
  {
62
62
  props.title ?
63
63
  <View style={{ marginHorizontal: 11, flex: 1 }} >
64
- <Text allowFontScaling={false} style={{ fontFamily: "Arial", fontSize: 14, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: "#70472b" }} >{props.title || esp.lang("component/header_home", "profile")}</Text>
64
+ <Text allowFontScaling={false} style={{ fontFamily: "Arial", fontSize: 14, fontWeight: "bold", fontStyle: "normal", letterSpacing: 0, color: "#70472b" }} >{props.title || esp.lang("event/header_home", "profile")}</Text>
65
65
  {props.subtitle && <Text allowFontScaling={false} style={{ fontFamily: "ArialBold", fontSize: 12, letterSpacing: 0, color: "#e5e5e5", marginTop: 3 }} >{props.subtitle}</Text>}
66
66
  </View>
67
67
  :
68
68
  <TouchableOpacity testID='search-bar' onPress={() => props.onPress()} style={{ flex: 1 }} >
69
69
  <View style={{ marginLeft: 15, height: 20, borderRadius: 20, backgroundColor: 'white', flexDirection: "row", alignItems: 'center', flex: 1, marginHorizontal: 12 }} >
70
70
  <LibPicture style={{ height: 15, width: 15, marginLeft: 6, marginRight: 6 }} source={esp.assets('icons/ic_search.png')} />
71
- <Text allowFontScaling={false} style={{ fontFamily: "ArialBold", fontSize: 12, color: "#e5e5e5" }} >{esp.lang("component/header_home", "search")}</Text>
71
+ <Text allowFontScaling={false} style={{ fontFamily: "ArialBold", fontSize: 12, color: "#e5e5e5" }} >{esp.lang("event/header_home", "search")}</Text>
72
72
  </View>
73
73
  </TouchableOpacity>
74
74
  }