Skip to content

Commit

Permalink
fix: eslint unused vars
Browse files Browse the repository at this point in the history
  • Loading branch information
caushcani committed Dec 4, 2024
1 parent e5ab47f commit 1063a80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
13 changes: 7 additions & 6 deletions apps/frontend/src/components/media/media.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FC, useCallback, useEffect, useState } from 'react';
import { Button } from '@gitroom/react/form/button';
import { useMediaDirectory } from '@gitroom/react/helpers/use.media.directory';
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
import EventEmitter from 'events';
import dynamic from 'next/dynamic';
import { useUser } from '@gitroom/frontend/components/layout/user.context';
import { MediaBox } from './mediabox.component';
Expand All @@ -28,17 +27,19 @@ export const MediaComponent: FC<{
const { name, type, label, description, onChange, value, width, height } = props;
const { getValues } = useSettings();
const user = useUser();

const [modal, setShowModal] = useState(false);
const [mediaModal, setMediaModal] = useState(false);
const [currentMedia, setCurrentMedia] = useState(value);
const mediaDirectory = useMediaDirectory();

useEffect(() => {
const settings = getValues()[props.name];
if (settings) {
setCurrentMedia(settings);
}
}, []);
const [modal, setShowModal] = useState(false);
const [mediaModal, setMediaModal] = useState(false);
const [currentMedia, setCurrentMedia] = useState(value);
const mediaDirectory = useMediaDirectory();


const closeDesignModal = useCallback(() => {
setMediaModal(false);
}, [modal]);
Expand Down
24 changes: 8 additions & 16 deletions apps/frontend/src/components/media/multimedia.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,20 @@ export const MultiMediaComponent: FC<{
target: { name: string; value?: Array<{ id: string; path: string }> };
}) => void;
}> = (props) => {
const { name, label, error, description, onChange, value } = props;
const { name, error, onChange, value } = props;
const user = useUser();
useEffect(() => {
if (value) {
setCurrentMedia(value);
}
}, []);

const [modal, setShowModal] = useState(false);
const [mediaModal, setMediaModal] = useState(false);

const [currentMedia, setCurrentMedia] = useState(value);

const mediaDirectory = useMediaDirectory();

const changeMedia = useCallback(
(m: { path: string; id: string }) => {
const newMedia = [...(currentMedia || []), m];
setCurrentMedia(newMedia);
const newMedia = [...(value || []), m];
onChange({ target: { name, value: newMedia } });
},
[currentMedia, name]
[value, name]
);

const showModal = useCallback(() => {
Expand All @@ -50,11 +43,10 @@ export const MultiMediaComponent: FC<{

const clearMedia = useCallback(
(topIndex: number) => () => {
const newMedia = currentMedia?.filter((f: any, index: number) => index !== topIndex);
setCurrentMedia(newMedia);
const newMedia = value?.filter((f: any, index: number) => index !== topIndex);
onChange({ target: { name, value: newMedia } });
},
[currentMedia]
[value]
);

const designMedia = useCallback(() => {
Expand Down Expand Up @@ -114,8 +106,8 @@ export const MultiMediaComponent: FC<{
</Button>
</div>

{!!currentMedia &&
currentMedia.map((media: { path: string ; }, index: number) => (
{!!value &&
value.map((media: { path: string ; }, index: number) => (
<>
<div className="cursor-pointer w-[40px] h-[40px] border-2 border-tableBorder relative flex">
<div
Expand Down

0 comments on commit 1063a80

Please sign in to comment.