Last active
          February 5, 2024 14:44 
        
      - 
      
- 
        Save medoevruslan/9cf3c7b5f007b2575f2e27dbc079326c to your computer and use it in GitHub Desktop. 
Revisions
- 
        medoevruslan revised this gist Feb 5, 2024 . 1 changed file with 3 additions and 22 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,7 @@ import * as XLSX from 'xlsx' const handleExportExcel = () => { const filename = 'members.xlsx' const wsData = [ ['First Name', 'Last Name', 'Email', 'Unique ID', 'Plan Name', 'Status'], 
- 
        medoevruslan created this gist Feb 5, 2024 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ const handleExportExcel = () => { if (isLoading || users.length === 0) { return // Do nothing if data is still loading or no users are available } // Filter the users based on the search input values const filteredUsers = users.filter((user) => { const firstNameMatch = user.first_name .toLowerCase() .includes(searchFirstName.toLowerCase()) const lastNameMatch = user.last_name .toLowerCase() .includes(searchLastName.toLowerCase()) const emailMatch = user.email .toLowerCase() .includes(searchEmail.toLowerCase()) const uniqueIdMatch = user.unique_id .toLowerCase() .includes(searchUniqueId.toLowerCase()) return firstNameMatch && lastNameMatch && emailMatch && uniqueIdMatch }) const filename = 'members.xlsx' const wsData = [ ['First Name', 'Last Name', 'Email', 'Unique ID', 'Plan Name', 'Status'], // Loop through the filtered users array and extract the required data ...filteredUsers.map((user) => [ user.first_name, user.last_name, user.email, user.unique_id, user.account_type, user.activated === false ? 'Inactive' : 'Active', ]), ] const ws = XLSX.utils.aoa_to_sheet(wsData) const wb = XLSX.utils.book_new() XLSX.utils.book_append_sheet(wb, ws, 'Members') XLSX.writeFile(wb, filename) }