@snapdragonsnursery/react-components 1.1.17 → 1.1.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapdragonsnursery/react-components",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -322,6 +322,13 @@ const ChildSearchPage = ({
322
322
  const data = await apiResponse.json();
323
323
 
324
324
  if (data.success) {
325
+ console.log("🔍 API Response:", {
326
+ children: data.data.children.length,
327
+ pagination: data.data.pagination,
328
+ totalCount: data.data.pagination.totalCount,
329
+ totalPages: data.data.pagination.totalPages
330
+ });
331
+
325
332
  setChildren(data.data.children);
326
333
  setPagination(data.data.pagination);
327
334
  trackEvent("child_search_success", {
@@ -413,8 +420,9 @@ const ChildSearchPage = ({
413
420
  };
414
421
 
415
422
  // Calculate pagination display values
416
- const startItem = pagination.totalCount > 0 ? (pagination.page - 1) * pagination.pageSize + 1 : 0;
417
- const endItem = Math.min(pagination.page * pagination.pageSize, pagination.totalCount);
423
+ const actualTotalCount = pagination.totalCount || children.length;
424
+ const startItem = actualTotalCount > 0 ? (pagination.page - 1) * pagination.pageSize + 1 : 0;
425
+ const endItem = Math.min(pagination.page * pagination.pageSize, actualTotalCount);
418
426
 
419
427
  return (
420
428
  <div className="min-h-screen bg-gray-50 dark:bg-gray-900">
@@ -439,13 +447,12 @@ const ChildSearchPage = ({
439
447
  <div className="p-6">
440
448
  {/* Search Input */}
441
449
  <div className="relative mb-4">
442
- <MagnifyingGlassIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400 pointer-events-none" />
443
450
  <Input
444
451
  type="text"
445
- placeholder="🔧 UPDATED: Search by name or child ID... (v1.1.14)"
452
+ placeholder="🔧 UPDATED: Search by name or child ID... (v1.1.17)"
446
453
  value={searchTerm}
447
454
  onChange={(e) => setSearchTerm(e.target.value)}
448
- className="pl-10"
455
+ className="pl-4"
449
456
  />
450
457
  </div>
451
458
 
@@ -661,9 +668,9 @@ const ChildSearchPage = ({
661
668
  <div className="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
662
669
  <div className="flex items-center justify-between">
663
670
  <div className="text-sm text-gray-600 dark:text-gray-400">
664
- {pagination.totalCount === 0
665
- ? "No children found"
666
- : `Showing ${startItem} to ${endItem} of ${pagination.totalCount} children`}
671
+ {(pagination.totalCount > 0 || children.length > 0)
672
+ ? `Showing ${startItem} to ${endItem} of ${actualTotalCount} children`
673
+ : "No children found"}
667
674
  </div>
668
675
  </div>
669
676
  </div>
@@ -731,25 +738,31 @@ const ChildSearchPage = ({
731
738
  )}
732
739
 
733
740
  {/* Pagination */}
734
- {pagination.totalCount > 0 && (
741
+ {(pagination.totalCount > 0 || children.length > 0) && (
735
742
  <div className="px-6 py-4 border-t border-gray-200 dark:border-gray-700">
736
743
  {/* Pagination Info */}
737
744
  <div className="flex items-center justify-between mb-4">
738
745
  <div className="text-sm text-gray-600 dark:text-gray-400">
739
- Page {pagination.page} of {pagination.totalPages}
746
+ Page {pagination.page} of {pagination.totalPages || 1}
740
747
  </div>
741
748
  <div className="text-sm text-gray-600 dark:text-gray-400">
742
- {pagination.totalCount} total children
749
+ {actualTotalCount} total children
743
750
  </div>
744
751
  </div>
745
752
 
746
753
  {/* Pagination Controls */}
747
- {pagination.totalPages > 1 && (
754
+ {(pagination.totalPages > 1 || children.length > 0) && (
748
755
  <Pagination>
749
756
  <PaginationContent>
750
757
  <PaginationItem>
751
- <PaginationPrevious
752
- onClick={() => handlePageChange(pagination.page - 1)}
758
+ <PaginationPrevious
759
+ href="#"
760
+ onClick={(e) => {
761
+ e.preventDefault();
762
+ if (pagination.hasPreviousPage) {
763
+ handlePageChange(pagination.page - 1);
764
+ }
765
+ }}
753
766
  className={cn(
754
767
  !pagination.hasPreviousPage &&
755
768
  "pointer-events-none opacity-50"
@@ -759,12 +772,12 @@ const ChildSearchPage = ({
759
772
 
760
773
  {/* Page numbers */}
761
774
  {Array.from(
762
- { length: pagination.totalPages },
775
+ { length: Math.max(pagination.totalPages, 1) },
763
776
  (_, i) => i + 1
764
777
  )
765
778
  .filter((page) => {
766
779
  const current = pagination.page;
767
- const total = pagination.totalPages;
780
+ const total = Math.max(pagination.totalPages, 1);
768
781
  return (
769
782
  page === 1 ||
770
783
  page === total ||
@@ -780,7 +793,11 @@ const ChildSearchPage = ({
780
793
  </PaginationItem>
781
794
  <PaginationItem>
782
795
  <PaginationLink
783
- onClick={() => handlePageChange(page)}
796
+ href="#"
797
+ onClick={(e) => {
798
+ e.preventDefault();
799
+ handlePageChange(page);
800
+ }}
784
801
  isActive={page === pagination.page}
785
802
  >
786
803
  {page}
@@ -792,7 +809,11 @@ const ChildSearchPage = ({
792
809
  return (
793
810
  <PaginationItem key={page}>
794
811
  <PaginationLink
795
- onClick={() => handlePageChange(page)}
812
+ href="#"
813
+ onClick={(e) => {
814
+ e.preventDefault();
815
+ handlePageChange(page);
816
+ }}
796
817
  isActive={page === pagination.page}
797
818
  >
798
819
  {page}
@@ -802,8 +823,14 @@ const ChildSearchPage = ({
802
823
  })}
803
824
 
804
825
  <PaginationItem>
805
- <PaginationNext
806
- onClick={() => handlePageChange(pagination.page + 1)}
826
+ <PaginationNext
827
+ href="#"
828
+ onClick={(e) => {
829
+ e.preventDefault();
830
+ if (pagination.hasNextPage) {
831
+ handlePageChange(pagination.page + 1);
832
+ }
833
+ }}
807
834
  className={cn(
808
835
  !pagination.hasNextPage &&
809
836
  "pointer-events-none opacity-50"