I would prefer not to add another database table just to differentiate between team members and friends. Can you provide assistance with this?

Instead of creating another table named friends in Strapi and linking it to Visual Studio Code, I have opted to use a Characters table for both team members and friends. This way, I can input new data only at Characters and filter it to differentiate between friends and team members. I attempted to create a function to determine if someone is a friend by checking if they have both a start and end date or just a start date. Here is the source code:

import Head from 'next/head'
import Layout from '../../components/Layout'
import styles from '../../styles/Home.module.css'
import fetchFromCMS from '../../lib/service';

import React, { Component } from 'react';
import "react-responsive-carousel/lib/styles/carousel.min.css";
import { Carousel } from 'react-responsive-carousel';

export async function getStaticProps() {
    const characters = await fetchFromCMS('characters');
    return {
      props: { characters},
      revalidate: 1,
    };
  }

function sortByDate(a , b){
  return new Date(a.StartDate) - new Date(b.StartDate);
}
function isFriend(a ){ 
  var bool = true;
  new Date(a.EndDate) !=  null? bool = true : bool= false;
 
  return  bool  ;
}

const charactersItem = ({ characters }) => {

        return (
      
          <Layout>
          <div className={styles.container}>
            <Head>
              <title>Characters</title>
            </Head>
      
            <main className={styles.main}  id="page-top">
                         {/*///Team*/ } 
          <section className="bg-light page-section">            
          <div className="container">
            <div className="row">
              <div className="col-lg-12 text-center">
                <h2 className="section-heading text-uppercase">Our Amazing Team</h2>
                <h3 className="section-subheading text-muted">Check out our fantastic team.</h3>
              </div>
            </div>  
            <div className="row">          
            {characters.sort().map((character) => (
                <div className="col-sm-4">
                  <a href={`/Team/${character.Slug}`}>
                  <div className="team-member">        
                    <img className="mx-auto rounded-circle" src={character.Image.url} alt=""></img> 
                    <h4 className="text-muted">{character.PaineapleName}</h4>         
                </div>
                </a>  
              </div> 
            
              )) 
            }  
             </div>            
            
          </div>
          </section> 
                            {/*//friends*/} 
                           { <section className="bg-light page-section">            
          <div className="container">
            <div className="row">
              <div className="col-lg-12 text-center">
                <h2 className="section-heading text-uppercase">Our Amazing Friends</h2>
                <h3 className="section-subheading text-muted">Check out our fantastic team.</h3>
              </div>
            </div>  
            <div className="row">          
            {characters.filter(character => isFriend(character)).map((character) => (
                <div className="col-sm-4">
                  <a href={`/Team/${character.Slug}`}>
                  <div className="team-member">        
                    <img className="mx-auto rounded-circle" src={character.Image.url} alt=""></img> 
                    <h4 className="text-muted">{character.PaineapleName}</h4>         
                </div>
                </a>  
              </div> 
            
              )) 
            }
             </div>            
            
          </div>
          </section> }
          </main>
           
          </div>
          </Layout>
        )   
};

export default charactersItem;

The results did not meet my expectations and an error was encountered as shown in this image.

I attempted other solutions, but all of them led to duplication of information instead of filtering out who is considered a friend.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to utilize the Calendar component in the Material UI picker on its own, without requiring the Datepicker? If so, how can this be achieved?

I am currently working on designing a datepicker that allows users to select the day, month, and year from a list of values. However, I also want to incorporate calendar functionality so that users can choose the date by either selecting from the list or u ...

What could be causing the invalid_client error in response to this POST request I am making?

I am currently trying to establish a connection with an external API that has specific specifications: Host: name.of.host Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache Through the utilization of the request module from npm, I am ...

Error in Azure Cosmos DB: Unable to access property 'electionId' as it is undefined

I've encountered an issue while using Azure Cosmos DB with a mongodb backend. The error message I keep receiving is: Exception has occurred: Error TypeError: Cannot read property 'electionId' of undefined at ReplSetState.update (c:\dev ...

Issues with click events in the navigation menu

How can I make my menu close when clicking on other parts of my website, instead of opening? I know that I should use a click event for this, but when I implemented a click event, my menu encountered 2 unwanted problems: 1- Whenever I clicked on a menu i ...

Using jQuery to create clickable images by enclosing them in an `<a>` tag

How can I make each image with a specific class clickable? I would like jQuery to: Retrieve the src attribute of the image. Enclose the image within an a href tag that includes that src URL. .clickable { padding: 20px; border: 1px ...

Success message displayed for Ajax form submission, yet email delivery remains pending

In my PHP code for sending emails, I have a function called "Send to friend" that works perfectly with standard PHP post. This confirms that the sendtomail.php file is functioning correctly as well. /* AJAX Code for Send to Friend */ $(function() { $(&ap ...

Prevent a sliding panel from responding if there is no input text by incorporating jQuery

I have a straightforward example of user input and a button that reveals "Hello World" when clicked: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1 ...

Unable to close Bootstrap modal upon clicking "x" or "close" buttons

Hey everyone, I'm having a bit of trouble with my modal. It appears correctly when clicked to open, and the close buttons seem to detect that my mouse is hovering over them. However, when I click on the buttons, nothing happens and the modal remains o ...

The data type 'boolean' cannot be assigned to the type 'CaseReducer<ReportedCasesState, { payload: any; type: string; }>'

I recently developed a deletion reducer using reduxjs/toolkit: import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { AppThunk } from "../store"; import { ReportedCase, deleteReportCase } from "../../api/reportedCasesApi"; import history ...

Using the timer function to extract data within a specific time frame - a step-by-step guide

Is there anything else I need to consider when the temperature increases by 1 degree? My plan is to extract data from my machine for the last 30 seconds and then send it to my database. set interval(function x(){ If(current_temp != prev_temp){ if((c ...

Is it possible for three.js to integrate information from REST APIs?

Currently, I am in the process of learning three.js and have successfully created basic 3D models using hardcoded values. My goal now is to retrieve these values from a database that I have set up in MSSQL Server. These x, y, and z parameters are stored ...

JavaScript's native innerHTML function is unable to access the content generated by Vue

I have been struggling with extracting the content from a specific div element in my HTML code. <div id="output" ref="output_data"> <h1>{{ information }}</h1> </div> I attempted to retrieve the contents using ...

javascript/AngularJS - make elements gradually disappear

I need help implementing a fade effect for an icon in the middle of a picture that indicates scrollability to the user. Currently, when the user scrolls, I can hide the icon but would like to add a nice smooth fade-out effect. Here is the HTML code snippe ...

Restricting the number of times a user can click on

I am currently displaying a table with data obtained from a database query. The structure of the table is outlined below: <table id="dt-inventory-list" class="table table-responsive"> <thead> <tr> <th>Field ...

Discover identical JSON elements in 2 JSON arrays using JavaScript and add CSS styles to the corresponding items within a UL list

In order to manipulate JSON data using JavaScript, I am required to create an HTML UL list of tags based on a JSON array of Tag items. Furthermore, there is a second set of Tags in another JSON data-set that needs to be compared with the first Tag JSON da ...

Guide to setting up an OpenGL environment in a NodeJS native addon on MacOS

Continuation from the question mentioned. In my pursuit of developing a NodeJS native addon that utilizes OpenGL, I've encountered an issue. The problem arises when attempting to use OpenGL functions as CGLGetCurrentContext() consistently returns NU ...

Retrieve the URL of the image from an XML document

Figuring out how to extract the image URL from XML files in Android Studio can be challenging. After analyzing 30 RSS Feed XMLs, I discovered that 95% of them contain ".jpg" images with links starting with "http," not "www." Therefore, I am working on a co ...

send another response following the completion of the request.end()

I am facing challenges with writing the correct callback function. The situation involves a user making a request to "/city", which then triggers the server to make a request to a third-party service for data retrieval using http.request(). I successfully ...

Running JavaScript function from AJAX response containing both HTML and JavaScript code

For my first time using AJAX to prevent page refresh upon form submission, everything works flawlessly. The data is received in HTML form and placed into the designated div. However, I am encountering an issue with one of the JavaScript functions responsib ...

"Using a nested loop in Node.js to select count from Mysql and insert the

I am currently learning about nodejs and mysql. I have an array of objects that I receive from a post request and would like to insert it into a mysql database. If the data already exists, then I want to update the existing entry in the database. The issue ...