This commit is contained in:
2026-06-12 21:50:03 +03:00
parent a0481f74b2
commit a48b417257
6 changed files with 49 additions and 54 deletions
+8 -3
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"log" "log"
"net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/joho/godotenv" "github.com/joho/godotenv"
@@ -37,14 +38,14 @@ func main() {
{ {
api.POST("/login", handlers.Login) api.POST("/login", handlers.Login)
protected := api.Group("/") protected := api.Group("/")
api.GET("/items/:id", handlers.GetItem)
api.GET("/items/", handlers.GetAllItems)
api.GET("/getCategories", handlers.GetCategories)
protected.Use(middleware.AuthRequired()) protected.Use(middleware.AuthRequired())
{ {
protected.GET("/items/:id", handlers.GetItem)
protected.GET("/items/", handlers.GetAllItems)
protected.DELETE("/items/:id", handlers.DeleteItem) protected.DELETE("/items/:id", handlers.DeleteItem)
protected.PATCH("/items/:id", handlers.UpdateItem) protected.PATCH("/items/:id", handlers.UpdateItem)
protected.POST("/items", handlers.AddItem) protected.POST("/items", handlers.AddItem)
protected.GET("/getCategories", handlers.GetCategories)
} }
admin := protected.Group("/") admin := protected.Group("/")
@@ -54,5 +55,9 @@ func main() {
} }
} }
r.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{"status": 404, "message": "API not found"})
})
r.Run(":8081") r.Run(":8081")
} }
+7 -32
View File
@@ -4,6 +4,7 @@ import AddItem from "./pages/AddItem";
import AuthForm from "./components/AuthForm"; import AuthForm from "./components/AuthForm";
import About from "./pages/About"; import About from "./pages/About";
import Shop from "./pages/Shop"; import Shop from "./pages/Shop";
import NotFoundPage from "./pages/NotFoundPage";
const PrivateRoute = ({ children }) => { const PrivateRoute = ({ children }) => {
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
@@ -19,38 +20,12 @@ export default function App() {
<BrowserRouter> <BrowserRouter>
<Routes> <Routes>
<Route path="/login" element={<AuthForm />} /> <Route path="/login" element={<AuthForm />} />
<Route <Route path="/" element={<Main />} />
path="/" <Route path="/add_item" element={<AddItem />} />
element={ <Route path="/about" element={<About />} />
<PrivateRoute> <Route path="/shop" element={<Shop />} />
<Main />
</PrivateRoute> <Route path="*" element={<NotFoundPage />} />
}
/>
<Route
path="/add_item"
element={
<PrivateRoute>
<AddItem />
</PrivateRoute>
}
/>
<Route
path="/about"
element={
<PrivateRoute>
<About />
</PrivateRoute>
}
/>
<Route
path="/shop"
element={
<PrivateRoute>
<Shop />
</PrivateRoute>
}
/>
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>
); );
+20 -16
View File
@@ -1,24 +1,28 @@
import PageLayout from "../components/PageLayout"; import PageLayout from "../components/PageLayout";
import { useState, useEffect } from "react" import FishBack from "../assets/Исходники/fish1.jpg";
import * as api from '../api/index'
export default function Shop() { export default function Shop() {
const [items, setItems] = useState([])
const [loading, setLoading] = useState(true);
useEffect(() => {
pa
})
return ( return (
<PageLayout> <PageLayout>
<main className="px-16 grow w-full"> <main className="px-6 md:px-16 grow w-full mb-6">
<div className="flex flex-row text-white"> <div className="flex flex-col text-white text-2xl font-medium ">
<div className="text-4xl flex-col"> <div className="uppercase text-2xl md:text-4xl md:mt-10">
<h1 className="uppercase">fish fish</h1> fish fish
</div>
<div className="flex flex-col md:flex-row items-center justify-between mt-7.5 md:mt-15 w-full">
<div className="text-white text-lg md:text-3xl font-medium md:font-extralight w-full md:w-2/3 md:px-[12.5%] flex flex-col items-center mt-7.5 justify-center text-center md:items-start md:text-left md:p-6 ">
Мы FISH FISH занимаемся доставкой свежих морепродуктов и рыбы на
любой вкус. Всегда только свежие продукты в охлажденном состоянии,
герметичной упаковке. Наши курьеры привозят рыбу и морепродукты в
переносных холодильных пакетах или камерах. Качество продукции для
нас выше всего!
</div>
<div className="md:w-1/3 md:ml-auto">
<img
src={FishBack}
className="w-full object-contain max-h-150 rounded md:w-auto"
/>
</div>
</div> </div>
</div> </div>
</main> </main>
+1 -1
View File
@@ -17,7 +17,7 @@ export default function Dashboard() {
className="px-5 md:px-16 grow w-full bg-cover bg-center bg-no-repeat h-screen overflow-hidden" className="px-5 md:px-16 grow w-full bg-cover bg-center bg-no-repeat h-screen overflow-hidden"
style={{ backgroundImage: `url(${bgLayout})` }} style={{ backgroundImage: `url(${bgLayout})` }}
> >
<div className="mt-10 md:mt-37.5 leading-[1.3] text-2xl md:text-6xl font-bold text-white flex flex-col"> <div className="mt-10 md:mt-37.5 text-2xl md:text-6xl font-bold text-white flex flex-col">
<div <div
className={`transition-all duration-1000 ease-out ${isLoaded className={`transition-all duration-1000 ease-out ${isLoaded
? "translate-x-0 opacity-100" ? "translate-x-0 opacity-100"
+11
View File
@@ -0,0 +1,11 @@
import PageLayout from "../components/PageLayout";
export default function NotFounePage() {
return (
<PageLayout>
<main className="px-6 md:px-16 grow w-full flex text-white items-center justify-center font-black text-6xl">
<h1>Страница не найдена :c</h1>
</main>
</PageLayout>
);
}
+2 -2
View File
@@ -41,7 +41,7 @@ export default function Shop() {
return ( return (
<PageLayout> <PageLayout>
<main className="px-6 md:px-16 grow w-full "> <main className="px-6 md:px-16 grow w-full ">
<h1 className="text-2xl text-white text-medium md:mt-10"> <h1 className="text-2xl md:text-4xl text-white font-medium md:mt-10">
Ассортимент Ассортимент
</h1> </h1>
<CategoryTabs <CategoryTabs
@@ -49,7 +49,7 @@ export default function Shop() {
activeCategory={activeCategory} activeCategory={activeCategory}
onSelectCategory={setActiveCategory} onSelectCategory={setActiveCategory}
/> />
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-4"> <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6 mb-4">
{filteredItems.map((item) => ( {filteredItems.map((item) => (
<CardItem key={item.id} item={item} onAddToCart={handleAddToCart} /> <CardItem key={item.id} item={item} onAddToCart={handleAddToCart} />
))} ))}