Using Use State and Use Effect for Dynamic checkboxes

Hello. I am working on a personal project using React.

I have three checkboxes that are supposed to filter the information in the table automatically when checked off (for example, if you check off "airline1", then only airline1 and its data will populate in the table). I would like some advice on how to do that using "Use State" and "Use Effect" because I believe using "Use States" and "Use Effect" would be the most efficient way to do this please. Here is the code that I have so far (see below):

import React, { useState } from "react";

import Table from "./components/Table/table";
import "./styles.css";

const list = [
  { id: "1", airline: "airline1", stops: 2, cost: 200 },
  { id: "2", airline: "airline2", stops: 2, cost: 100 },
  { id: "3", airline: "airline2", stops: 3, cost: 350 },
  { id: "4", airline: "airline3", stops: 1, cost: 90 },
  { id: "5", airline: "airline3", stops: 3, cost: 300 },
  { id: "6", airline: "airline1", stops: 1, cost: 100 }
];

const colNames = ["Id", "Airline", "Stops", "Cost"];

const App = (props) => {
  const [filteredList, setFilteredList] = useState(list);

  function filterData(list, filters) {
    return list.filter((item) => filters.includes(item.airline));
  }

  console.log(filterData(list, "airline2")); // test

  function changeSearch(e) {
    if (e.target.checked) {
      console.log("THIS IS TRUE");

      if (e.currentTarget.value === "airline1") {
        console.log("You have chosen airline1");
        console.log(filterData(list, "airline1"));
        //console.log(filterData(list, e.currentTarget.value));
        return <p>test</p>;
      } else if (e.currentTarget.value === "airline2") {
        console.log("You have chosen airline2");
        console.log(filterData(list, "airline2"));
      } else if (e.currentTarget.value === "airline3") {
        console.log("You have chosen airline3");
        console.log(filterData(list, "airline3"));
      }
    } else {
      console.log("THIS IS FALSE");
      console.log(filterData(list, ["airline1", "airline2", "airline3"]));
    }
  }
  return (
    <div className="grid-container">
      <div className="tableClass">
        <Table list={list} colNames={colNames} />
      </div>
      <div className="filterClass">
        <input
          type="checkbox"
          id="airline1"
          value="airline1"
          onChange={changeSearch}
        />{" "}
        airline1
        <br />
        <input
          type="checkbox"
          id="airline2"
          value="airline2"
          onChange={changeSearch}
        />{" "}
        airline2
        <br />
        <input
          type="checkbox"
          id="airline3"
          value="airline3"
          onChange={changeSearch}
        />{" "}
        airline3
        <br />
      </div>
    </div>
  );
};

export default App;

Running a .SWF file in 2022

Hi. When I was 17 years old, I played this game called White Enamel (its's more of a walkthrough then a game actually. See link: http://www.whiteenamel.com/). The website ran on Adobe Flash. So, since this technology has been discontinued, the website has gone into reconstruction. I know a new site is being developed for it so I can wait on the website to be done but, I tried reviving the game in spite of Adobe Flash not longer being supported.

I downloaded a .swf file that can play the White Enamel game from this website (see here: https://gamaverse.com/white-enamel-game/). Then, I ran it in Ruffle Emulator (see here: https://ruffle.rs/demo/). This allowed me to see the opening screen with the seven levels listed. However, once I selected a level, the screen goes blank thus not playing the full game.

Is this a problem with the .swf file? Can it be fixed? Any ideas are welcomed.

Compare a table definition to function

Hello. I am trying to check if a table definition (the default value on a constraint) is equal to UTC Time by using the following query:

IF NOT EXISTS((SELECT object_definition(default_object_id) AS definition
FROM sys.columns
WHERE name = 'ModifiedDate'
AND object_id = object_id('dbo.WorkflowAudit')) == GETUTCDATE())

However, you can not compare a function (GETUTCDATE()) to this Select Statement. I need to do it this way because I am building an update script and it can only update the table IF the table definition is NOT equal to UTC TIME Any ideas? Thank you

API not accepting input

Hello. I am making a database using SQLite. Then I need to make an API with functions that returns information about that database. Then I need to print out a report. However, when I try to return an answer to a query using inputs, nothing is returned. I either get an empty array or I get "<sqlite3.cursor object="" at="" 0x034d2d20="">". If I put default values in the query and not inputs, values are returned. Does anyone have any idea's on how I can fix this please (see below for more information)? Thank you in advance!

Here is the code that I have so far:

This is the code that creates the database....

import sqlite3

with sqlite3.connect('homework3.sq') as db:
    cursor = db.cursor()

cursor.execute(""" CREATE TABLE IF NOT EXISTS COURSES(
                    course_id       INTEGER              PRIMARY KEY,
                    department      varChar(100)         NOT NULL,
                    course_number   varChar(100)         NOT NULL,
                    course_name     varChar(100)         NOT NULL,
                    semester        varChar(100)         NOT NULL,
                    sem_year        varChar(20)          NOT NULL,
                    grade           varChar(1)           Not NULL)""")

cursor.execute("""CREATE TABLE IF NOT EXISTS PREREQUISITE(
                course_id       INTEGER              PRIMARY KEY,
                prereq1         Numeric(4)           NOT NULL,
                prereq2         Numeric(4)           NOT NULL,  
                ID REFERENCES COURSES("course_id")
                )""")

cursor.execute("""INSERT INTO COURSES (department, course_number, course_name, semester, sem_year, grade) VALUES 
                /*Sample Kpop Boy Bands- Present*/
                ('MATH', '1190', 'Calculus I', 'Summer', '2018', 'A'),
                ('CSE', '1322', 'Programming and Problem Solving', 'Fall', '2018', 'B'),
                ('CSE', '1322L', 'Programming and Problem Solving Lab', 'Fall', '2018', 'A'),
                ('CS', '3305', 'Data Structures', 'Spring', '2019', 'A'),
                ('CS', '3503', 'Computer Organization and Architecture', 'Spring', '2019', 'A'),  
                ('MATH','2202', 'Calculus II', 'Spring', '2019', 'B'),
                ('MATH', '2345', 'Discrete Mathematics', 'Fall', '2018', 'A'),
                ('CS', '3410', 'Introduction to Database Systems', 'Spring', '2020', 'A'),
                ('SWE', '3313', 'Introduction to Software Engineering', 'Spring', '2020', 'A'),
                ('CSE', '3801', 'Professional Practices and Ethics', 'Spring', '2020', 'A'),
                ('CS', '3502', 'Operating Systems', 'Fall', '2020', 'B'),
                ('CS', '4720', 'Internet Programming', 'Fall', '2020', 'A');""")

cursor.execute("""INSERT INTO PREREQUISITE(prereq1,prereq2) VALUES
                (0,0),
                (0,0),
                (0,0),
                (2,3),
                (2,3),
                (1,0),
                (0,0),
                (2,3),
                (2,3),
                (2,3),
                (4,5),
                (4,8)""")

db.commit()

This code is in the API file. This code works fine:

def infoA():
    return cursor.execute("SELECT * FROM COURSES WHERE sem_year = 2018 AND semester = 'Fall'")

But if I try to add parameters so that the function can accept inputs (as shown below), I don't get an answer:

def infoB(year, sem):
    return cursor.execute("SELECT * FROM COURSES WHERE sem_year = ? AND semester = ?", [year, sem])

Here is the report file also:

import API
# print line to dive results
print("=" * 111)

template = "|{:<5} | {:15} | {:15}| {:40} | {:10}|{:5}| {:>5}|"  # Writes the instructions on how to format column title
# writes the first column of the report by writing that column one is
row = template.format("ID", "Department", "Course Number", "Course Name", "Semester", "Year", "Grade")
print(row)

# print line to dive results
print("=" * 111)

# Gets function from API. When I run this function I get this: "[]"
info = API.infoB(2018, 'FALL') 

# If I run this, it will return information
# info = API.infoA()  

# If I run this using infoB, I get "<sqlite3.Cursor object at 0x034D2D20>"
# print(infoB.fetchall()) 

for data in info:
    id = data[0]
    depart = data[1]
    num = data[2]
    name = data[3]
    sem = data[4]
    class_year = data[5]
    class_grade = data[6]
    print(template.format(id, depart, num, name, sem, class_year, class_grade))

# print line to dive results
print("=" * 111)