groovinads-ui 1.2.39 → 1.2.41

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,7 +1,7 @@
1
1
  {
2
2
  "name": "groovinads-ui",
3
3
  "description": "Groovinads UI is a React component library designed exclusively for Groovinads applications. It provides ready-to-use UI elements styled according to Groovinads design guidelines to facilitate rapid development.",
4
- "version": "1.2.39",
4
+ "version": "1.2.41",
5
5
  "keywords": [
6
6
  "css",
7
7
  "sass",
@@ -32,16 +32,10 @@ const DropdownDatePicker = ({
32
32
  dateTo2,
33
33
  setDateTo2,
34
34
  }) => {
35
- const [activeTab, setActiveTab] = useState(1);
35
+ //const [activeTab, setActiveTab] = useState(1);
36
36
 
37
37
  const [compareDates, setCompareDates] = useState(true);
38
38
 
39
- /* State for dropdowns only visible when selecting 'compare dates' option */
40
- const [period1, setPeriod1] = useState('Custom range');
41
- const [detailLevel1, setDetailLevel1] = useState('Daily');
42
-
43
- const [period2, setPeriod2] = useState('Custom range');
44
- const [detailLevel2, setDetailLevel2] = useState('Daily');
45
39
 
46
40
  /* We have a 'local' state for datepickers inside the dropdown, so the user can cancel the dropdown and go back to previous values. */
47
41
  /* When user confirms selected values, the 'local' state replaces the values previously stored in the DateFilters component. */
@@ -49,9 +43,6 @@ const DropdownDatePicker = ({
49
43
  const [editingDateFrom, setEditingDateFrom] = useState(dateFrom);
50
44
  const [editingDateTo, setEditingDateTo] = useState(dateTo);
51
45
 
52
- const [editingDateFrom2, setEditingDateFrom2] = useState(dateFrom2);
53
- const [editingDateTo2, setEditingDateTo2] = useState(dateTo2);
54
-
55
46
  const [internalShow, setInternalShow] = useState(!!show);
56
47
 
57
48
  const { capitalice } = useTextFormatter();
@@ -64,12 +55,6 @@ const DropdownDatePicker = ({
64
55
  setEditingDateTo(end);
65
56
  };
66
57
 
67
- const onChangeDate2 = (dates) => {
68
- const [start, end] = dates;
69
- setEditingDateFrom2(start);
70
- setEditingDateTo2(end);
71
- };
72
-
73
58
  const internalToggle = () => {
74
59
  setInternalShow((prevShow) => !prevShow);
75
60
  try {
@@ -105,7 +90,7 @@ const DropdownDatePicker = ({
105
90
  return (
106
91
  <Dropdown
107
92
  show={internalShow}
108
- className={`${variant === 'filter' ? 'dropdown-filter' : ''}`}
93
+ className={`${variant === 'filter' ? 'dropdown-filter' : ''} ${className}`}
109
94
  >
110
95
  <Dropdown.Toggle
111
96
  variant='toggle-filter'
@@ -16,11 +16,11 @@ const PillComponent = ({
16
16
  <span>{children}</span>
17
17
  {closeButton && (
18
18
  <button onClick={onClick}>
19
- <Icon
20
- style={'solid'}
21
- iconName={'xmark'}
22
- scale={0.7}
23
- />
19
+ <Icon
20
+ style={'solid'}
21
+ iconName={'xmark'}
22
+ scale={0.7}
23
+ />
24
24
  </button>
25
25
  )}
26
26
  </div>
@@ -19,7 +19,6 @@ const DeckDropdown = () => {
19
19
  try {
20
20
  const resp = await ComponentsService.applications();
21
21
  resp.forEach((element) => {
22
- //element.app_icon = `fa-duotone fa-${element.application_icon}`; // Solo para Deck
23
22
  element.app_icon_sm = element.application_icon;
24
23
  element.app_name = element.application_name;
25
24
  });
@@ -34,7 +33,6 @@ const DeckDropdown = () => {
34
33
 
35
34
  const linkToApp = (path, title) => {
36
35
  // if path begins with /, path is a subdomain, linkUrl must be window.location.origin + path + '/'
37
- // else linkUrl must be path
38
36
  let linkUrl;
39
37
  const base_domain = useGetBaseDomain();
40
38
  const nextState = { additionalInformation: 'Updated the URL' };
@@ -43,12 +41,10 @@ const DeckDropdown = () => {
43
41
  if (path.startsWith('/')) {
44
42
  if (base_domain === 'groovinads.com') {
45
43
  linkUrl = window.location.origin + path + '/';
46
- // we update the browser history window.history.pushState({ additionalInformation: 'URL updated' }, title, linkUrl);
47
44
  window.history.pushState(nextState, title, linkUrl);
48
45
  } else {
49
46
  linkUrl = 'https://deck-dev.groovinads.com' + path + '/';
50
47
  }
51
- // Else return complete path
52
48
  } else linkUrl = path;
53
49
 
54
50
  return linkUrl;
@@ -68,8 +64,6 @@ const DeckDropdown = () => {
68
64
  });
69
65
  } catch (error) {
70
66
  console.error('favApp error', error);
71
- //setShowAPIerrorModal(true);
72
- //setErrorModalDetail(`${error}`);
73
67
  }
74
68
  };
75
69
 
@@ -88,8 +82,6 @@ const DeckDropdown = () => {
88
82
  }
89
83
  } catch (error) {
90
84
  console.error('unfavApp error', error);
91
- //setShowAPIerrorModal(true);
92
- //setErrorModalDetail(`${error}`);
93
85
  }
94
86
  };
95
87
 
@@ -144,7 +136,6 @@ const DeckDropdown = () => {
144
136
  className='link-app'
145
137
  >
146
138
  <span className='icon-app'>
147
- {/* <i className={element.app_icon_sm}></i> */}
148
139
  <Icon
149
140
  style={'solid'}
150
141
  iconName={element.app_icon_sm}
@@ -189,7 +180,6 @@ const DeckDropdown = () => {
189
180
  className='link-app'
190
181
  >
191
182
  <span className='icon-app'>
192
- {/* <i className={element.app_icon_sm}></i> */}
193
183
  <Icon
194
184
  style={'solid'}
195
185
  iconName={element.app_icon_sm}
@@ -213,43 +203,6 @@ const DeckDropdown = () => {
213
203
  })}
214
204
  </Dropdown.Menu>
215
205
 
216
- {/* <Dropdown.Menu as={'ul'}>
217
- <Dropdown.Item as={'li'}>
218
- <h4 className='dropdown-header'>Favoritos</h4>
219
- </Dropdown.Item>
220
-
221
- <Dropdown.Item as={'li'}>
222
- <div
223
- onClick={() => {
224
- console.log('link');
225
- }}
226
- className='link-app'
227
- >
228
- <span className='icon-app'>
229
- <Icon
230
- style={'solid'}
231
- iconName={'book'}
232
- scale={1}
233
- />
234
- </span>
235
-
236
- <span>La app va a acá</span>
237
- </div>
238
- <button
239
- className='deck-fav'
240
- onClick={(e) => {
241
- e.stopPropagation();
242
- console.log('fav');
243
- }}
244
- >
245
- <Icon
246
- style={'regular'}
247
- iconName={'star'}
248
- scale={1}
249
- />
250
- </button>
251
- </Dropdown.Item>
252
- </Dropdown.Menu> */}
253
206
  </Dropdown>
254
207
  );
255
208
  };
@@ -13,6 +13,14 @@ const UserDropdown = () => {
13
13
 
14
14
  const [groovinProfile, setGroovinProfile] = useState({});
15
15
 
16
+ const handleLogout = async() => {
17
+ const resp = await ComponentsService.authLogout().then(() => {
18
+ window.location.href = '/';
19
+ }).catch((error) => {
20
+ console.error( error)
21
+ })
22
+ }
23
+
16
24
  useEffect(() => {
17
25
  ComponentsService.authStatus().then((resp) => {
18
26
 
@@ -46,9 +54,7 @@ const UserDropdown = () => {
46
54
  </Dropdown.Toggle>
47
55
  <Dropdown.Menu as={'ul'} align={'end'}>
48
56
  <Dropdown.Item as={'li'}
49
- onClick={() => {
50
- window.location.href = '/logout';
51
- }}
57
+ onClick={handleLogout}
52
58
  >
53
59
  <Icon
54
60
  iconName={'right-from-bracket'}
@@ -11,15 +11,21 @@ import PropTypes from 'prop-types';
11
11
  // COMPONENTES
12
12
  import { Icon } from '../Labels';
13
13
 
14
- const Sidebar = ({ api, customLinks, defaultOpened = true, show, setShow}) => {
15
- const isMobile = useMediaQuery({ query: '(max-width: 992px)' })
14
+ const Sidebar = ({
15
+ api,
16
+ customLinks,
17
+ defaultOpened = true,
18
+ show,
19
+ setShow,
20
+ onNavigate,
21
+ }) => {
22
+ const isMobile = useMediaQuery({ query: '(max-width: 992px)' });
16
23
 
17
24
  const url = window.location.pathname; // to get current url
18
25
 
19
26
  const [sidebarLinks, setSidebarLinks] = useState([]);
20
27
  const [openIndex, setOpenIndex] = useState(null);
21
- console.log('defaultOpened', defaultOpened, isMobile? false : defaultOpened);
22
- const [innerShow, setInnerShow] = useState(isMobile? false : defaultOpened);
28
+ const [innerShow, setInnerShow] = useState(isMobile ? false : defaultOpened);
23
29
 
24
30
  const sidebarRef = useRef(null);
25
31
  const firstOpen = useRef(true);
@@ -43,7 +49,7 @@ const Sidebar = ({ api, customLinks, defaultOpened = true, show, setShow}) => {
43
49
 
44
50
  useEffect(() => {
45
51
  if (isMobile && setShow) setShow(innerShow);
46
- setInnerShow(isMobile ? false : firstOpen.current ? defaultOpened : show)
52
+ setInnerShow(isMobile ? false : firstOpen.current ? defaultOpened : show);
47
53
  firstOpen.current = false;
48
54
  }, []);
49
55
 
@@ -91,31 +97,29 @@ const Sidebar = ({ api, customLinks, defaultOpened = true, show, setShow}) => {
91
97
  <ul className='btn-toggle-nav'>
92
98
  {linkSection.children.map((childSection, x) => (
93
99
  <li key={`childSectionIndex${x}`}>
94
- <a
100
+ <button
95
101
  className={`nav-link ${
96
102
  url === childSection.url ? 'active' : ''
97
103
  }`}
98
- href={childSection.url}
104
+ onClick={() => onNavigate(childSection.url)}
99
105
  >
100
106
  {childSection.name}
101
- </a>
107
+ </button>
102
108
  </li>
103
109
  ))}
104
110
  </ul>
105
111
  </Collapse>
106
112
  </>
107
113
  ) : (
108
- <>
109
- <a
110
- className={`nav-link ${
111
- url === linkSection.url ? 'active' : ''
112
- }`}
113
- href={linkSection.url}
114
- >
115
- <Icon iconName={linkSection.icon} />
116
- {linkSection.name}
117
- </a>
118
- </>
114
+ <button
115
+ className={`nav-link ${
116
+ url === linkSection.url ? 'active' : ''
117
+ }`}
118
+ onClick={() => onNavigate(linkSection.url)}
119
+ >
120
+ <Icon iconName={linkSection.icon} />
121
+ {linkSection.name}
122
+ </button>
119
123
  )}
120
124
  </li>
121
125
  </ul>
@@ -135,6 +139,7 @@ Sidebar.propTypes = {
135
139
  defaultOpened: PropTypes.bool,
136
140
  show: PropTypes.bool, // Add show prop for controlling visibility
137
141
  setShow: PropTypes.func, // Add setShow prop for controlling visibility
142
+ onNavigate: PropTypes.func.isRequired, // Nueva prop para manejar la navegación
138
143
  };
139
144
 
140
145
  export default Sidebar;
@@ -8,7 +8,7 @@ import { Icon } from '../Labels';
8
8
  // HOOKS
9
9
  import useTextFormatter from '../../hooks/useTextFormatter';
10
10
 
11
- function Tabnav({
11
+ function Tabnav({
12
12
  tabs = [],
13
13
  activeTab = 1,
14
14
  navigateTab= false,
@@ -17,7 +17,7 @@ function Tabnav({
17
17
  const { toCamelCase } = useTextFormatter();
18
18
 
19
19
  // initial activeTab (in case it's not sent, it has a default value)
20
- const [activeTabState, setActiveTabState] = useState(activeTab);
20
+ const [activeTabState, setActiveTabState] = useState(activeTab);
21
21
 
22
22
  const handleSelect = (k) => {
23
23
  if (navigateTab) {
@@ -28,7 +28,7 @@ function Tabnav({
28
28
  // console.log('Valor de k:', k);
29
29
  const tabIndex = tabs.findIndex((tab) => toCamelCase(tab.tab) === k) + 1;
30
30
  setActiveTab ? setActiveTab(tabIndex) : setActiveTabState(tabIndex);
31
- }
31
+ }
32
32
  };
33
33
 
34
34
  const formatTabsName = (tab) => {
@@ -42,7 +42,7 @@ function Tabnav({
42
42
  useEffect(() => {
43
43
  setActiveTabState(activeTab);
44
44
  }, [activeTab]);
45
-
45
+
46
46
  return (
47
47
  <Nav
48
48
  variant='tabs'
@@ -65,7 +65,7 @@ function Tabnav({
65
65
  }
66
66
 
67
67
  Tabnav.propTypes = {
68
- tabs: PropTypes.array,
68
+ tabs: PropTypes.array.isRequired,
69
69
  activeTab: PropTypes.number,
70
70
  customFunction: PropTypes.bool,
71
71
  navigateTab: PropTypes.bool,
@@ -3,6 +3,8 @@ import { POST, GET, DELETE } from './helpers';
3
3
 
4
4
  export const authStatus = async () => await GET({ url: urlPath.authStatus });
5
5
 
6
+ export const authLogout = async () => await POST({ url: urlPath.authLogout });
7
+
6
8
  export const applications = async () => await GET({ url: urlPath.applications });
7
9
 
8
10
  export const favApplication = async (appToFav) => await POST({url: `${urlPath.favApps}/${appToFav}`, data: appToFav})
@@ -1,6 +1,8 @@
1
1
  import axios from 'axios';
2
2
  import urlPath from './url.path';
3
3
 
4
+ axios.defaults.withCredentials = true;
5
+
4
6
  export const GET = async ({ url }) => {
5
7
  return await axios
6
8
  .get(url, urlPath.headers)
@@ -9,11 +9,13 @@ export const basePath =
9
9
 
10
10
  export default {
11
11
  authStatus: basePath + 'v2/auth/status',
12
+ authLogout: basePath + 'v2/auth/logout',
12
13
 
13
14
  /* APPS FOR DROPDOWN */
14
15
  applications: basePath + 'v2/applications',
15
16
  favApps: basePath + 'v2/applications/favorite',
16
17
 
18
+
17
19
  headers: {
18
20
  headers: {
19
21
  'Content-Type': 'application/json',
@@ -41,7 +41,7 @@ const Template = (args) => {
41
41
  // onClick={() => handleToggle()}
42
42
  >
43
43
  <span>Add filter</span>
44
- <Icon iconName='fas fa-chevron-down' className='ms-2' />
44
+ <Icon iconName='chevron-down' className='ms-2' />
45
45
  </Button>
46
46
 
47
47
  <DropdownMenu>