esoftplay-event 0.0.0-k → 0.0.0-m

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.
@@ -1,261 +1,261 @@
1
- // noPage
2
- // useLibs
1
+ // // noPage
2
+ // // useLibs
3
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';
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
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
- }
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
21
 
22
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>({})
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
28
 
29
- export default function useFirebaseSocket() {
30
- const [status] = state.useState()
31
- const isDirect = EventTms_homeProperty.state()
29
+ // export default function useFirebaseSocket() {
30
+ // const [status] = state.useState()
31
+ // const isDirect = EventTms_homeProperty.state()
32
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
- }
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
37
 
38
- const auth = () => {
39
- return getAuth()
40
- }
41
- const db = () => {
42
- return getDatabase()
38
+ // const auth = () => {
39
+ // return getAuth()
40
+ // }
41
+ // const db = () => {
42
+ // return getDatabase()
43
43
 
44
- }
44
+ // }
45
45
 
46
- const signInAnonym = () => { }
46
+ // const signInAnonym = () => { }
47
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
- }
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
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
- }
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
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
- }
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
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
- }
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
103
 
104
- function path(...paths: any[]): string {
105
- return paths.join('/')
106
- }
104
+ // function path(...paths: any[]): string {
105
+ // return paths.join('/')
106
+ // }
107
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)
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
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
- }
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
153
 
154
- function getDateTimebyGmt7() {
155
- const ori = new Date()
156
- // const gmt = setTimeOffset(ori)
157
- return ori
158
- }
154
+ // function getDateTimebyGmt7() {
155
+ // const ori = new Date()
156
+ // // const gmt = setTimeOffset(ori)
157
+ // return ori
158
+ // }
159
159
 
160
- // get weather function
160
+ // // get weather function
161
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));
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
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
- }
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
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
- }
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
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
- }
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
221
 
222
- function isInPricingQueueConfig(event_id: string) {
223
- return eventQueueConfig.get(event_id) && eventQueueConfig.get(event_id).limit > 0
224
- }
222
+ // function isInPricingQueueConfig(event_id: string) {
223
+ // return eventQueueConfig.get(event_id) && eventQueueConfig.get(event_id).limit > 0
224
+ // }
225
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
- })
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
233
 
234
- }
235
- const timeout = useInterval()
236
- action()
237
- timeout(() => {
238
- action()
239
- }, 10000)
240
- }
234
+ // }
235
+ // const timeout = useInterval()
236
+ // action()
237
+ // timeout(() => {
238
+ // action()
239
+ // }, 10000)
240
+ // }
241
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
- }
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
+ // }
@@ -61,7 +61,7 @@ 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("event/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", "myprofile")}</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
  :
package/id.json CHANGED
@@ -1849,5 +1849,9 @@
1849
1849
  "header_title": "Gunakan Voucher",
1850
1850
  "label_code": "Kode Voucher",
1851
1851
  "voucher_or_referral_code": "Kode Voucher atau Kode Referral"
1852
+ },
1853
+ "event/header_home": {
1854
+ "search": "Cari...",
1855
+ "myprofile": "Profile saya"
1852
1856
  }
1853
1857
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay-event",
3
- "version": "0.0.0-k",
3
+ "version": "0.0.0-m",
4
4
  "description": "event module on esoftplay framework",
5
5
  "main": "index.js",
6
6
  "scripts": {