Skip to content

Commit

Permalink
fix: ui fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitShogun committed Apr 4, 2024
1 parent fe156b6 commit 9dc0d3e
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 88 deletions.
9 changes: 5 additions & 4 deletions apps/retail/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const cartIconBlackList: string[] = [
'/paymentMode',
'/signUp',
'/invoiceDetails',
'/'
'/',
'/cart'
]

const backIconList = ['/', '/signin']
Expand Down Expand Up @@ -128,10 +129,10 @@ const TopHeader: React.FC<TopHeaderProps> = ({ handleMenuClick }) => {
>
<Box className={styles.top_header_wrapper}>
<Box>
{/* <Image
src="/images/Suppliflow_app_logo.svg"
<Image
src="/images/headerLogo.svg"
alt="App logo"
/> */}
/>
</Box>
<Flex columnGap={['10px', '10px', '2rem', '2rem']}>
{!homeIconBlackList.includes(router.pathname) && (
Expand Down
1 change: 1 addition & 0 deletions apps/retail/lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DOMAIN = 'retail:1.1.0'
5 changes: 3 additions & 2 deletions apps/retail/pages/cart/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Cart as BecknCart } from '@beckn-ui/becknified-components'
import { useSelectMutation } from '@services/select'
import { getSelectPayload } from './cart.utils'
import { cartActions } from '@store/cart-slice'
import { DOMAIN } from '@lib/config'

import { ICartRootState } from '@lib/types'
import { DiscoveryRootState } from '@store/discovery-slice'
Expand All @@ -24,7 +25,7 @@ const Cart = () => {
const { transactionId, productList } = useSelector((state: DiscoveryRootState) => state.discovery)

useEffect(() => {
fetchQuotes(getSelectPayload(items, transactionId))
fetchQuotes(getSelectPayload(items, transactionId, DOMAIN))
}, [totalQuantity])

const onOrderClick = () => {
Expand Down Expand Up @@ -53,7 +54,7 @@ const Cart = () => {
dispatch(cartActions.removeItemFromCart(id))
}
})),
loader: { text: 'Loading....' },
loader: { text: 'Loading cart' },
orderSummary: {
totalAmount: {
price: totalAmount
Expand Down
12 changes: 7 additions & 5 deletions apps/retail/pages/cart/cart.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const getSelectPayload = (inputData: any, transactionId: string, domain =
const orderIndex = orders.findIndex(order => order.provider.id === item.providerId)
const newItem = {
id: item.id,
selected: {
quantity: {
quantity: {
selected: {
count: item.quantity
}
}
Expand All @@ -52,9 +52,11 @@ export const getSelectPayload = (inputData: any, transactionId: string, domain =
provider: {
id: item.providerId
},
fulfillments: item.fulfillments.map(fulfillment => ({
id: fulfillment.id
}))
fulfillments:
item.fulfillments &&
item.fulfillments.map(fulfillment => ({
id: fulfillment.id
}))
})
}
})
Expand Down
22 changes: 16 additions & 6 deletions apps/retail/pages/checkout/checkout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { Box, Flex, Text, Stack, Checkbox } from '@chakra-ui/react'

import { DOMAIN } from '@lib/config'
import { useLanguage } from '../../hooks/useLanguage'

import { CartItemForRequest, DataPerBpp, ICartRootState, TransactionIdRootState } from '@lib/types/cart'
Expand All @@ -18,7 +18,7 @@ import { Checkout } from '@beckn-ui/becknified-components'

import { Router, useRouter } from 'next/router'
import { ShippingFormInitialValuesType } from '@beckn-ui/becknified-components'
import { CheckoutRootState } from '@store/checkout-slice'
import { CheckoutRootState, checkoutActions } from '@store/checkout-slice'
import { cartActions } from '@store/cart-slice'
import cart from '@beckn-ui/becknified-components/src/components/cart'

Expand Down Expand Up @@ -62,15 +62,16 @@ const CheckoutPage = () => {
pinCode: '75001'
})

const [isBillingSame, setIsBillingSame] = useState(true)

const router = useRouter()
const initRequest = useRequest()
const dispatch = useDispatch()
const [initialize, { isLoading }] = useInitMutation()
const { t, locale } = useLanguage()
const cartItems = useSelector((state: ICartRootState) => state.cart.items)
const totalAmount = useSelector((state: ICartRootState) => state.cart.totalAmount)
const initResponse = useSelector((state: CheckoutRootState) => state.checkout.initResponse)
console.log('Dank init', initResponse)
const isBillingSameRedux = useSelector((state: CheckoutRootState) => state.checkout.isBillingSame)
const { transactionId, productList } = useSelector((state: DiscoveryRootState) => state.discovery)

useEffect(() => {
Expand Down Expand Up @@ -119,9 +120,13 @@ const CheckoutPage = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [billingFormData])

// useEffect(()=>{
// setIsBillingSame(isBillingSameRedux)
// },[])

const formSubmitHandler = (data: any) => {
if (data) {
getInitPayload(data, billingFormData, cartItems, transactionId)
getInitPayload(data, billingFormData, cartItems, transactionId, DOMAIN)
.then(res => {
console.log('Dank checkout', res)
return initialize(res)
Expand Down Expand Up @@ -163,7 +168,7 @@ const CheckoutPage = () => {
title: singleItem.name,
description: singleItem.short_desc,
quantity: singleItem.quantity,
priceWithSymbol: `${t.currencySymbol}${totalAmount}`,
priceWithSymbol: `${t.currencySymbol}${singleItem.totalPrice}`,
image: singleItem.images[0].url
}))
},
Expand All @@ -187,6 +192,11 @@ const CheckoutPage = () => {
sectionTitle: 'Billing',
formTitle: 'Add Billing Details',
isBilling: true,
isChecked: isBillingSameRedux,
onCheckChange: () => {
// setIsBillingSame(!isBillingSame)
dispatch(checkoutActions.setIsBillingSame({ isBillingSame: !isBillingSameRedux }))
},
showDetails: isInitResultPresent(),
shippingDetails: {
name: submittedDetails.name,
Expand Down
9 changes: 5 additions & 4 deletions apps/retail/pages/checkout/checkout.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ export const getInitPayload = async (
deliveryAddress: any,
billingAddress: any,
cartItems: any,
transaction_id: string
transaction_id: string,
domain: string = 'retail:1.1.0'
) => {
const cityData = await geocodeFromPincode(deliveryAddress.pinCode)

Expand All @@ -192,7 +193,7 @@ export const getInitPayload = async (
transaction_id: transaction_id,
bpp_id: bpp_id,
bpp_uri: items[0].bpp_uri,
domain: 'retail'
domain: domain
},
message: {
orders: transformOrdersByProvider(items)
Expand All @@ -214,8 +215,8 @@ export const getInitPayload = async (
const providerId = group[0].providerId
const items = group.map(item => ({
id: item.id,
selected: {
quantity: {
quantity: {
selected: {
count: item.quantity
}
}
Expand Down
71 changes: 65 additions & 6 deletions apps/retail/pages/product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ import Router from 'next/router'
import React, { useEffect, useState } from 'react'
import { ProductDetailPage } from '@beckn-ui/becknified-components'
import { RetailItem } from '@lib/products'
import { ProductCard } from '@beckn-ui/becknified-components'
import { LocalStorage, ICartProduct, ICart, LocalStorageCart, LocalStorageCartItem } from '@lib/types'
import { cartActions } from '@store/cart-slice'
import { useDispatch, useSelector } from 'react-redux'
import useResponsive from '@beckn-ui/becknified-components/src/hooks/useResponsive'
import { toast } from 'react-toastify'
import { setLocalStorage, getLocalStorage, addLocalStorage } from '@utils/localstorage'
import { fromBinary } from '@utils/common-utils'
import { useRouter } from 'next/router'
import { DiscoveryRootState } from '@store/discovery-slice'
import { Box, Flex, useTheme } from '@chakra-ui/react'
import { Button, CustomThemeType, Input, Typography } from '@beckn-ui/molecules'

const Product = () => {
const theme = useTheme<CustomThemeType>()
const selectedProduct = useSelector((state: DiscoveryRootState) => state.discovery.selectedProduct)
const productList = useSelector((state: DiscoveryRootState) => state.discovery.productList)
const { isMobile, isTablet, isDesktop } = useResponsive()
console.log('Dank list', productList, isMobile, isTablet, isDesktop)
const dispatch = useDispatch()
const [counter, setCounter] = useState(1)
const [totalPrice, setTotalPrice] = useState(selectedProduct.item.price.value)
Expand All @@ -34,22 +40,33 @@ const Product = () => {
setTotalPrice(newTotalPrice)
}
}
const router = useRouter()

if (!selectedProduct) {
return <></>
}
return (
<Box
className="hideScroll"
maxH={'calc(100vh - 100px)'}
overflowY="scroll"
>
<>
<ProductDetailPage
schema={{
productSummary: {
imageSrc: selectedProduct.item.images[0].url,
name: selectedProduct.item.name,
secondaryDescription: selectedProduct.item.long_desc,
// secondaryCTAs:[
// {
// text: 'Add to cart',
// handleClick: () => {
// dispatch(
// cartActions.addItemToCart({
// product: selectedProduct,
// quantity: 1
// })
// )
// toast.success('Product added to cart')
// }
// }
// ],
starRating: {
rating: 4.5,
size: 20,
Expand Down Expand Up @@ -128,8 +145,50 @@ const Product = () => {
}}
/>
</Box>
</Box>
</>
)
}

export default Product

{
/* {
!(isMobile || isTablet) && <Flex overflow='hidden'>
{
Array(5).fill([...productList]).flat().map((singleItem,idx)=>{
const { item } = singleItem
const product = {
id: item.id,
images: item.images.map(singleImage => singleImage.url),
name: item.name,
price: item.price.value,
rating: '4',
shortDesc: item.short_desc
}
return (
<ProductCard
key={idx}
productClickHandler={e => {
e.preventDefault()
dispatch(discoveryActions.addSingleProduct({ product: singleItem }))
router.push({
pathname: '/product',
query: {
id: item.id,
search: searchKeyword
}
})
}}
product={product}
currency={item.price.currency}
/>
)
})
}
</Flex>
} */
}
Loading

0 comments on commit 9dc0d3e

Please sign in to comment.