@visns-studio/visns-components 5.1.10 → 5.1.12

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
@@ -77,7 +77,7 @@
77
77
  "react-dom": "^17.0.0 || ^18.0.0"
78
78
  },
79
79
  "name": "@visns-studio/visns-components",
80
- "version": "5.1.10",
80
+ "version": "5.1.12",
81
81
  "description": "Various packages to assist in the development of our Custom Applications.",
82
82
  "main": "src/index.js",
83
83
  "files": [
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Link } from 'react-router-dom';
3
+ import dayjs from 'dayjs';
3
4
  import { CircleChevronRight } from 'akar-icons';
4
5
 
5
6
  function Breadcrumb({ data, page }) {
@@ -19,6 +20,15 @@ function Breadcrumb({ data, page }) {
19
20
  ? getNestedData(data, page.parentTitleKey)
20
21
  : null;
21
22
 
23
+ // Function to handle titleKey when it's a nested path like 'event_detail.name'
24
+ const getTitleData = (data, titleKey) => {
25
+ if (typeof titleKey === 'string' && titleKey.includes('.')) {
26
+ const keys = titleKey.split('.'); // Split the nested path by "."
27
+ return getNestedData(data, keys); // Use getNestedData to fetch the nested value
28
+ }
29
+ return data[titleKey]; // If not nested, return the direct data
30
+ };
31
+
22
32
  return (
23
33
  <h1>
24
34
  {page?.parentTitle && page?.parentUrl && (
@@ -71,9 +81,15 @@ function Breadcrumb({ data, page }) {
71
81
  ))}
72
82
  </>
73
83
  ) : (
84
+ // If titleKey is a single string, display the corresponding data
74
85
  <>
75
- {page.titleText && <span>{page.titleText} </span>}
76
- <span>{data[page.titleKey]}</span>
86
+ {page?.titleType && page.titleType === 'date'
87
+ ? dayjs(data[page.titleKey]).format(
88
+ page.titleFormat
89
+ ? page.titleFormat
90
+ : 'DD/MM/YYYY'
91
+ )
92
+ : getTitleData(data, page.titleKey)}
77
93
  </>
78
94
  )}
79
95
  </>
@@ -502,12 +502,37 @@ function GenericDetail({
502
502
 
503
503
  const renderDateTime = () => formatDateTimeValue(value);
504
504
 
505
- const renderFile = () =>
506
- value ? (
507
- <a href={value} target="_blank">
508
- Download
509
- </a>
510
- ) : null;
505
+ const renderFile = () => {
506
+ if (value) {
507
+ return (
508
+ <a href={value} target="_blank">
509
+ Download
510
+ </a>
511
+ );
512
+ } else {
513
+ let fileData = null;
514
+
515
+ if (item.relation?.length > 0) {
516
+ item.relation.forEach((r, rKey) => {
517
+ if (rKey === 0) {
518
+ fileData = data[r];
519
+ } else {
520
+ fileData = fileData[r];
521
+ }
522
+ });
523
+ }
524
+
525
+ if (fileData && fileData.temporary_url) {
526
+ return (
527
+ <a href={fileData.temporary_url} target="_blank">
528
+ Download
529
+ </a>
530
+ );
531
+ } else {
532
+ return null;
533
+ }
534
+ }
535
+ };
511
536
 
512
537
  const renderExist = () => (truncatedValue ? 'Yes' : 'No');
513
538