Skip to content

Commit

Permalink
Big project update
Browse files Browse the repository at this point in the history
Fix front app (config, lint)
  • Loading branch information
MathieuAndrade committed Mar 24, 2024
1 parent 9d22949 commit 527e048
Show file tree
Hide file tree
Showing 60 changed files with 100 additions and 138 deletions.
2 changes: 0 additions & 2 deletions apps/front/.env.development

This file was deleted.

2 changes: 0 additions & 2 deletions apps/front/.env.staging

This file was deleted.

11 changes: 11 additions & 0 deletions apps/front/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = require("@friday-ai/tools/eslint/react-internal");

/** @type {import("eslint").Linter.Config} */
module.exports = {
...config,
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
};
3 changes: 0 additions & 3 deletions apps/front/.eslintrc.js

This file was deleted.

6 changes: 0 additions & 6 deletions apps/front/.gitignore

This file was deleted.

15 changes: 7 additions & 8 deletions apps/front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@
"type": "module",
"scripts": {
"start": "per-env",
"start:prod": "cross-env NODE_ENV=production http-server dist -p 1444 -g",
"start:dev": "cross-env CHOKIDAR_USEPOLLING=true NODE_ENV=development vite --host --force",
"start:demo": "cross-env NODE_ENV=production tsc && vite build --mode staging && http-server dist",
"start:prod": "http-server dist -p 1444 -g",
"start:dev": "cross-env CHOKIDAR_USEPOLLING=true NODE_ENV=development VITE_SERVER_PORT=3000 vite --host --force",
"build": "cross-env NODE_ENV=production tsc && vite build --mode production",
"preview": "pnpm build && vite preview --host",
"preview:https": "cross-env HTTPS=true pnpm run preview",
"build:front": "cross-env NODE_ENV=production tsc && vite build --mode production",
"format": "prettier --write src/**/*.{js,jsx,ts,tsx}",
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src",
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx --fix ./src"
},
"prettier": "../../packages/tools/prettier.config.js",
"prettier": "@friday-ai/tools/configs/prettier.config.js",
"dependencies": {
"@ebay/nice-modal-react": "^1.2.13",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@friday-ai/shared": "workspace:*",
"@mui/icons-material": "^5.15.3",
"@mui/material": "^5.15.3",
"@friday-ai/shared": "workspace:*",
"@tanstack/react-query": "^5.17.8",
"@visx/event": "^3.3.0",
"@visx/group": "^3.3.0",
Expand Down Expand Up @@ -64,7 +62,8 @@
"prettier": "^3.1.1",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^5.3.3",
"vite": "^5.0.11",
"vite": "^5.0.12",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-pwa": "^0.17.4",
"vite-plugin-svgr": "^4.2.0",
"workbox-window": "^7.0.0"
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/App/AnimationContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AnimatePresence, m, MotionStyle } from 'framer-motion';
import React from 'react';

interface AnimationContainerProps {
children: React.ReactNode;
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/App/AnimationLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { m } from 'framer-motion';
import React from 'react';
import { useLocation } from 'react-router-dom';

const pageVariants = {
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/App/DashboardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Container from '@mui/material/Container';
import Paper from '@mui/material/Paper';
import React from 'react';
import { Outlet } from 'react-router-dom';

import AppBar from '../AppBar/AppBar';
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/AppBar/AccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Divider from '@mui/material/Divider';
import ListItemIcon from '@mui/material/ListItemIcon';
import MenuItem from '@mui/material/MenuItem';

import React from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';

Expand Down
2 changes: 0 additions & 2 deletions apps/front/src/components/AppBar/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import Typography from '@mui/material/Typography';

import { useTheme } from '@mui/material/styles';

import React from 'react';

import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';

Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/Charts/Pie.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';

import { localPoint } from '@visx/event';
import { Group } from '@visx/group';
Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/Countdown/Countdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import { useEffect } from 'react';

interface CountdownProps {
start: boolean;
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useTheme } from '@mui/material/styles';
import { m, Transition } from 'framer-motion';
import React from 'react';

const transition: Transition = {
duration: 4,
Expand Down
1 change: 0 additions & 1 deletion apps/front/src/components/Loader/LoaderLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Box from '@mui/material/Box';
import React from 'react';

import FaviconLoader from './Loader';

Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/Loader/LoaderSuspense.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';

import AnimationLayout from '../App/AnimationLayout';
import LoaderLayout from './LoaderLayout';
Expand Down
5 changes: 3 additions & 2 deletions apps/front/src/components/Map/LocationMarker.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import { Marker, Popup, useMap } from 'react-leaflet';

import { LocationEvent } from 'leaflet';
import { DEFAULT_COORDS } from '../../utils/constants';

export default function LocationMarker() {
const [position, setPosition] = useState<[number, number]>(DEFAULT_COORDS);
const map = useMap();

useEffect(() => {
map.locate().on('locationfound', (e) => {
map.locate().on('locationfound', (e: LocationEvent) => {
setPosition([e.latlng.lat, e.latlng.lng]);
map.flyTo(e.latlng, map.getZoom());
});
Expand Down
5 changes: 2 additions & 3 deletions apps/front/src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { MapContainer, Marker as MapMarker, Popup, TileLayer } from 'react-leaflet';

import 'leaflet/dist/leaflet.css';
Expand All @@ -16,7 +15,7 @@ interface MapProps {
onNewMarker: (latitude: number, longitude: number) => void;
}

export default function Map({ markers, onNewMarker }: MapProps) {
export default function CustomMap({ markers, onNewMarker }: MapProps) {
const theme = useTheme();

return (
Expand All @@ -39,6 +38,6 @@ export default function Map({ markers, onNewMarker }: MapProps) {
);
}

Map.defaultProps = {
CustomMap.defaultProps = {
markers: [],
};
3 changes: 2 additions & 1 deletion apps/front/src/components/Map/MapEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMapEvents } from 'react-leaflet';

import { LeafletMouseEvent } from 'leaflet';
import { round } from '../../utils/number';

interface MapEventsProps {
Expand All @@ -8,7 +9,7 @@ interface MapEventsProps {

export default function MapEvents({ onClick }: MapEventsProps) {
useMapEvents({
click: (e) => {
click: (e: LeafletMouseEvent) => {
onClick(round(e.latlng.lat, 5), round(e.latlng.lng, 5));
},
});
Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MuiMenu from '@mui/material/Menu';
import { SxProps, Theme } from '@mui/material/styles';
import Tooltip from '@mui/material/Tooltip';

import React, { useState } from 'react';
import { useState } from 'react';

interface MenuProps {
id: string;
Expand Down
2 changes: 0 additions & 2 deletions apps/front/src/components/Modal/Confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
Expand Down
18 changes: 6 additions & 12 deletions apps/front/src/components/Snackbar/Snackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React from 'react';

import Alert from '@mui/material/Alert';
import Snackbar from '@mui/material/Snackbar';

import { CustomContentProps, SnackbarContent } from 'notistack';
import { forwardRef } from 'react';

const defaultSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const defaultSnackbar = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const { id, message } = props;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<SnackbarContent ref={ref}>
<Snackbar open key={id} message={message} />
</SnackbarContent>
);
});

const successSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const successSnackbar = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const { id, message } = props;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<SnackbarContent ref={ref}>
<Snackbar open key={id}>
<Alert severity="success" variant="filled" sx={{ minWidth: 288 }}>
Expand All @@ -29,10 +26,9 @@ const successSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((pr
);
});

const errorSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const errorSnackbar = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const { id, message } = props;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<SnackbarContent ref={ref}>
<Snackbar open key={id}>
<Alert severity="error" variant="filled" sx={{ minWidth: 288 }}>
Expand All @@ -43,10 +39,9 @@ const errorSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((prop
);
});

const warningSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const warningSnackbar = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const { id, message } = props;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<SnackbarContent ref={ref}>
<Snackbar open key={id}>
<Alert severity="warning" variant="filled" sx={{ minWidth: 288 }}>
Expand All @@ -57,10 +52,9 @@ const warningSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((pr
);
});

const infoSnackbar = React.forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const infoSnackbar = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
const { id, message } = props;
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<SnackbarContent ref={ref}>
<Snackbar open key={id}>
<Alert severity="info" variant="filled" sx={{ minWidth: 288 }}>
Expand Down
6 changes: 3 additions & 3 deletions apps/front/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { LazyMotion, domAnimation } from 'framer-motion';
import React from 'react';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { RouterProvider } from 'react-router-dom';
import { registerSW } from 'virtual:pwa-register';
Expand All @@ -29,7 +29,7 @@ if (rootContainer !== null) {
const root = createRoot(rootContainer);

root.render(
<React.StrictMode>
<StrictMode>
<LazyMotion features={domAnimation}>
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
Expand All @@ -40,7 +40,7 @@ if (rootContainer !== null) {
</ThemeProvider>
</QueryClientProvider>
</LazyMotion>
</React.StrictMode>
</StrictMode>,
);

registerSW();
Expand Down
2 changes: 0 additions & 2 deletions apps/front/src/routes/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import DashboardLayout from '../../components/App/DashboardLayout';

export default function Dashboard() {
Expand Down
2 changes: 0 additions & 2 deletions apps/front/src/routes/Dashboard/Devices.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

export default function Devices() {
return <div>Devices</div>;
}
2 changes: 1 addition & 1 deletion apps/front/src/routes/Dashboard/Satellites/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';

import FilterListOutlinedIcon from '@mui/icons-material/FilterListOutlined';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';

import ArrowBackIosNewOutlinedIcon from '@mui/icons-material/ArrowBackIosNewOutlined';
Expand Down Expand Up @@ -56,7 +56,7 @@ export default function Install() {
return { id: varId, key, value };
}
return variable;
})
}),
);
};

Expand Down Expand Up @@ -86,7 +86,7 @@ export default function Install() {
})
.catch((_err) => setRepoExisting(2));
}, 500),
[]
[],
);

const getIcon = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import { useCallback } from 'react';

import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
import MoreVertOutlinedIcon from '@mui/icons-material/MoreVertOutlined';
Expand Down Expand Up @@ -46,7 +46,7 @@ export default function PluginList({ plugins, onRemovePlugin }: { plugins: Plugi
NiceModal.show(ConfirmDialog, {
title: t('dashboard.satellites.areYouSure'),
content: `${t('dashboard.satellites.deletePluginMessage')} <b>${name}</b>.`,
onClose: async (confirm) => {
onClose: async (confirm: boolean) => {
if (confirm) {
uninstallPlugin
.mutateAsync(id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';

import AddCircleOutlineOutlinedIcon from '@mui/icons-material/AddCircleOutlineOutlined';
Expand Down
6 changes: 2 additions & 4 deletions apps/front/src/routes/Dashboard/Satellites/Satellites.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { Navigate, useLocation } from 'react-router-dom';

import LoaderSuspense from '../../../components/Loader/LoaderSuspense';
Expand All @@ -10,14 +8,14 @@ export default function Satellites() {
const location = useLocation();
const { isLoading, isSuccess, data } = useGetSatellites();

if (!isSuccess) {
if (!isSuccess || data === undefined || data[0] === undefined) {
return null;
}

return (
<LoaderSuspense isFetching={isLoading}>
<>
<Navigate to={`${data[0].id}`} state={{ from: location }} />{' '}
<Navigate to={`${data[0].id}`} state={{ from: location }} />
</>
</LoaderSuspense>
);
Expand Down
2 changes: 0 additions & 2 deletions apps/front/src/routes/Dashboard/Satellites/States.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import Chip from '@mui/material/Chip';

import { AvailableState } from '@friday-ai/shared';
Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/routes/Dashboard/Settings/House/House.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';

import AddCircleOutlineOutlinedIcon from '@mui/icons-material/AddCircleOutlineOutlined';
import { Divider, IconButton, Stack, Tooltip, Typography } from '@mui/material';
Expand Down
Loading

0 comments on commit 527e048

Please sign in to comment.