saafe-redirection-flow 2.2.0 → 2.2.2

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.
@@ -594,111 +594,133 @@ const DiscoverAccount = ({ state, currentCategory }: DiscoverAccountProps) => {
594
594
  {t('youCanAddUpTo3Numbers')}
595
595
  </p>
596
596
  </div>
597
- {identifiers?.find(i => i.type == 'DOB') ? (
598
- <>
599
- <SectionTitle className='mt-6' title={`DOB*`} />
600
- <div className='flex flex-col gap-1 md:w-[50%] w-full gap-2'>
601
- <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
602
- <PopoverTrigger asChild>
603
- {/* */}
604
- <div
605
- className={`flex h-[56px] w-full items-center justify-between rounded-md border bg-white border-gray-200 dark:border-gray-700 dark:bg-input/30 px-3 py-2 text-muted-foreground dark:border-gray-700 cursor-pointer`}
606
- >
607
- {identifiers?.find(i => i.type === 'DOB')?.value ? (
608
- <span>
609
- {
610
- (() => {
611
- const dobString = identifiers.find(i => i.type === 'DOB')?.value || '';
612
- const [day, month, year] = dobString.split('/');
613
- const dob = new Date(Number(year), Number(month) - 1, Number(day));
614
- return dob.toLocaleDateString('en-IN', {
615
- year: 'numeric',
616
- month: 'long',
617
- day: 'numeric'
618
- });
619
- })()
620
- }
621
- </span>
622
- ) : (
623
- <span className='text-muted-foreground'>Pick a date</span>
624
- )}
625
- <CalendarIcon className={`h-4 w-4 ${decodedInfo?.dob ? 'opacity-30' : 'opacity-50'}`} />
626
- </div>
627
- </PopoverTrigger>
628
- <PopoverContent className='w-auto p-0' align='start'>
629
- <Calendar
630
- mode='single'
631
- captionLayout="dropdown"
632
- hideNavigation
633
-
634
- components={{
635
- DropdownNav: (props: DropdownNavProps) => {
636
- return <div className="flex w-full items-center gap-2">{props.children}</div>;
637
- },
638
-
639
- Dropdown: (props: DropdownProps) => {
640
- return (
641
- <Select
642
- value={String(props.value)}
643
- onValueChange={(value) => {
644
- if (props.onChange) {
645
- handleCalendarChange(value, props.onChange);
646
- }
647
- }}
648
- >
649
- <SelectTrigger className="h-8 w-fit font-medium first:grow">
650
- <SelectValue />
651
- </SelectTrigger>
652
- <SelectContent className="max-h-[min(26rem,var(--radix-select-content-available-height))]">
653
- {props.options?.map((option) => (
654
-
655
- <SelectItem
656
- key={option.value}
657
- value={String(option.value)}
658
- disabled={option.disabled}
659
- >
660
- {option.label}
661
- </SelectItem>
662
- ))}
663
- </SelectContent>
664
- </Select>
665
- );
666
- },
667
- }}
668
- selected={identifiers?.find(i => i.type === 'DOB')?.value ? new Date(identifiers.find(i => i.type === 'DOB')?.value || '') : undefined}
669
- onSelect={(date) => {
670
- if (date) {
671
- const dateValue = date.toLocaleString().split(',')[0]
672
- const result = [...identifiers]
673
- result.splice(
674
- result.findIndex(i => i.type === 'DOB'),
675
- 1,
676
- {
677
- ...identifiers?.find(i => i.type === 'DOB'),
678
- value: dateValue
679
- }
680
- )
681
- setIdentifiers(result)
682
-
683
- // Also update redirect store immediately
684
- const { updateIdentifiers } = useRedirectStore.getState()
685
- updateIdentifiers(undefined, dateValue || undefined)
686
-
687
- setIsPopoverOpen(false)
688
- }
689
- }}
690
- initialFocus
691
- />
692
- </PopoverContent>
693
- </Popover>
694
- </div>
695
- </>
696
- ) : null}
597
+ {identifiers?.find(i => i.type === 'DOB') ? (
598
+ <>
599
+ <SectionTitle className='mt-6' title={`DOB*`} />
600
+ <div className='flex flex-col gap-1 md:w-[50%] w-full gap-2'>
601
+ <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
602
+ <PopoverTrigger asChild>
603
+ <div
604
+ className={`flex h-[56px] w-full items-center justify-between rounded-md border bg-white border-gray-200 dark:border-gray-700 dark:bg-input/30 px-3 py-2 text-muted-foreground cursor-pointer`}
605
+ >
606
+ {/* From backend we are getting data into two types of format */}
607
+ {(() => {
608
+ const rawValue = identifiers.find(i => i.type === 'DOB')?.value || '';
609
+ const dobString = decodeURIComponent(rawValue);
610
+
611
+ let dob: Date | null = null;
612
+ // Check for DD/MM/YYYY format
613
+ if (dobString.includes('/')) {
614
+ const [day, month, year] = dobString.split('/');
615
+ if (!isNaN(Number(day)) && !isNaN(Number(month)) && !isNaN(Number(year))) {
616
+ dob = new Date(Number(year), Number(month) - 1, Number(day));
617
+ }
618
+ }
619
+ // Else treat as ISO
620
+ else if (!isNaN(Date.parse(dobString))) {
621
+ dob = new Date(dobString);
622
+ }
623
+
624
+ return dob ? (
625
+ <span>
626
+ {dob.toLocaleDateString('en-IN', {
627
+ year: 'numeric',
628
+ month: 'long',
629
+ day: 'numeric'
630
+ })}
631
+ </span>
632
+ ) : (
633
+ <span className='text-muted-foreground'>Pick a date</span>
634
+ );
635
+ })()}
636
+ <CalendarIcon
637
+ className={`h-4 w-4 ${decodedInfo?.dob ? 'opacity-30' : 'opacity-50'}`}
638
+ />
639
+ </div>
640
+ </PopoverTrigger>
641
+ <PopoverContent className='w-auto p-0' align='start'>
642
+ <Calendar
643
+ mode='single'
644
+ captionLayout="dropdown"
645
+ hideNavigation
646
+ components={{
647
+ DropdownNav: (props: DropdownNavProps) => (
648
+ <div className="flex w-full items-center gap-2">{props.children}</div>
649
+ ),
650
+ Dropdown: (props: DropdownProps) => (
651
+ <Select
652
+ value={String(props.value)}
653
+ onValueChange={(value) => {
654
+ if (props.onChange) {
655
+ handleCalendarChange(value, props.onChange);
656
+ }
657
+ }}
658
+ >
659
+ <SelectTrigger className="h-8 w-fit font-medium first:grow">
660
+ <SelectValue />
661
+ </SelectTrigger>
662
+ <SelectContent className="max-h-[min(26rem,var(--radix-select-content-available-height))]">
663
+ {props.options?.map(option => (
664
+ <SelectItem
665
+ key={option.value}
666
+ value={String(option.value)}
667
+ disabled={option.disabled}
668
+ >
669
+ {option.label}
670
+ </SelectItem>
671
+ ))}
672
+ </SelectContent>
673
+ </Select>
674
+ )
675
+ }}
676
+ selected={(() => {
677
+ const rawValue = identifiers.find(i => i.type === 'DOB')?.value || '';
678
+ const dobString = decodeURIComponent(rawValue);
679
+ if (dobString.includes('/')) {
680
+ const [day, month, year] = dobString.split('/');
681
+ if (!isNaN(Number(day)) && !isNaN(Number(month)) && !isNaN(Number(year))) {
682
+ return new Date(Number(year), Number(month) - 1, Number(day));
683
+ }
684
+ } else if (!isNaN(Date.parse(dobString))) {
685
+ return new Date(dobString);
686
+ }
687
+ return undefined;
688
+ })()}
689
+ onSelect={(date) => {
690
+ if (date) {
691
+ const dateValue = `${String(date.getDate()).padStart(2, '0')}/${String(date.getMonth() + 1).padStart(2, '0')}/${date.getFullYear()}`;
692
+
693
+ const result = [...identifiers];
694
+ const dobIndex = result.findIndex(i => i.type === 'DOB');
695
+ if (dobIndex !== -1) {
696
+ result.splice(dobIndex, 1, {
697
+ ...result[dobIndex],
698
+ value: dateValue
699
+ });
700
+ }
701
+ setIdentifiers(result);
702
+
703
+ const { updateIdentifiers } = useRedirectStore.getState();
704
+ updateIdentifiers(undefined, dateValue);
705
+
706
+ setIsPopoverOpen(false);
707
+ }
708
+ }}
709
+ initialFocus
710
+ />
711
+ </PopoverContent>
712
+ </Popover>
713
+ </div>
714
+
715
+ </>
716
+ ) : null}
717
+
697
718
  {identifiers?.find(i => i.type == 'PAN') ? (
698
719
  <>
699
720
  <SectionTitle className='mt-6' title={`PAN*`} />
700
721
  <div className='flex flex-col gap-1 md:w-[50%] w-full gap-2'>
701
722
  <Input
723
+ maxLength={10}
702
724
  type='text'
703
725
  className={`h-[56px] bg-white border-gray-200 dark:border-gray-700 text-consent-primary text-md ${validationError.PAN ? 'border-red-500' : ''}`}
704
726
  placeholder={`Enter PAN`}
@@ -717,6 +739,11 @@ const DiscoverAccount = ({ state, currentCategory }: DiscoverAccountProps) => {
717
739
  ...result[panIndex],
718
740
  value: panValue
719
741
  }
742
+
743
+
744
+ if (panIndex === -1) {
745
+ console.log("Just pretending that I am coding.")
746
+ }
720
747
  setIdentifiers(result)
721
748
 
722
749
  // Also update redirect store immediately
@@ -424,6 +424,7 @@ export const useFipStore = create<FipState>()(
424
424
  name: 'saafe-fip-storage',
425
425
  storage: createJSONStorage(() => sessionStorage),
426
426
  partialize: state => ({
427
+ // groupedFip: state.groupedFips,
427
428
  selectedFips: state.selectedFips,
428
429
  activeCategory: state.activeCategory,
429
430
  selectedMobileNumber: state.selectedMobileNumber,
@@ -0,0 +1,3 @@
1
+ const removeUnderscores = (str : string) => str.replace(/_/g, ' ');
2
+
3
+ export default removeUnderscores
Binary file
Binary file