From cfe063acc7ec5004209168672d519a98446584de Mon Sep 17 00:00:00 2001 From: Sanjai Kumar Date: Sat, 20 Apr 2024 12:01:05 +0530 Subject: [PATCH] Refactor countRequests function to use getTotalRequestCountInCollection in CollectionSettings/Info/index.js --- .../CollectionSettings/Info/index.js | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/Info/index.js b/packages/bruno-app/src/components/CollectionSettings/Info/index.js index f69e0b25aa..3b0a1297be 100644 --- a/packages/bruno-app/src/components/CollectionSettings/Info/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/Info/index.js @@ -1,26 +1,10 @@ import React from 'react'; import StyledWrapper from './StyledWrapper'; - -function countRequests(items) { - let count = 0; - - function recurse(item) { - if (item && typeof item === 'object') { - if (item.type !== 'folder') { - count++; - } - if (Array.isArray(item.items)) { - item.items.forEach(recurse); - } - } - } - - items.forEach(recurse); - - return count; -} +import { getTotalRequestCountInCollection } from 'utils/collections/'; const Info = ({ collection }) => { + const totalRequestsInCollection = getTotalRequestCountInCollection(collection); + return (
General information about the collection.
@@ -44,7 +28,7 @@ const Info = ({ collection }) => { Requests : - {countRequests(collection.items)} + {totalRequestsInCollection}