template and back

This commit is contained in:
romantarkin committed 2025-01-29 15:09:27 +05:00
commit 07ef7e9b8f
3773 files changed
+422508

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/body-types');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/body-types', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/body-types', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/body-types', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/car-brands');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/car-brands', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/car-brands', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/car-brands', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/car-colors');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/car-colors', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/car-colors', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/car-colors', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/car-models');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/car-models', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/car-models', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/car-models', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/cars');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/cars', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/cars', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/cars', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/bodyTypes";
interface BodyTypeContextType {
bodyType: ReactElement | null;
setBodyType: (content: ReactElement | null) => void;
}
const BodyTypeContext = createContext<BodyTypeContextType | undefined>(undefined);
export const BodyTypeProvider = ({ children }: { children: ReactNode }) => {
const [bodyType, setBodyType] = useState<any | null>(null);
const fetchData = async () => {
setBodyType(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<BodyTypeContext.Provider value={{ bodyType, setBodyType }}>
{children}
</BodyTypeContext.Provider>
);
};
export const useBodyTypeContext = (): BodyTypeContextType => {
const context = useContext(BodyTypeContext);
if (!context) {
throw new Error('useBodyTypeContext must be used within a BodyTypeProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/cars";
interface CarContextType {
car: ReactElement | null;
setCar: (content: ReactElement | null) => void;
}
const CarContext = createContext<CarContextType | undefined>(undefined);
export const CarProvider = ({ children }: { children: ReactNode }) => {
const [car, setCar] = useState<any | null>(null);
const fetchData = async () => {
setCar(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<CarContext.Provider value={{ car, setCar }}>
{children}
</CarContext.Provider>
);
};
export const useCarContext = (): CarContextType => {
const context = useContext(CarContext);
if (!context) {
throw new Error('useCarContext must be used within a CarProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/carBrands";
interface CarBrandContextType {
carBrand: ReactElement | null;
setCarBrand: (content: ReactElement | null) => void;
}
const CarBrandContext = createContext<CarBrandContextType | undefined>(undefined);
export const CarBrandProvider = ({ children }: { children: ReactNode }) => {
const [carBrand, setCarBrand] = useState<any | null>(null);
const fetchData = async () => {
setCarBrand(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<CarBrandContext.Provider value={{ carBrand, setCarBrand }}>
{children}
</CarBrandContext.Provider>
);
};
export const useCarBrandContext = (): CarBrandContextType => {
const context = useContext(CarBrandContext);
if (!context) {
throw new Error('useCarBrandContext must be used within a CarBrandProvider');
}
return context;
};
+45
View File
@@ -0,0 +1,45 @@
'use client'
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { list } from "@/api/carColors";
// Define types for carColor item
interface CarColorItem {
id: string;
name: string;
hexCode: string;
}
interface CarColorType {
carColor: CarColorItem[] | null;
setCarColor: (content: CarColorItem[]) => void;
fetchData: () => void;
}
const CarColorContext = createContext<CarColorType | undefined>(undefined);
export const CarColorProvider = ({ children }: { children: ReactNode }) => {
const [carColor, setCarColor] = useState<CarColorItem[]>([]);
const fetchData = async () => {
setCarColor(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<CarColorContext.Provider value={{ carColor, setCarColor, fetchData }}>
{children}
</CarColorContext.Provider>
);
};
export const useCarColorContext = (): CarColorType => {
const context = useContext(CarColorContext);
if (!context) {
throw new Error('useCarColorContext must be used within a CarColorProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/carModels";
interface CarModelContextType {
carModel: ReactElement | null;
setCarModel: (content: ReactElement | null) => void;
}
const CarModelContext = createContext<CarModelContextType | undefined>(undefined);
export const CarModelProvider = ({ children }: { children: ReactNode }) => {
const [carModel, setCarModel] = useState<any | null>(null);
const fetchData = async () => {
setCarModel(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<CarModelContext.Provider value={{ carModel, setCarModel }}>
{children}
</CarModelContext.Provider>
);
};
export const useCarModelContext = (): CarModelContextType => {
const context = useContext(CarModelContext);
if (!context) {
throw new Error('useCarModelContext must be used within a CarModelProvider');
}
return context;
};
+45
View File
@@ -0,0 +1,45 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { list } from "@/api/customers";
interface CustomerItem {
id: string;
name: string;
phone: string;
email: string;
}
interface CustomerContextType {
customers: CustomerItem[] | [];
setCustomers: (content: CustomerItem[] | []) => void;
fetchData: () => void;
}
const CustomerContext = createContext<CustomerContextType | undefined>(undefined);
export const CustomerProvider = ({ children }: { children: ReactNode }) => {
const [customers, setCustomers] = useState<any | null>([]);
const fetchData = async () => {
setCustomers(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<CustomerContext.Provider value={{ customers, setCustomers, fetchData }}>
{children}
</CustomerContext.Provider>
);
};
export const useCustomerContext = (): CustomerContextType => {
const context = useContext(CustomerContext);
if (!context) {
throw new Error('useCustomerContext must be used within a CustomerProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/engines";
interface EngineContextType {
engine: ReactElement | null;
setEngine: (content: ReactElement | null) => void;
}
const EngineContext = createContext<EngineContextType | undefined>(undefined);
export const EngineProvider = ({ children }: { children: ReactNode }) => {
const [engine, setEngine] = useState<any | null>(null);
const fetchData = async () => {
setEngine(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<EngineContext.Provider value={{ engine, setEngine }}>
{children}
</EngineContext.Provider>
);
};
export const useEngineContext = (): EngineContextType => {
const context = useContext(EngineContext);
if (!context) {
throw new Error('useEngineContext must be used within an EngineProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/sales"; // Assuming your API call for sales is here
interface SaleContextType {
sale: ReactElement | null;
setSale: (content: ReactElement | null) => void;
}
const SaleContext = createContext<SaleContextType | undefined>(undefined);
export const SaleProvider = ({ children }: { children: ReactNode }) => {
const [sale, setSale] = useState<any | null>(null);
const fetchData = async () => {
setSale(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<SaleContext.Provider value={{ sale, setSale }}>
{children}
</SaleContext.Provider>
);
};
export const useSaleContext = (): SaleContextType => {
const context = useContext(SaleContext);
if (!context) {
throw new Error('useSaleContext must be used within a SaleProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/transmissions";
interface TransmissionContextType {
transmission: ReactElement | null;
setTransmission: (content: ReactElement | null) => void;
}
const TransmissionContext = createContext<TransmissionContextType | undefined>(undefined);
export const TransmissionProvider = ({ children }: { children: ReactNode }) => {
const [transmission, setTransmission] = useState<any | null>(null);
const fetchData = async () => {
setTransmission(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<TransmissionContext.Provider value={{ transmission, setTransmission }}>
{children}
</TransmissionContext.Provider>
);
};
export const useTransmissionContext = (): TransmissionContextType => {
const context = useContext(TransmissionContext);
if (!context) {
throw new Error('useTransmissionContext must be used within a TransmissionProvider');
}
return context;
};
+38
View File
@@ -0,0 +1,38 @@
"use client"
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { ReactElement } from 'react';
import { list } from "@/api/trims";
interface TrimContextType {
trim: ReactElement | null;
setTrim: (content: ReactElement | null) => void;
}
const TrimContext = createContext<TrimContextType | undefined>(undefined);
export const TrimProvider = ({ children }: { children: ReactNode }) => {
const [trim, setTrim] = useState<any | null>(null);
const fetchData = async () => {
setTrim(await list());
};
useEffect(() => {
fetchData();
}, []);
return (
<TrimContext.Provider value={{ trim, setTrim }}>
{children}
</TrimContext.Provider>
);
};
export const useTrimContext = (): TrimContextType => {
const context = useContext(TrimContext);
if (!context) {
throw new Error('useTrimContext must be used within a TrimProvider');
}
return context;
};
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/customers');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/customers', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/customers', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/engines');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/engines', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/engines', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/engines', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/sales');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/sales', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/sales', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/sales', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/transmissions');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/transmissions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/transmissions', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/transmissions', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
+42
View File
@@ -0,0 +1,42 @@
export async function list () {
const response = await fetch('/api/v1/trims');
return (await response.json()).results.rows;
}
export async function add (params: any) {
const response = await fetch('/api/v1/trims', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}
export async function update (params: any) {
const response = await fetch('/api/v1/trims', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
updates: params,
where: {
id: params.id,
}
})
});
return await response.json();
}
export async function remove (params: any) {
const response = await fetch('/api/v1/trims', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params)
});
return await response.json();
}