Commit 3b3a9e9b authored by Jan Minář's avatar Jan Minář
Browse files

fix(frontend): filter show none integratedGraphics

parent af094bf9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ export function AddProcessor() {
  const [manufacturer, setManufacturer] = useState<Manufacturer>();
  const [socket, setSocket] = useState<Socket>();
  const [integratedGraphics, setIntegratedGraphics] =
    useState<IntegratedGraphics>();
    useState<IntegratedGraphics | null>();

  const { register, handleSubmit, getValues } = useForm<Processor>();
  const {
@@ -50,7 +50,7 @@ export function AddProcessor() {
      price: getValues('price'),
      manufacturerId: manufacturer.id,
      socketId: socket.id,
      integratedGraphicsId: integratedGraphics.id,
      integratedGraphicsId: integratedGraphics?.id ?? null,
      image: stored[0].filename,
    };
    mutate(processor);
+9 −4
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@ import { useQuery } from 'react-query';
import { readManyIntegratedGraphics } from '../../../services/integratedGraphicsApi';

interface IntegratedGraphicsProps {
  integratedGraphic: IntegratedGraphics;
  setIntegratedGraphic: (data: IntegratedGraphics) => void;
  integratedGraphic: IntegratedGraphics | null;
  setIntegratedGraphic: (data: IntegratedGraphics | null) => void;
}

export function IntegratedGraphicsAttr({
@@ -22,9 +22,13 @@ export function IntegratedGraphicsAttr({
    queryFn: async () => readManyIntegratedGraphics(),
  });
  const handleIntegratedGraphicsChange = (
    event: SelectChangeEvent<IntegratedGraphics>
    event: SelectChangeEvent<IntegratedGraphics | string>
  ) => {
    if (event.target.value === 'None') {
      setIntegratedGraphic(null);
    } else {
      setIntegratedGraphic(event.target.value as IntegratedGraphics);
    }
  };
  return (
    <div className="formAdd__item">
@@ -35,6 +39,7 @@ export function IntegratedGraphicsAttr({
          autoWidth
          onChange={handleIntegratedGraphicsChange}
        >
          <MenuItem value={'None'}>None</MenuItem>
          {integratedGraphics?.map((i) => (
            <MenuItem key={i.id} value={i}>
              {i.name}
+2 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import {
} from './atoms';

const isEmptyOrHas = <T extends { id: string }>(set: T[], value: T) =>
  set.length === 0 || set.find((x) => x?.id === value?.id);
  set.length === 0 || set.findIndex((x) => x?.id === value?.id) !== -1;

export const filteredProcessorsSelector = selector({
  key: 'filteredProcessorsSelector',
@@ -31,6 +31,7 @@ export const filteredProcessorsSelector = selector({
    const sortName = get(sortNameAtom);
    const sortPrice = get(sortPriceAtom);

    console.log(processorFilters);
    return processors
      .filter((processor) => {
        if (