esoftplay-event 0.0.1 → 0.0.2

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.
Files changed (83) hide show
  1. package/event/artist.tsx +11 -7
  2. package/event/artist_detail.tsx +3 -5
  3. package/event/artist_detailv2.tsx +386 -0
  4. package/event/artistv2.tsx +162 -0
  5. package/event/button_order_detail.tsx +43 -0
  6. package/event/countdown_base.tsx +16 -3
  7. package/event/countdown_event.tsx +47 -0
  8. package/event/detail.tsx +30 -37
  9. package/event/detail2.tsx +354 -0
  10. package/event/exchange_ticket.tsx +1 -1
  11. package/event/exchange_ticket_list.tsx +2 -3
  12. package/event/exchange_ticket_result.tsx +1 -1
  13. package/event/firebase_socket.ts +8 -0
  14. package/event/loading_page.tsx +4 -2
  15. package/event/order.tsx +23 -36
  16. package/event/order_detail.tsx +119 -41
  17. package/event/order_detail_upgrade.tsx +8 -5
  18. package/event/order_detail_upgrade_payment.tsx +17 -11
  19. package/event/order_detail_visitor.tsx +33 -33
  20. package/event/order_detail_waiting.tsx +45 -20
  21. package/event/order_item.tsx +1 -1
  22. package/event/order_lottery.tsx +48 -36
  23. package/event/order_reschedule.tsx +50 -52
  24. package/event/order_share_to.tsx +11 -24
  25. package/event/order_share_to_detail.tsx +8 -3
  26. package/event/order_waiting.tsx +1 -1
  27. package/event/queue_pricing.tsx +16 -3
  28. package/event/refresh_button.tsx +3 -5
  29. package/event/scan_item.tsx +2 -2
  30. package/event/seat.tsx +19 -11
  31. package/event/seat_map_new.tsx +313 -0
  32. package/event/secure_page.debug.tsx +34 -0
  33. package/event/secure_page.live.tsx +35 -0
  34. package/event/secure_page.tsx +6 -5
  35. package/event/test.tsx +240 -155
  36. package/event/ticket_list.tsx +49 -21
  37. package/event/ticket_list2.tsx +83 -34
  38. package/event/tms_check_code.tsx +6 -0
  39. package/event/tms_check_ticket_result.tsx +36 -7
  40. package/event/tms_dashboard.tsx +85 -3
  41. package/event/tms_gate.tsx +6 -0
  42. package/event/tms_home.tsx +1 -4
  43. package/event/tms_in_failed.tsx +1 -1
  44. package/event/tms_in_log.tsx +2 -0
  45. package/event/tms_in_success.tsx +1 -1
  46. package/event/tms_log.tsx +10 -25
  47. package/event/tms_out.tsx +1 -1
  48. package/event/tms_out_failed.tsx +1 -1
  49. package/event/visitor_input.tsx +23 -5
  50. package/event/visitor_inputv2.tsx +397 -0
  51. package/event/voucher.tsx +2 -0
  52. package/event/voucher2.tsx +14 -6
  53. package/id.json +25 -9
  54. package/package.json +1 -1
  55. package/event/entrance.tsx +0 -215
  56. package/event/entrance_again.tsx +0 -199
  57. package/event/entrance_failed.tsx +0 -190
  58. package/event/entrance_idcard.tsx +0 -199
  59. package/event/entrance_list.tsx +0 -264
  60. package/event/entrance_list_item.tsx +0 -88
  61. package/event/entrance_log.tsx +0 -130
  62. package/event/entrance_success.tsx +0 -153
  63. package/event/entrance_warning.tsx +0 -91
  64. package/event/exit.tsx +0 -91
  65. package/event/exit_failed.tsx +0 -135
  66. package/event/exit_list.tsx +0 -118
  67. package/event/exit_log.tsx +0 -130
  68. package/event/exit_success.tsx +0 -143
  69. package/event/exit_temporary.tsx +0 -226
  70. package/event/firebase_socket.debug.ts +0 -260
  71. package/event/firebase_socket.live.ts +0 -335
  72. package/event/hall_in.tsx +0 -148
  73. package/event/hall_in_failed.tsx +0 -270
  74. package/event/hall_in_list.tsx +0 -222
  75. package/event/hall_in_log.tsx +0 -134
  76. package/event/hall_in_success.tsx +0 -132
  77. package/event/hall_out.tsx +0 -143
  78. package/event/hall_out_failed.tsx +0 -133
  79. package/event/hall_out_list.tsx +0 -215
  80. package/event/hall_out_log.tsx +0 -133
  81. package/event/hall_out_success.tsx +0 -130
  82. package/event/log.tsx +0 -433
  83. package/event/seat_map_test.tsx +0 -401
@@ -1,335 +0,0 @@
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 } 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
- setTimeout(() => {
310
- action()
311
- }, 10000);
312
- }
313
- action()
314
- }
315
-
316
- return {
317
- status,
318
- auth,
319
- db,
320
- signInAnonymously: signInAnonym,
321
- get: _get,
322
- set: _set,
323
- isInLocal,
324
- // getQueueConfig,
325
- isInPricingQueueConfig,
326
- useQueueConfigListener,
327
- // isInBookingQueueConfig,
328
- addQueue,
329
- getQueue,
330
- doneQueue,
331
- updateQueueExp,
332
- listenChangeTime,
333
- path
334
- }
335
- }
package/event/hall_in.tsx DELETED
@@ -1,148 +0,0 @@
1
- // withHooks
2
- import { useEffect } from 'react';
3
-
4
- import { EventTms_homeProperty } from 'esoftplay/cache/event/tms_home/import';
5
- import { LibCurl } from 'esoftplay/cache/lib/curl/import';
6
- import { LibLoading } from 'esoftplay/cache/lib/loading/import';
7
- import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
8
- import { LibObject } from 'esoftplay/cache/lib/object/import';
9
- import { UserClass } from 'esoftplay/cache/user/class/import';
10
- import esp from 'esoftplay/esp';
11
- import React from 'react';
12
- import { View } from 'react-native';
13
-
14
-
15
- export interface EventTms_in_hallArgs {
16
-
17
- }
18
- export interface EventTms_in_hallProps {
19
-
20
- }
21
- export default function m(props: EventTms_in_hallProps): any {
22
- const { scan_type, url_ticket_update, url_ticket_detail, price_type, gate_type, qr_code, event_id, selectGate, typeScanner, event_title, configPriority }: any = LibNavigation.getArgsAll<any>(props)
23
-
24
- let args = {
25
- selectGate: selectGate,
26
- fromPage: 'event/tms_home',
27
- event_id: event_id,
28
- event_title: event_title,
29
- typeScanner: typeScanner,
30
- gate_type: gate_type,
31
- price_type: price_type,
32
- url_ticket_detail: url_ticket_detail,
33
- url_ticket_update: url_ticket_update,
34
- configPriority: configPriority,
35
- scan_type: scan_type
36
- }
37
- useEffect(() => {
38
- loadData()
39
- }, [])
40
-
41
- function loadData() {
42
- EventTms_homeProperty.addCounterHallInScan(1, "0")
43
-
44
- var post = {
45
- event_id: event_id,
46
- user_qr: qr_code,
47
- hall_id: selectGate?.id
48
- }
49
-
50
- let ticketsData: any[] = [];
51
-
52
- new LibCurl('event_tms_hall', post, (res) => {
53
- res?.list?.forEach((item: any, i: number) => {
54
- let foundIndex = ticketsData.findIndex((x: any) => x.price_id == item.price_id);
55
-
56
- let newItem = {
57
- ...item,
58
- checked: 0
59
- }
60
-
61
- if (foundIndex != -1) {
62
- ticketsData[foundIndex].list.push(newItem);
63
- ticketsData[foundIndex].qty += 1
64
- } else {
65
- ticketsData.push({
66
- price_id: item.price_id,
67
- price_name: item.price_name,
68
- qty: 1,
69
- list: [newItem]
70
- });
71
- }
72
- });
73
-
74
- esp.log({ res });
75
-
76
- if (res?.hasOwnProperty("staff")) {
77
- res?.staff?.map((it: any) => {
78
- let x = {
79
- ...it,
80
- price_id: "staff",
81
- user_name: it.name,
82
- user_image: it.image,
83
- exhibitor_name: it.department_name + "-" + it.exhibitor_name,
84
- checked: 0
85
- }
86
- ticketsData.push(x)
87
- })
88
- }
89
-
90
- if (ticketsData.length == 1) { // cek jika tiket cuma 1
91
- let tiket = ticketsData[0]
92
- if (tiket.price_id == "staff") { // jika itu adalah id card
93
- if (tiket.status_scanned == 2) {
94
- /* 0 tidak diperbolehkan, 1 sudah didalam, 2 available */
95
- LibNavigation.replace('event/tms_idcard', {
96
- selectedTicket: { ...tiket, key: qr_code },
97
- hall: "in",
98
- ...args
99
- })
100
- } else {
101
- let err = {
102
- message: tiket.status_label,
103
- result: tiket.scanned_detail
104
- }
105
- LibNavigation.replace('event/tms_in_hall_failed', { msgError: err, ...args, postGetData: post })
106
- }
107
- } else { // jika itu adalah tiket
108
- if (tiket.list?.length > 1) { // jika tiket itu mempunyai banyak qty
109
- LibNavigation.replace('event/tms_in_hall_list', { data: ticketsData, ...args })
110
- } else { // jika tiket itu cuma 1 qty
111
- let defaultUse = LibObject.set(tiket?.list, tiket?.list?.[0]?.status_scanned != 2 ? 1 : 0)(0, 'checked')
112
- let a = defaultUse?.filter((item: any) => item.checked == 1 && item.status_scanned != 2).map((it: any) => it.id)
113
- let postOut = {
114
- event_id: event_id,
115
- ids: JSON.stringify(a),
116
- hall_id: selectGate?.id,
117
- trx_id: new Date().getTime() + "" + UserClass.state().get()?.id,
118
- price_id: defaultUse?.filter((item: any) => item.checked == 1 && item.status_scanned != 2).map((it: any) => it.price_id)
119
- }
120
- if (a.length > 0) { // jika tiket itu bisa di pakai
121
- let urlOut = "event_tms_hall_confirm"
122
- LibNavigation.replace('event/tms_in_hall_success', { data: [tiket], ...args, url: urlOut, post: postOut })
123
- } else { // jika tiket itu tidak bisa dipakai
124
- let err = {
125
- message: tiket?.list?.[0]?.status_label,
126
- }
127
- LibNavigation.replace('event/tms_in_hall_failed', { msgError: err, ...args, postGetData: post })
128
- }
129
- }
130
- }
131
- } else { // jika punya tiket banyak
132
- LibNavigation.replace('event/tms_in_hall_list', { data: ticketsData, ...args })
133
- }
134
-
135
- }, (error) => { // jika tidak punya tiket
136
- esp.log({ error });
137
-
138
- LibNavigation.replace('event/tms_in_hall_failed', { msgError: error, ...args, postGetData: post })
139
- }, 1)
140
- }
141
-
142
-
143
- return (
144
- <View style={{ flex: 1, backgroundColor: '#fff' }}>
145
- <LibLoading />
146
- </View>
147
- )
148
- }