ordering-ui-react-native 0.24.12 → 0.24.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.24.12",
3
+ "version": "0.24.14",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -88,12 +88,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
88
88
  }
89
89
 
90
90
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
91
- if (name !== 'No') {
92
- const pos = position ? `(${position})` : '';
93
- return `${quantity} x ${name} ${pos} +${price}`
94
- } else {
95
- return 'No';
96
- }
91
+ const pos = position ? `(${position})` : ''
92
+ return `${quantity} x ${name} ${pos} +${price}`
97
93
  };
98
94
 
99
95
  /*useEffect(() => {
@@ -284,7 +280,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
284
280
  suboption.position,
285
281
  )
286
282
  : '',
287
- price: parsePrice(suboption.price, { currency: getCurrenySymbol(currency) }),
283
+ price: (['left', 'right'].includes(suboption.position)) ? parsePrice(suboption.half_price ?? suboption.price, { currency: getCurrenySymbol(currency) }) : parsePrice(suboption.price, { currency: getCurrenySymbol(currency) }),
288
284
  })}
289
285
  </OText>
290
286
  </ProductSubOption>
@@ -184,56 +184,56 @@ const MomentOptionUI = (props: MomentOptionParams) => {
184
184
  const validateSelectedDate = (curdate: any, menu: any) => {
185
185
  const day = moment(curdate).format('d')
186
186
  setIsEnabled(menu?.schedule?.[day]?.enabled || false)
187
- }
188
-
189
- const getTimes = (curdate: any, menu: any) => {
187
+ }
188
+
189
+ const getTimes = (curdate: any, menu: any) => {
190
190
  validateSelectedDate(curdate, menu)
191
191
  const date = new Date()
192
192
  var dateSeleted = new Date(curdate)
193
193
  var times = []
194
194
  for (var k = 0; k < menu.schedule[dateSeleted.getDay()].lapses.length; k++) {
195
- var open = {
196
- hour: menu.schedule[dateSeleted.getDay()].lapses[k].open.hour,
197
- minute: menu.schedule[dateSeleted.getDay()].lapses[k].open.minute
198
- }
199
- var close = {
200
- hour: menu.schedule[dateSeleted.getDay()].lapses[k].close.hour,
201
- minute: menu.schedule[dateSeleted.getDay()].lapses[k].close.minute
202
- }
203
- for (var i = open.hour; i <= close.hour; i++) {
204
- if (date.getDate() !== dateSeleted.getDate() || i >= date.getHours()) {
205
- let hour = ''
206
- let meridian = ''
207
- if (is12hours) {
208
- if (i === 0) {
209
- hour = '12'
210
- meridian = ' ' + t('AM', 'AM')
211
- } else if (i > 0 && i < 12) {
212
- hour = (i < 10 ? '0' + i : i)
213
- meridian = ' ' + t('AM', 'AM')
214
- } else if (i === 12) {
215
- hour = '12'
216
- meridian = ' ' + t('PM', 'PM')
217
- } else {
218
- hour = ((i - 12 < 10) ? '0' + (i - 12) : `${(i - 12)}`)
219
- meridian = ' ' + t('PM', 'PM')
220
- }
221
- } else {
222
- hour = i < 10 ? '0' + i : i
223
- }
224
- for (let j = (i === open.hour ? open.minute : 0); j <= (i === close.hour ? close.minute : 59); j += 15) {
225
- if (i !== date.getHours() || j >= date.getMinutes() || date.getDate() !== dateSeleted.getDate()) {
226
- times.push({
227
- text: hour + ':' + (j < 10 ? '0' + j : j) + meridian,
228
- value: (i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j)
229
- })
195
+ var open = {
196
+ hour: menu.schedule[dateSeleted.getDay()].lapses[k].open.hour,
197
+ minute: menu.schedule[dateSeleted.getDay()].lapses[k].open.minute
198
+ }
199
+ var close = {
200
+ hour: menu.schedule[dateSeleted.getDay()].lapses[k].close.hour,
201
+ minute: menu.schedule[dateSeleted.getDay()].lapses[k].close.minute
202
+ }
203
+ for (var i = open.hour; i <= close.hour; i++) {
204
+ if (date.getDate() !== dateSeleted.getDate() || i >= date.getHours()) {
205
+ let hour = ''
206
+ let meridian = ''
207
+ if (is12hours) {
208
+ if (i === 0) {
209
+ hour = '12'
210
+ meridian = ' ' + t('AM', 'AM')
211
+ } else if (i > 0 && i < 12) {
212
+ hour = (i < 10 ? '0' + i : i)
213
+ meridian = ' ' + t('AM', 'AM')
214
+ } else if (i === 12) {
215
+ hour = '12'
216
+ meridian = ' ' + t('PM', 'PM')
217
+ } else {
218
+ hour = ((i - 12 < 10) ? '0' + (i - 12) : `${(i - 12)}`)
219
+ meridian = ' ' + t('PM', 'PM')
220
+ }
221
+ } else {
222
+ hour = i < 10 ? '0' + i : i
223
+ }
224
+ for (let j = (i === open.hour ? open.minute : 0); j <= (i === close.hour ? close.minute : 59); j += 15) {
225
+ if (i !== date.getHours() || j >= date.getMinutes() || date.getDate() !== dateSeleted.getDate()) {
226
+ times.push({
227
+ text: hour + ':' + (j < 10 ? '0' + j : j) + meridian,
228
+ value: (i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j)
229
+ })
230
+ }
231
+ }
230
232
  }
231
- }
232
233
  }
233
- }
234
234
  }
235
235
  return times
236
- }
236
+ }
237
237
 
238
238
  const momento = moment(
239
239
  `${dateSelected} ${timeSelected}`,
@@ -374,8 +374,25 @@ const MomentOptionUI = (props: MomentOptionParams) => {
374
374
  setTimeList(_timeLists)
375
375
  }
376
376
  } else {
377
- const _times = getTimes(selectDate, business)
378
- setTimeList(_times)
377
+ let _times: any = []
378
+ if (business) {
379
+ _times = getTimes(selectDate, business)
380
+ } else {
381
+ _times = hoursList.map(hour => {
382
+ return {
383
+ value: hour.startTime,
384
+ text: is12hours ? (
385
+ hour.startTime.includes('12')
386
+ ? `${hour.startTime}PM`
387
+ : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
388
+ ) : (
389
+ parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
390
+ )
391
+ }
392
+ })
393
+ setIsEnabled(true)
394
+ }
395
+ setTimeList(_times)
379
396
  }
380
397
  }, [dateSelected, hoursList?.length, JSON.stringify(datesWhitelist), JSON.stringify(business)])
381
398