@snapdragonsnursery/react-components 1.1.16 → 1.1.18

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.16",
3
+ "version": "1.1.18",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -170,10 +170,16 @@ const ChildSearchPage = ({
170
170
  header: "Age",
171
171
  cell: ({ row }) => {
172
172
  const { age_years, age_months } = row.original;
173
- const ageText =
174
- age_years || age_months
175
- ? `${age_years || 0}y ${age_months || 0}m`
176
- : "N/A";
173
+
174
+ // Calculate proper years and months
175
+ let totalMonths = (age_years || 0) * 12 + (age_months || 0);
176
+ let years = Math.floor(totalMonths / 12);
177
+ let months = totalMonths % 12;
178
+
179
+ const ageText = totalMonths > 0
180
+ ? `${years}y ${months}m`
181
+ : "N/A";
182
+
177
183
  return (
178
184
  <div className="flex items-center space-x-2">
179
185
  <span>{ageText}</span>
@@ -316,6 +322,13 @@ const ChildSearchPage = ({
316
322
  const data = await apiResponse.json();
317
323
 
318
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
+
319
332
  setChildren(data.data.children);
320
333
  setPagination(data.data.pagination);
321
334
  trackEvent("child_search_success", {
@@ -433,13 +446,12 @@ const ChildSearchPage = ({
433
446
  <div className="p-6">
434
447
  {/* Search Input */}
435
448
  <div className="relative mb-4">
436
- <MagnifyingGlassIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />
437
449
  <Input
438
450
  type="text"
439
- placeholder="🔧 UPDATED: Search by name or child ID... (v1.1.14)"
451
+ placeholder="🔧 UPDATED: Search by name or child ID... (v1.1.17)"
440
452
  value={searchTerm}
441
453
  onChange={(e) => setSearchTerm(e.target.value)}
442
- className="pl-10"
454
+ className="pl-4"
443
455
  />
444
456
  </div>
445
457
 
@@ -655,9 +667,9 @@ const ChildSearchPage = ({
655
667
  <div className="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
656
668
  <div className="flex items-center justify-between">
657
669
  <div className="text-sm text-gray-600 dark:text-gray-400">
658
- {pagination.totalCount === 0
659
- ? "No children found"
660
- : `Showing ${startItem} to ${endItem} of ${pagination.totalCount} children`}
670
+ {(pagination.totalCount > 0 || children.length > 0)
671
+ ? `Showing ${startItem} to ${endItem} of ${pagination.totalCount || children.length} children`
672
+ : "No children found"}
661
673
  </div>
662
674
  </div>
663
675
  </div>
@@ -725,20 +737,20 @@ const ChildSearchPage = ({
725
737
  )}
726
738
 
727
739
  {/* Pagination */}
728
- {pagination.totalCount > 0 && (
740
+ {(pagination.totalCount > 0 || children.length > 0) && (
729
741
  <div className="px-6 py-4 border-t border-gray-200 dark:border-gray-700">
730
742
  {/* Pagination Info */}
731
743
  <div className="flex items-center justify-between mb-4">
732
744
  <div className="text-sm text-gray-600 dark:text-gray-400">
733
- Page {pagination.page} of {pagination.totalPages}
745
+ Page {pagination.page} of {pagination.totalPages || 1}
734
746
  </div>
735
747
  <div className="text-sm text-gray-600 dark:text-gray-400">
736
- {pagination.totalCount} total children
748
+ {pagination.totalCount || children.length} total children
737
749
  </div>
738
750
  </div>
739
751
 
740
752
  {/* Pagination Controls */}
741
- {pagination.totalPages > 1 && (
753
+ {(pagination.totalPages > 1 || children.length > 0) && (
742
754
  <Pagination>
743
755
  <PaginationContent>
744
756
  <PaginationItem>
@@ -753,12 +765,12 @@ const ChildSearchPage = ({
753
765
 
754
766
  {/* Page numbers */}
755
767
  {Array.from(
756
- { length: pagination.totalPages },
768
+ { length: Math.max(pagination.totalPages, 1) },
757
769
  (_, i) => i + 1
758
770
  )
759
771
  .filter((page) => {
760
772
  const current = pagination.page;
761
- const total = pagination.totalPages;
773
+ const total = Math.max(pagination.totalPages, 1);
762
774
  return (
763
775
  page === 1 ||
764
776
  page === total ||