@@ -132,7 +132,7 @@ const Preparation = () => {
)}
setConfirmOrder(null)}>
- {loading ? : 'Annuler'}
+ {loading ? : "Annuler"}
{
await editOrder(confirmOrder, true);
setConfirmOrder(null);
}}>
- {loading ? : 'Confirmer'}
+ {loading ? : "Confirmer"}
@@ -148,4 +148,4 @@ const Preparation = () => {
);
};
-export default Preparation;
+export default Page;
diff --git a/src/routes/sell.scss b/src/app/sell/page.scss
similarity index 100%
rename from src/routes/sell.scss
rename to src/app/sell/page.scss
diff --git a/src/app/sell/page.tsx b/src/app/sell/page.tsx
new file mode 100644
index 0000000..da0c90d
--- /dev/null
+++ b/src/app/sell/page.tsx
@@ -0,0 +1,57 @@
+"use client";
+import "../page.scss";
+import "./page.scss";
+import React from "react";
+//import queryString from "query-string";
+import ItemsGrid from "../../components/itemsGrid";
+import Navbar from "../../components/navbar";
+import PriceToogler from "../../components/priceToogler";
+import Basket from "../../components/basket";
+import { useDispatch, useSelector } from "react-redux";
+import { clearBasket } from "@/reducers/basket";
+import { State } from "@/types";
+import { setNormalPrice } from "@/reducers/orgaPrice";
+import { useSearchParams } from "next/navigation";
+//import Categories from "@/reducers/categories";
+
+/**
+ * /sell
+ *
+ * Query params: ?only=(food|goodies)
+ */
+
+const Page = () => {
+ const searchParams = useSearchParams();
+ const dispatch = useDispatch();
+ let categories = useSelector((state: State) => state.categories);
+
+ if (searchParams.has("only")) { //TODO check change
+ categories = categories.filter((category) => category.key == searchParams.get("only"));
+ } else if (searchParams.has("except")) {
+ categories = categories.filter((category) => category.key !== searchParams.get("except"));
+ }
+
+ categories = categories.map((category) => ({
+ ...category,
+ items: category.items.filter((item) => item.available)
+ }));
+
+ const onBack = () => {
+ dispatch(clearBasket());
+ dispatch(setNormalPrice());
+ };
+
+ return (
+ <>
+
onBack()}>
+
+
+
+
+
+
+ >
+ );
+};
+
+export default Page;
diff --git a/src/routes/tv.scss b/src/app/tv/page.scss
similarity index 100%
rename from src/routes/tv.scss
rename to src/app/tv/page.scss
diff --git a/src/routes/tv.tsx b/src/app/tv/page.tsx
similarity index 86%
rename from src/routes/tv.tsx
rename to src/app/tv/page.tsx
index 6b45825..fbe03d7 100644
--- a/src/routes/tv.tsx
+++ b/src/app/tv/page.tsx
@@ -1,11 +1,12 @@
-import React, { LegacyRef, useEffect, useRef, useState } from 'react';
+"use client";
+import React, { LegacyRef, useEffect, useRef, useState } from "react";
+import "../page.scss";
+import "./page.scss";
+import { useSelector } from "react-redux";
-import './tv.scss';
-import { useSelector } from 'react-redux';
-
-import { Order as OrderType, OrderItem, State, Status } from '../types';
-import Separator from '../components/UI/separator';
-import { useRouter } from 'next/navigation';
+import { Order as OrderType, OrderItem, State, Status } from "../../types";
+import Separator from "../../components/UI/separator";
+import { useRouter } from "next/navigation";
interface GroupedCategory {
name: string;
@@ -21,7 +22,7 @@ const groupOrderItems = (items: Array
) => {
} else {
acc.push({
name: curr.item.category.name,
- count: 1,
+ count: 1
});
}
@@ -31,7 +32,7 @@ const groupOrderItems = (items: Array) => {
// Takes plural in account
const formatName = (name: string, count: number) => {
- if (name.endsWith('s') && count === 1) return name.slice(0, -1);
+ if (name.endsWith("s") && count === 1) return name.slice(0, -1);
return name;
};
@@ -66,7 +67,7 @@ const OrderGrid = ({ orders, passingRef }: { orders: Array; passingRe
);
};
-const Tv = () => {
+const Page = () => {
const orders = useSelector((state: State) => state.orders);
const pendingOrders = orders.filter((order) => order.status === Status.PENDING);
@@ -110,7 +111,7 @@ const Tv = () => {
});
return (
- router.push('/')}>
+
router.push("/")}>
En attente
(refs.current[0] = el)} />
@@ -129,4 +130,4 @@ const Tv = () => {
);
};
-export default Tv;
+export default Page;
diff --git a/src/components/loginRouter.tsx b/src/components/loginRouter.tsx
index 3be60e2..2cd306c 100644
--- a/src/components/loginRouter.tsx
+++ b/src/components/loginRouter.tsx
@@ -1,6 +1,6 @@
import React, { ReactNode, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
-import Login from '../routes/login';
+import Page from '../app/login/page';
import { autoLogin } from '@/reducers/login';
import { State } from '@/types';
import Loader from './pageLoader';
@@ -28,7 +28,7 @@ const LoginRouter = ({ children }: { children: ReactNode }) => {
if (state.login.loading) return ;
- if (!state.login.token) return ;
+ if (!state.login.token) return ;
return { children };
};
diff --git a/src/routes/index.scss b/src/routes/index.scss
deleted file mode 100644
index 5bd05f2..0000000
--- a/src/routes/index.scss
+++ /dev/null
@@ -1,31 +0,0 @@
-.logout {
- padding-right: 14px;
-}
-
-#index {
- display: flex;
- flex-direction: row;
- justify-content: center;
- flex-wrap: wrap;
- align-items: stretch;
- height: calc(100% - 50px);
- font-size: 3em;
-
- div {
- height: calc(33% - 20px - 4px);
- width: calc(50% - 20px - 4px - 20px);
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: var(--primary);
- margin: 10px;
-
- .fa {
- margin-right: 15px;
- }
-
- &:hover {
- filter: brightness(0.9);
- }
- }
-}
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
deleted file mode 100644
index e69de29..0000000
diff --git a/src/routes/sell.tsx b/src/routes/sell.tsx
deleted file mode 100644
index b8e4073..0000000
--- a/src/routes/sell.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import './sell.scss';
-import React from 'react';
-import { useLocation } from 'react-router';
-import queryString from 'query-string';
-import ItemsGrid from '../components/itemsGrid';
-import Navbar from '../components/navbar';
-import PriceToogler from '../components/priceToogler';
-import Basket from '../components/basket';
-import { useDispatch, useSelector } from 'react-redux';
-import { clearBasket } from '@/reducers/basket';
-import { State } from '@/types';
-import { setNormalPrice } from '@/reducers/orgaPrice';
-
-/**
- * /sell
- *
- * Query params: ?only=(food|goodies)
- */
-
-const Sell = () => {
- const dispatch = useDispatch();
- const location = useLocation();
- let categories = useSelector((state: State) => state.categories);
- const queryParams = queryString.parse(location.search);
-
- if (queryParams.only) {
- categories = categories.filter((category) => category.key === queryParams.only);
- } else if (queryParams.except) {
- categories = categories.filter((category) => category.key !== queryParams.except);
- }
-
- categories = categories.map((category) => ({
- ...category,
- items: category.items.filter((item) => item.available),
- }));
-
- const onBack = () => {
- dispatch(clearBasket());
- dispatch(setNormalPrice());
- };
-
- return (
- <>
- onBack()}>
-
-
-
-
-
-
- >
- );
-};
-
-export default Sell;