Skip to content

Commit

Permalink
Merge pull request #3023 from beckn/fix/retail-externlurl-issue
Browse files Browse the repository at this point in the history
fix(retail): modified ocde to handle external url order details
  • Loading branch information
aniketceminds authored Jan 21, 2025
2 parents 0da0c0a + 97b25fd commit 3a216a5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
18 changes: 15 additions & 3 deletions apps/retail/components/orderDetails/ImportedOrderDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { useLanguage } from '../../hooks/useLanguage'
import BottomModalScan from '@components/BottomModal/BottomModalScan'
import BecknButton from '@beckn-ui/molecules/src/components/button/Button'
import Typography from '@beckn-ui/molecules/src/components/typography/typography'
import { ImportOrderModel } from '@beckn-ui/common/lib/types'
import { ImportOrderModel, PaymentBreakDownModel } from '@beckn-ui/common/lib/types'
import { testIds } from '@shared/dataTestIds'
import { currencyMap } from '@lib/config'

interface OrderDetailsProps {
backOnImportedOrder: (newValue: boolean) => void
Expand All @@ -25,10 +26,21 @@ const OrderDetails: FC<OrderDetailsProps> = ({ backOnImportedOrder, importedOrde
const orderId = importedtObjectOrder.id
const createdAtTimeline = importedOrderObject.payments[0].time.timestamp
console.log(importedtObjectOrder)
const totalPrice = itemData.price.value
// const totalPrice = itemData.price.value
const noOfTravellers = itemData.quantity.selected.count
const providerName = importedOrderObject.provider.descriptor.name

const createPaymentBreakdownMap = () => {
const paymentBreakdownMap: { total: number; currency: string } = { total: 0, currency: 'INR' }
if (importedOrderObject.quote.breakup.length > 0) {
importedOrderObject.quote.breakup.forEach(breakup => {
paymentBreakdownMap['total'] = paymentBreakdownMap['total'] + Number(breakup.price.value)
paymentBreakdownMap['currency'] = breakup.price.currency
})
}
return paymentBreakdownMap
}

const getFormattedDate = (timestamp: string) => {
const date = new Date(timestamp)
const options: Object = { day: 'numeric', month: 'short', year: 'numeric', hour: 'numeric', minute: 'numeric' }
Expand Down Expand Up @@ -119,7 +131,7 @@ const OrderDetails: FC<OrderDetailsProps> = ({ backOnImportedOrder, importedOrde
/>
<Typography
variant="subTitleRegular"
text={`${Number(totalPrice) * noOfTravellers}`}
text={`${(currencyMap as any)[createPaymentBreakdownMap().currency]}${createPaymentBreakdownMap().total}`}
/>
</Flex>
<BecknButton
Expand Down
2 changes: 2 additions & 0 deletions apps/retail/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ const HomePage = () => {
})
const promptType = himalayasTag ? 'HIMALAYAS' : 'PARIS'

console.log(himalayasTag, promptType)

const payload = {
message: {
prompt_type: promptType,
Expand Down
8 changes: 6 additions & 2 deletions packages/common/src/utils/checkout-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export const geocodeFromPincode = async (pincode: string) => {
const { country, state, city } = extractAddressComponents(
response.results[1] ? response.results[1] : response.results[0]
)
const lat = response.results[0].geometry.location.lat()
const lng = response.results[0].geometry.location.lng()
const lat = response.results[1]
? response.results[1].geometry.location.lat()
: response.results[0].geometry.location.lat()
const lng = response.results[1]
? response.results[1].geometry.location.lng()
: response.results[0].geometry.location.lng()
return { country, state, city, lat, lng }
} else {
console.log('No results found')
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/utils/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const getInitPayload = async (
fulfillments: { id: string; type: string } = { id: '3', type: 'Standard-shipping' }
) => {
const cityData = await geocodeFromPincode(deliveryAddress.pinCode!)

console.log(cityData)
const bppGroups = cartItems.reduce((acc: { [key: string]: CartItemForRequest[] }, item) => {
if (!acc[item.bpp_id]) {
acc[item.bpp_id] = []
Expand Down

0 comments on commit 3a216a5

Please sign in to comment.