add first version of product
parent
ed0f16e6c1
commit
2f4ee7021e
|
@ -36,5 +36,4 @@ yarn-error.log*
|
|||
next-env.d.ts
|
||||
|
||||
.idea/
|
||||
./docker-compose.yml
|
||||
./Dockerfile
|
||||
Dockerfile
|
||||
|
|
|
@ -34,7 +34,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
{
|
||||
// FIO
|
||||
orderPropsId: 103,
|
||||
value: body.fullName,E
|
||||
value: body.fullName
|
||||
},
|
||||
{
|
||||
// Phone
|
||||
|
|
|
@ -180,7 +180,8 @@ const OilCard = ({product}: InferGetStaticPropsType<typeof getStaticProps>) => {
|
|||
export default OilCard
|
||||
|
||||
export const getStaticPaths = async () => {
|
||||
const {data} = await axios.get<ResponseData[]>("http://localhost:8000/api/v1/catalog")
|
||||
const service = new LocalAPI()
|
||||
const data = await service.getCatalogItems() as {code: string}[]
|
||||
const codes = data.map(item => ({params: {code: item.code}}))
|
||||
return {
|
||||
paths: [
|
||||
|
@ -192,7 +193,8 @@ export const getStaticPaths = async () => {
|
|||
}
|
||||
|
||||
export const getStaticProps = async ({params: {code}}: { params: { code: string } }) => {
|
||||
const {data} = await axios.get<ResponseData>(`http://localhost:8000/api/v1/catalog/${code}`)
|
||||
const service = new LocalAPI()
|
||||
const data = await service.getCatalogItemByCode(code)
|
||||
return {
|
||||
props: {
|
||||
product: data
|
||||
|
|
|
@ -5,12 +5,9 @@ import {
|
|||
Checkbox,
|
||||
Button, Skeleton
|
||||
} from "@nextui-org/react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import axios from "axios";
|
||||
import {InferGetStaticPropsType} from "next";
|
||||
import {ResponseData} from "@/pages/api/v1/catalog/properties"
|
||||
import {ResponseData as ResponseDataProduct} from "@/pages/api/v1/catalog"
|
||||
import FavouriteIcon from "@/../public/favourites_icon.svg";
|
||||
import {Dispatch, SetStateAction, useEffect, useState} from "react";
|
||||
import {toggleFavourite} from "@/store/favourites";
|
||||
|
@ -80,7 +77,7 @@ const CatalogCard = (product: CardProps) => {
|
|||
imageIsLoading && <Skeleton className={"absolute top-0 left-0 right-3/4 rounded-[20px] h-full"} />
|
||||
}
|
||||
{
|
||||
product.properties.main_image && <Image src={`http://relynolli.elitvinenko.tech/upload/${product.properties.main_image[0]}`} alt={product.properties.viscosity!} className={"col-auto mx-auto mb-4 sm:col-span-2 sm:row-span-2"} width={300} height={430} onLoad={onImageLoad}/>
|
||||
product.properties.main_image && <img src={`/upload/${product.properties.main_image[0]}`} alt={product.name} className={"col-auto mx-auto mb-4 sm:col-span-2 sm:row-span-2"} width={300} height={430} onLoad={onImageLoad}/>
|
||||
}
|
||||
<div className="col-auto sm:col-start-4 sm:col-span-6 h-full flex flex-col justify-center">
|
||||
<span className={"text-[#52525C] font-normal text-subtitle-4 mb-2 block"}>Стандарт API: {product.properties.api_standart} Тип: {product.properties.oil_type}</span>
|
||||
|
@ -137,11 +134,24 @@ const Catalog = (props: InferGetStaticPropsType<typeof getStaticProps>) => {
|
|||
export default Catalog;
|
||||
|
||||
export const getStaticProps = async () => {
|
||||
const {data} = await axios.get<ResponseData[]>("http://localhost:8000/api/v1/catalog/filters")
|
||||
const {data: catalogData} = await axios.get<ResponseDataProduct[]>("http://localhost:8000/api/v1/catalog")
|
||||
const service = new LocalAPI()
|
||||
const filterData = await service.getFilters() as {id: number, name: string, values: {id: number, value: string}[]}[]
|
||||
const catalogData = await service.getCatalogItems() as {
|
||||
id: number
|
||||
code: string,
|
||||
name: string,
|
||||
properties: {
|
||||
[key: string]: string | string[]
|
||||
}
|
||||
detailText: string,
|
||||
price: {
|
||||
[key: string]: number | null
|
||||
}
|
||||
}[]
|
||||
|
||||
return {
|
||||
props: {
|
||||
filterPropertiesData: data,
|
||||
filterPropertiesData: filterData,
|
||||
catalog: catalogData
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import axios, {AxiosInstance} from "axios";
|
||||
import {ResponseData} from "@/pages/api/v1/catalog";
|
||||
|
||||
|
||||
type createFUserType = {
|
||||
|
@ -22,10 +23,25 @@ class LocalAPI {
|
|||
|
||||
constructor() {
|
||||
this.instance = axios.create({
|
||||
baseURL: 'http://localhost:8000'
|
||||
baseURL: process.env.NODE_ENV === "development" ? "http://localhost:8000": "https://relynolli.ru"
|
||||
})
|
||||
}
|
||||
|
||||
async getCatalogItems() {
|
||||
const {data} = await this.instance.get('/api/v1/catalog')
|
||||
return data
|
||||
}
|
||||
|
||||
async getFilters() {
|
||||
const {data} = await this.instance.get("/api/v1/catalog/filters")
|
||||
return data
|
||||
}
|
||||
|
||||
async getCatalogItemByCode(code: string) {
|
||||
const {data} = await this.instance.get<ResponseData>(`/api/v1/catalog/${code}`)
|
||||
return data
|
||||
}
|
||||
|
||||
async getFuserId() {
|
||||
let fuserId: string | number | null = localStorage.getItem('fuserId')
|
||||
|
||||
|
|
Loading…
Reference in New Issue