Skip to content

Commit eba064d

Browse files
Merge pull request #3878 from beckn/staging-1.1.0
Staging 1.1.0
2 parents 39be025 + 5f3d6bd commit eba064d

File tree

10 files changed

+88
-61
lines changed

10 files changed

+88
-61
lines changed

apps/deg-ec/pages/home.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ const Home = () => {
9494
code: 'USA'
9595
}
9696
}
97-
},
98-
{
99-
name: 'IND',
100-
fullName: 'IND',
101-
flag: '/images/india.svg',
102-
data: {
103-
country: {
104-
name: 'India',
105-
code: 'IND'
106-
}
107-
}
10897
}
98+
// {
99+
// name: 'IND',
100+
// fullName: 'IND',
101+
// flag: '/images/india.svg',
102+
// data: {
103+
// country: {
104+
// name: 'India',
105+
// code: 'IND'
106+
// }
107+
// }
108+
// }
109109
]
110110

111111
const experiences: Array<{ title: string; icon: string }> = [

apps/deg-rental/pages/confirmRent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function ConfirmRent() {
2828
const rentalDate = selectedProduct.item.fulfillments[0].state?.name
2929

3030
const handleConfirm = async () => {
31-
const formTimestamp = Math.floor(new Date(startDate).getTime() / 1000)
31+
const formTimestamp = Math.floor(new Date(startDate).getTime() / 1000 + 1)
3232
const toTimestamp = Math.floor(new Date(endDate).getTime() / 1000)
3333
localStorage.setItem('fromTimestamp', formTimestamp.toString())
3434
localStorage.setItem('toTimestamp', toTimestamp.toString())

apps/deg-rental/utilities/checkout-util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export const generateRentalInitPayload = async (
8888
export function calculateDuration(from: number, to: number): number {
8989
if (!from || !to) return 0 // Handle invalid inputs
9090

91-
// Convert milliseconds to hours
91+
// Convert milliseconds to hours and round up
9292
const diffInMs = to - from
93-
const diffInHours = Math.floor(diffInMs / (1000 * 60 * 60))
93+
const diffInHours = Math.ceil(diffInMs / (1000 * 60 * 60))
9494

9595
return diffInHours
9696
}

apps/deg-retail/components/RentalServiceModal/RentalServiceModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ const RentalServiceModal: React.FC<RentalServiceModalProps> = ({ isOpen, onClose
681681
top="50%"
682682
transform="translateY(-50%)"
683683
pointerEvents="none"
684-
zIndex={1}
684+
zIndex={0}
685685
>{`${currencyMap[getCountryCode().country.code as keyof typeof currencyMap]} `}</Text>
686686
<Text color="gray.600">{` per hour`}</Text>
687687
</Flex>

apps/deg-retail/pages/index.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const HomePage = () => {
8888
left={'0'}
8989
background="#fff"
9090
boxShadow={'0px 4px 20px 0px rgba(0, 0, 0, 0.07)'}
91+
pl={'20px'}
92+
pr={'20px'}
9193
>
9294
<Flex
9395
className="sub-header-DEG"
@@ -116,31 +118,33 @@ const HomePage = () => {
116118
/>
117119
)}
118120
</Flex>
119-
{user?.deg_wallet ? (
120-
<></>
121-
) : (
122-
// <Select
123-
// variant="unstyled"
124-
// placeholder={`/subj****${user?.deg_wallet.deg_wallet_id.slice(-4)}`}
125-
// value=""
126-
// style={{
127-
// pointerEvents: 'none'
128-
// }}
129-
// />
130-
<BecknButton
131-
text="Connect Wallet"
132-
handleClick={() => handleModalOpen('wallet')}
133-
sx={{
134-
width: '93px',
135-
height: '30px',
136-
fontSize: '10px',
137-
fontWeight: '400',
138-
padding: '10px',
139-
borderRadius: '6px',
140-
mb: 'unset'
141-
}}
142-
/>
143-
)}
121+
<Box>
122+
{user?.deg_wallet ? (
123+
<></>
124+
) : (
125+
// <Select
126+
// variant="unstyled"
127+
// placeholder={`/subj****${user?.deg_wallet.deg_wallet_id.slice(-4)}`}
128+
// value=""
129+
// style={{
130+
// pointerEvents: 'none'
131+
// }}
132+
// />
133+
<BecknButton
134+
text="Connect Wallet"
135+
handleClick={() => handleModalOpen('wallet')}
136+
sx={{
137+
width: '93px',
138+
height: '30px',
139+
fontSize: '10px',
140+
fontWeight: '400',
141+
padding: '10px',
142+
borderRadius: '6px',
143+
mb: 'unset'
144+
}}
145+
/>
146+
)}
147+
</Box>
144148
</Flex>
145149
<Box
146150
background="#deeaf5"

apps/deg-retail/pages/paymentMode.tsx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ const EMIApplicationModal = ({
118118
const toast = useToast()
119119
const dispatch = useDispatch()
120120
const { user } = useSelector((state: AuthRootState) => state.auth)
121-
const [selectedEmiPlan, setSelectedEmiPlan] = useState<string | null>(null)
122-
const selectedEmi = useSelector((state: any) => state.selectedEmi.apiResponse?.[0]?.message.order.items) || 0
121+
const selectedEmi = useSelector((state: any) => state.selectedEmi.apiResponse?.[0]?.message.order.items) || []
122+
123123
const monthlyInstallment = useSelector((state: any) => state.selectedEmi.emiDetails)
124124

125125
useEffect(() => {
@@ -194,14 +194,15 @@ const EMIApplicationModal = ({
194194
// value = value.toUpperCase() // Convert PAN to uppercase
195195
// if (value.length > 10) return // Limit to 10 characters
196196
// }
197+
if (field === 'ssNumber' && !/^\d*$/.test(value)) {
198+
return // Only allow digits in SS number
199+
}
197200

198201
setFormData(prev => ({
199202
...prev,
200203
[field]: value
201204
}))
202205

203-
dispatch(emiFormActions.updateForm({ [field]: value }))
204-
205206
// Clear error when user starts typing
206207
if (errors[field]) {
207208
setErrors(prev => ({
@@ -231,6 +232,7 @@ const EMIApplicationModal = ({
231232
}
232233

233234
const handleSubmit = () => {
235+
dispatch(emiFormActions.updateForm(formData))
234236
if (validateForm()) {
235237
console.log('Form submitted:', formData)
236238
// Add your submission logic here
@@ -328,7 +330,7 @@ const EMIApplicationModal = ({
328330
<Typography
329331
fontWeight="400"
330332
fontSize="12px"
331-
text="Verified by Vault"
333+
text="Verified by Wallet"
332334
color="#53A052"
333335
/>
334336
)}
@@ -501,14 +503,22 @@ const EMIApplicationModal = ({
501503
<Typography
502504
fontWeight="400"
503505
fontSize="12px"
504-
text="Verified by Vault"
506+
text="Verified by Wallet"
505507
color="#53A052"
506508
/>
507509
)}
508510
</Flex>
509511
<Input
510-
value={formData.ssNumber ? formData.ssNumber.replace(/^(.{5})/g, '*****') : ''}
512+
value={
513+
formData.ssNumber
514+
? document.activeElement?.id === 'ssInput'
515+
? formData.ssNumber
516+
: formData.ssNumber.replace(/^(.{5})/g, '*****')
517+
: ''
518+
}
519+
id="ssInput"
511520
onChange={e => handleInputChange('ssNumber', e.target.value)}
521+
maxLength={9}
512522
paddingInlineStart="unset"
513523
_focusVisible={{ borderColor: errors.ssNumber ? 'red.500' : '#4398E8' }}
514524
border="unset"
@@ -540,7 +550,7 @@ const EMIApplicationModal = ({
540550
<Typography
541551
fontWeight="400"
542552
fontSize="12px"
543-
text="Verified by Vault"
553+
text="Verified by Wallet"
544554
color="#53A052"
545555
/>
546556
)}
@@ -963,7 +973,22 @@ const PaymentMode = (props: PaymentMethodSelectionProps) => {
963973
const handleChange = (id: string) => {
964974
setSelectedPaymentMethod(id)
965975
setCheckedPayment(id === checkedState ? null : id)
976+
dispatch(
977+
setEmiDetails({
978+
emiDetails: [
979+
{
980+
annualInterestRate: 0,
981+
interestAmount: 0,
982+
monthlyInstallment: 0,
983+
totalCost: 0,
984+
processingFee: 0,
985+
deliveryCharges: deliveryCharges
986+
}
987+
]
988+
})
989+
)
966990
setSelectedPlan('')
991+
setSelectedEMIPlanItemId('')
967992
}
968993

969994
const handleFinanceOnConfirm = (data: FormData) => {
@@ -1556,6 +1581,7 @@ const PaymentMode = (props: PaymentMethodSelectionProps) => {
15561581
className="radio-for-emi"
15571582
isChecked={selectedPlan === plan.id}
15581583
onChange={() => {
1584+
setCheckedPayment(null)
15591585
setSelectedPlan(plan.id)
15601586
setSelectedEMIPlanItemId('') // Reset child selection when parent changes
15611587
handleEmiSelect(plan.id)
@@ -1716,6 +1742,7 @@ const PaymentMode = (props: PaymentMethodSelectionProps) => {
17161742
top="10px"
17171743
isChecked={selectedEMIPlanItemId === item.id}
17181744
onChange={() => {
1745+
setCheckedPayment(null)
17191746
setSelectedEMIPlanItemId(item.id)
17201747
// Always select the parent plan when an item is selected
17211748
setSelectedPlan(plan.id)
@@ -1924,7 +1951,8 @@ const PaymentMode = (props: PaymentMethodSelectionProps) => {
19241951
) : (
19251952
openModal &&
19261953
!showSuccess &&
1927-
!checkedPayment && (
1954+
!checkedPayment &&
1955+
selectedEmi.length > 0 && (
19281956
<Box className="btm-modal-payment">
19291957
<EMIApplicationModal
19301958
isOpen={openModal}

apps/deg-retail/pages/retailOrderConfirmation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { feedbackActions } from '@beckn-ui/common'
3232
import { getRentalPayloadForConfirm } from '@utils/confirm-utils'
3333
import { getPayloadForConfirm, getPayloadForOrderHistoryPost } from '@utils/payload'
3434
import { calculateDuration } from '@utils/checkout-util'
35+
import { EmiDetail } from '@store/emiSelect-slice'
3536

3637
const retailOrderConfirmation = () => {
3738
const { t } = useLanguage()
@@ -81,7 +82,7 @@ const retailOrderConfirmation = () => {
8182
const initResponse = useSelector((state: CheckoutRootState) => state.checkout.initResponse)
8283
const confirmResponse = useSelector((state: CheckoutRootState) => state.checkout.confirmResponse)
8384
const cartItems = useSelector((state: ICartRootState) => state.cart.items)
84-
const emiDetails = useSelector((state: any) => state.selectedEmi.emiDetails[0])
85+
const emiDetails: EmiDetail = useSelector((state: any) => state.selectedEmi.emiDetails[0])
8586
const strapiUrl = process.env.NEXT_PUBLIC_STRAPI_URL
8687

8788
const getOrderCategoryId = (type: any) => {

apps/deg-retail/store/emiSelect-slice.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
22

3-
interface EmiDetail {
3+
export interface EmiDetail {
44
monthlyInstallment: number
55
interestAmount: number
66
annualInterestRate: number
77
totalCost: number
88
payableAmount?: number
9+
processingFee?: number
10+
deliveryCharges?: number
911
}
1012

1113
interface ApiResponse {

apps/deg-retail/styles/globals.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,3 @@ input {
517517
.-product_summary_container .css-afhyro {
518518
background: #fff;
519519
}
520-
.sub-header-DEG {
521-
padding: 0 10rem;
522-
}
523-
@media screen and (min-width: 280px) and (max-width: 991px) {
524-
.sub-header-DEG {
525-
padding: 0 20px;
526-
}
527-
}

apps/deg-retail/utilities/payload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const getPayloadForConfirm = (initResponse: InitResponseModel[], cartAndE
3838
Number(item.price.value) * cartAndEmiDetails.cartDetails[order.provider.id][item.id].quantity
3939
)
4040
}, 0) +
41-
Number(cartAndEmiDetails.emiDetails.deliveryCharges) +
42-
Number(cartAndEmiDetails.emiDetails.processingFee)
41+
Number(cartAndEmiDetails?.emiDetails?.deliveryCharges || 0) +
42+
Number(cartAndEmiDetails?.emiDetails?.processingFee || 0)
4343
}`,
4444
currency: order.quote?.price?.currency
4545
},

0 commit comments

Comments
 (0)