From 963b197afcd52eafd83da696dec4f9c9ad7d7ed4 Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <84461672+sanjai0py@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:46:51 +0530 Subject: [PATCH] Refactor countRequests function to use getTotalRequestCountInCollection in CollectionSettings/Info/index.js (#2140) --- .../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 f69e0b25a..3b0a1297b 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}