Skip to content

Commit

Permalink
Merge pull request #3027 from beckn/staging-1.1.0
Browse files Browse the repository at this point in the history
Staging 1.1.0
  • Loading branch information
aniketceminds authored Jan 22, 2025
2 parents 2918254 + 6b49392 commit a0c36df
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 24 deletions.
4 changes: 2 additions & 2 deletions apps/OSC/pages/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 rue du soleil, paris, france',
pinCode: '75001'
pinCode: '75020'
})

const [isBillingAddressSameAsShippingAddress, setIsBillingAddressSameAsShippingAddress] = useState(true)
Expand All @@ -60,7 +60,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 rue du soleil, paris, france',
pinCode: '75001'
pinCode: '75020'
})

const router = useRouter()
Expand Down
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
4 changes: 2 additions & 2 deletions apps/retail/pages/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue Du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)

Expand All @@ -69,7 +69,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue Du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)

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
6 changes: 3 additions & 3 deletions apps/retail/public/images/openCommerce_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/tourismV1.1/pages/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)
const [isBillingAddressSameAsShippingAddress, setIsBillingAddressSameAsShippingAddress] = useState(true)
Expand All @@ -83,7 +83,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)
const theme = useTheme()
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/pages/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue Du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)

Expand All @@ -68,7 +68,7 @@ const CheckoutPage = () => {
mobileNumber: '0612345678',
email: '[email protected]',
address: '15 Rue Du Soleil, Paris, France',
pinCode: '75001'
pinCode: '75020'
}
)

Expand Down
24 changes: 15 additions & 9 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 All @@ -45,8 +49,8 @@ export const getPaymentBreakDown = (initData: InitResponseModel[] | StatusRespon
const quote = initData[0].message.order.quote
const breakUp = quote.breakup
const totalPricewithCurrent = {
currency: quote.price.currency,
value: quote.price.value
value: getSubTotalAndDeliveryCharges(initData).subTotal.toString(),
currency: getSubTotalAndDeliveryCharges(initData).currencySymbol!
}

const breakUpMap: Record<string, any> = {}
Expand All @@ -66,16 +70,18 @@ export const getPaymentBreakDown = (initData: InitResponseModel[] | StatusRespon
return { breakUpMap, totalPricewithCurrent }
}

export const getSubTotalAndDeliveryCharges = (initData: InitResponseModel[]) => {
export const getSubTotalAndDeliveryCharges = (initData: InitResponseModel[] | StatusResponseModel[]) => {
let subTotal: number = 0
let currencySymbol

if (initData && initData.length > 0) {
initData.forEach(data => {
subTotal =
subTotal + Number(parseFloat((Number(data.message.order.quote.price.value) || 0).toString()).toFixed(2))

currencySymbol = data.message.order.quote.price.currency
if (data.message.order.quote.breakup) {
data.message.order.quote.breakup.forEach(breakup => {
subTotal += Number(parseFloat((Number(breakup.price.value) || 0).toString()).toFixed(2))
})
currencySymbol = data.message.order.quote.breakup[0]?.price.currency
}
})
}

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 a0c36df

Please sign in to comment.