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

Learn how to update a fixed value by adding the content entered into the Input textfield using Material-UI

I made a field using the Input component from material-ui: <Input placeholder="0.00" value={rate} onChange={event => { this.setState({ `obj.rate`, event.target.value }); }} /> Whenever I input a rate into this field, ...

Solving the challenge of handling multiple text inputs in Laravel Blade using Vue.js v-model within a @

Hello, I am encountering an issue with my Laravel application that displays posts and comments. The problem lies with the Vue v-model in the input text when using the @foreach directive in Blade. Each post is showing the comments input box, but when I ente ...

"Step-by-step guide on creating a popup window for editing a row using ng-grid and AngularJS

I recently started diving into angular-js and I'm really impressed with how cool it is. In my search, I came across http://angular-ui.github.io/ng-grid/, which seems to be a user-friendly tool. However, I'm grappling with figuring out how to disp ...

Steps to retrieve the value of a particular row in a table using vuejs

Can you help me retrieve the value of a specific row in a table using VueJS 2? Here is an image of my current table: I need assistance with obtaining and displaying the last value from a loop in the "SHOW QR Button" within my code snippet. The button shou ...

Tips for activating a click event on a changing element within a Vue.js application

I am working on creating dynamically generated tabs with a specific range of time (from 8am to 9am). My goal is to automatically trigger a click event when the current time falls within this range. However, I am facing an issue where the ref is being ident ...

Tips for resolving the NextJS port already in use issue

My ReactApp is up and running smoothly on port 3000. However, when I decided to launch a new NextJS App for testing purposes, an error popped up: Error: listen EADDRINUSE: address already in use 0.0.0.0:3000 This situation doesn't add up. In a nor ...

Tips for manipulating observableArray information retrieved through the $.getJSON method

Recently, I've started using knockout.js and I'm really enjoying it so far! While working in MVC4, I encountered a small issue. I had successfully implemented kojs with static data, but now I need to work with data passed from a controller via JS ...

Tips for efficiently finding and comparing text within the results generated by a for loop in Angular/Javascript

In my XML data, I have extracted all the tag names using a for loop and some other logic. Now, I am looking to find the word 'author' from the output values that are displayed in the console during the loop. If any of the output values match &apo ...

What prevents variables defined in outer blocks from being accessed by nested describe() blocks?

In my real code, I encountered a problem that I wanted to demonstrate with a simple example. The code below functions properly. I defined a variable in the root describe() block that can be accessed in the it() blocks of nested describe()s. describe(&apo ...

The object function router(req, res, next) is encountering an error as it does not contain the required method for handling the request

I am trying to add a new row to my MySQL database, but I encountered an error message. Here is the scenario: I have set up Passport and hjs in my project. I am passing form data from app.js to a JavaScript file where I aim to insert the data. Object funct ...

In React Native, what is the method for utilizing index.js rather than separate index.ios.js and index.android.js files to create a cross-platform app?

Thank you for the help so far, I am new to React Native, and I'm trying to develop a cross-platform app. Here is my index.js file: import React from 'react'; { Component, View, Text, } from 'react-nativ ...

Implementing a design aesthetic to installed React components

After downloading a react multiselect component created by an individual, I installed it using npm install .... and incorporated the component in my react code with <MultiSelect .../>. The dropdown checkbox 'menu' is designed to allow users ...

Encountering issues with managing CometD channels within Angular 2

After dabbling in Angular2 and Typescript, I decided to challenge myself by creating an application using plain javascript with the CometD library. The goal of this app was to retrieve data from a CometD channel and present it to the user in some way. So, ...

Having trouble extracting data from a particular cell within an HTML table using jQuery

I am struggling to extract row data from a table for utilization in a modal. Provided below is my code for Views. <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"> <link href="@Url.Content(" ...

Handling a JSON array error when working with a JSON string field

Attempting to create a JSONArray object with nested arrays and json strings, specifically looking at the "res" field. [{ "time": 123813213, "value": [{ "name": "task", "res": "{\"taskName\" : \"NAME\", \"ta ...

Images on web pages are automatically resized to fit into a smaller preview window

Currently, I am facing an issue with the display of images in my grid windows on my website . The images are appearing as partial representations instead of rescaled versions where the whole picture is resized to fit the grid window. I have attempted mod ...

Tips for generating AJAX requests directly from HTML documents

Hey there! I'm fairly new to JavaScript and have a question that might seem silly to some. How exactly can I invoke a function from a Coffeescript file within my HTML code? I'd like to give users the option to choose the language in which they v ...

Removing the Tooltip for Sorting in React-Table: Here's How to Remove the 'Toggle sortBy' Tooltip from Column Headers

Is there a way to remove the 'Toggle sortBy' tooltip from the column header when using the Material-UI Table components in the most recent version (7.5.x) of React-Table? Two tooltips Upon hover, I have a tooltip displaying the column header na ...

How can the table column drag and drop feature be activated in material-ui?

After consulting the official documentation, I attempted to use DataGridPro in order to create a table. However, I encountered difficulty triggering a response after dragging the table. Despite trying various methods outlined in the documentation, none o ...

What is the best way to use JavaScript to emphasize a substring that includes a wild card character surrounded by two specific characters

In the dataframe below, I have multiple strings stored: v1 v2 ARSTNFGATTATNMGATGHTGNKGTEEFR SEQUENCE1 BRCTNIGATGATNLGATGHTGNQGTEEFR SEQUENCE2 ARSTNFGATTATNMGATGHTGNKGTEEFR SEQUENCE3 I am interested in searching for a ...