refactor code

This commit is contained in:
Abhinav 2022-08-17 13:58:22 +05:30
parent 6b353c6d7c
commit ee686d430b
4 changed files with 11 additions and 16 deletions

View file

@ -1,5 +1,4 @@
import { MappingList } from './mappingList'; import { MappingList } from './mappingList';
import { NoMappingsContent } from './noMappingsContent';
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { Button, Dialog, DialogContent, Stack } from '@mui/material'; import { Button, Dialog, DialogContent, Stack } from '@mui/material';
import watchFolderService from 'services/watchFolder/watchFolderService'; import watchFolderService from 'services/watchFolder/watchFolderService';
@ -98,17 +97,10 @@ export default function WatchFolder({ open, onClose }: Iprops) {
</DialogTitleWithCloseButton> </DialogTitleWithCloseButton>
<DialogContent sx={{ flex: 1 }}> <DialogContent sx={{ flex: 1 }}>
<Stack spacing={1} p={1.5} height={'100%'}> <Stack spacing={1} p={1.5} height={'100%'}>
{mappings.length === 0 ? (
<NoMappingsContent />
) : (
<MappingList <MappingList
mappings={mappings} mappings={mappings}
handleRemoveWatchMapping={ handleRemoveWatchMapping={handleRemoveWatchMapping}
handleRemoveWatchMapping
}
/> />
)}
<Button <Button
fullWidth fullWidth
color="accent" color="accent"

View file

@ -1,14 +1,17 @@
import React from 'react'; import React from 'react';
import { WatchMapping } from 'types/watchFolder'; import { WatchMapping } from 'types/watchFolder';
import { MappingEntry } from './mappingEntry'; import { MappingEntry } from '../mappingEntry';
import { MappingsContainer } from './styledComponents'; import { NoMappingsContent } from './noMappingsContent/noMappingsContent';
import { MappingsContainer } from '../styledComponents';
interface Iprops { interface Iprops {
mappings: WatchMapping[]; mappings: WatchMapping[];
handleRemoveWatchMapping: (value: WatchMapping) => void; handleRemoveWatchMapping: (value: WatchMapping) => void;
} }
export function MappingList({ mappings, handleRemoveWatchMapping }: Iprops) { export function MappingList({ mappings, handleRemoveWatchMapping }: Iprops) {
return ( return mappings.length === 0 ? (
<NoMappingsContent />
) : (
<MappingsContainer> <MappingsContainer>
{mappings.map((mapping) => { {mappings.map((mapping) => {
return ( return (

View file

@ -3,7 +3,7 @@ import { FlexWrapper } from 'components/Container';
import React from 'react'; import React from 'react';
import constants from 'utils/strings/constants'; import constants from 'utils/strings/constants';
import { CheckmarkIcon } from './checkmarkIcon'; import { CheckmarkIcon } from './checkmarkIcon';
import { NoMappingsContainer } from './styledComponents'; import { NoMappingsContainer } from '../../styledComponents';
export function NoMappingsContent() { export function NoMappingsContent() {
return ( return (
<NoMappingsContainer> <NoMappingsContainer>