info vendedor + direccion del producto
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
DROP VIEW "public"."v_product_store";--> statement-breakpoint
|
||||||
|
ALTER TABLE "products" ADD COLUMN "address" text NOT NULL;--> statement-breakpoint
|
||||||
|
CREATE VIEW "public"."v_product_store" AS (
|
||||||
|
select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.user_id, u.fullname, u.email, u.phone
|
||||||
|
from products p
|
||||||
|
left join auth.users as u on u.id = p.user_id);
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
DROP VIEW "public"."v_product_store";--> statement-breakpoint
|
||||||
|
CREATE VIEW "public"."v_product_store" AS (
|
||||||
|
select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.address, p.user_id, u.fullname, u.email, u.phone
|
||||||
|
from products p
|
||||||
|
left join auth.users as u on u.id = p.user_id);
|
||||||
1516
apps/api/src/database/migrations/meta/0004_snapshot.json
Normal file
1516
apps/api/src/database/migrations/meta/0004_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1522
apps/api/src/database/migrations/meta/0005_snapshot.json
Normal file
1522
apps/api/src/database/migrations/meta/0005_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,20 @@
|
|||||||
"when": 1751482400155,
|
"when": 1751482400155,
|
||||||
"tag": "0003_icy_gertrude_yorkes",
|
"tag": "0003_icy_gertrude_yorkes",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 4,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1752500116385,
|
||||||
|
"tag": "0004_colorful_aqueduct",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 5,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1752500607554,
|
||||||
|
"tag": "0005_little_bloodscream",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ export const products = t.pgTable(
|
|||||||
description: t.text('description').notNull(),
|
description: t.text('description').notNull(),
|
||||||
price: t.numeric('price').notNull(),
|
price: t.numeric('price').notNull(),
|
||||||
stock: t.integer('stock').notNull(),
|
stock: t.integer('stock').notNull(),
|
||||||
|
address: t.text('address').notNull(),
|
||||||
urlImg: t.text('url_img').notNull(),
|
urlImg: t.text('url_img').notNull(),
|
||||||
userId: t.integer('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
|
userId: t.integer('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
|
||||||
...timestamps,
|
...timestamps,
|
||||||
@@ -24,11 +25,12 @@ export const viewProductsStore = t.pgView('v_product_store', {
|
|||||||
price: t.numeric('price'),
|
price: t.numeric('price'),
|
||||||
stock: t.integer('stock'),
|
stock: t.integer('stock'),
|
||||||
urlImg: t.text('url_img'),
|
urlImg: t.text('url_img'),
|
||||||
|
address: t.text('address'),
|
||||||
userId: t.integer('user_id'),
|
userId: t.integer('user_id'),
|
||||||
fullname: t.text('fullname'),
|
fullname: t.text('fullname'),
|
||||||
email: t.text('email'),
|
email: t.text('email'),
|
||||||
phone: t.text('phone')
|
phone: t.text('phone')
|
||||||
}).as(sql`
|
}).as(sql`
|
||||||
select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.user_id, u.fullname, u.email, u.phone
|
select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.address, p.user_id, u.fullname, u.email, u.phone
|
||||||
from products p
|
from products p
|
||||||
left join auth.users as u on u.id = p.user_id`);
|
left join auth.users as u on u.id = p.user_id`);
|
||||||
@@ -7,7 +7,7 @@ export async function seedProducts(db: NodePgDatabase<typeof schema>) {
|
|||||||
console.log('Seeding example product...');
|
console.log('Seeding example product...');
|
||||||
|
|
||||||
// Insert inventory
|
// Insert inventory
|
||||||
const array = [{title:'manzana',description:'fruta roja',price:'100',urlImg:'apple.avif',userId:1,stock:0}];
|
const array = [{title:'manzana',description:'fruta roja',price:'100',urlImg:'apple.avif',address:"Calle 1",userId:1,stock:0}];
|
||||||
|
|
||||||
for (const item of array) {
|
for (const item of array) {
|
||||||
try {
|
try {
|
||||||
@@ -16,6 +16,7 @@ export async function seedProducts(db: NodePgDatabase<typeof schema>) {
|
|||||||
description: item.description,
|
description: item.description,
|
||||||
price: item.price,
|
price: item.price,
|
||||||
stock: item.stock,
|
stock: item.stock,
|
||||||
|
address: item.address,
|
||||||
urlImg: item.urlImg,
|
urlImg: item.urlImg,
|
||||||
userId: item.userId
|
userId: item.userId
|
||||||
}).onConflictDoNothing();
|
}).onConflictDoNothing();
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ export class CreateProductDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
stock: number;
|
stock: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString({
|
||||||
|
message: 'address must be a string',
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
address: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsInt({
|
@IsInt({
|
||||||
message: 'stock must be a number',
|
message: 'stock must be a number',
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ export class UpdateProductDto extends PartialType(CreateProductDto) {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
stock: number;
|
stock: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
address: string;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
urlImg: string;
|
urlImg: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export class InventoryService {
|
|||||||
id: products.id,
|
id: products.id,
|
||||||
title: products.title,
|
title: products.title,
|
||||||
description: products.description,
|
description: products.description,
|
||||||
|
address: products.address,
|
||||||
price: products.price,
|
price: products.price,
|
||||||
stock: products.stock,
|
stock: products.stock,
|
||||||
urlImg: products.urlImg
|
urlImg: products.urlImg
|
||||||
@@ -113,10 +114,13 @@ export class InventoryService {
|
|||||||
title: viewProductsStore.title,
|
title: viewProductsStore.title,
|
||||||
description: viewProductsStore.description,
|
description: viewProductsStore.description,
|
||||||
price: viewProductsStore.price,
|
price: viewProductsStore.price,
|
||||||
|
address: viewProductsStore.address,
|
||||||
urlImg: viewProductsStore.urlImg,
|
urlImg: viewProductsStore.urlImg,
|
||||||
stock: viewProductsStore.stock,
|
stock: viewProductsStore.stock,
|
||||||
userId: viewProductsStore.userId,
|
userId: viewProductsStore.userId,
|
||||||
fullname: viewProductsStore.fullname
|
fullname: viewProductsStore.fullname,
|
||||||
|
email: viewProductsStore.email,
|
||||||
|
phone: viewProductsStore.phone
|
||||||
})
|
})
|
||||||
.from(viewProductsStore)
|
.from(viewProductsStore)
|
||||||
.where(searchCondition)
|
.where(searchCondition)
|
||||||
@@ -145,10 +149,13 @@ export class InventoryService {
|
|||||||
title: viewProductsStore.title,
|
title: viewProductsStore.title,
|
||||||
description: viewProductsStore.description,
|
description: viewProductsStore.description,
|
||||||
price: viewProductsStore.price,
|
price: viewProductsStore.price,
|
||||||
|
address: viewProductsStore.address,
|
||||||
urlImg: viewProductsStore.urlImg,
|
urlImg: viewProductsStore.urlImg,
|
||||||
stock: viewProductsStore.stock,
|
stock: viewProductsStore.stock,
|
||||||
userId: viewProductsStore.userId,
|
userId: viewProductsStore.userId,
|
||||||
fullname: viewProductsStore.fullname
|
fullname: viewProductsStore.fullname,
|
||||||
|
email: viewProductsStore.email,
|
||||||
|
phone: viewProductsStore.phone
|
||||||
})
|
})
|
||||||
.from(viewProductsStore)
|
.from(viewProductsStore)
|
||||||
.where(eq(viewProductsStore.id, parseInt(id)));
|
.where(eq(viewProductsStore.id, parseInt(id)));
|
||||||
@@ -175,6 +182,7 @@ export class InventoryService {
|
|||||||
title: createProductDto.title,
|
title: createProductDto.title,
|
||||||
description: createProductDto.description,
|
description: createProductDto.description,
|
||||||
price: createProductDto.price,
|
price: createProductDto.price,
|
||||||
|
address: createProductDto.address,
|
||||||
urlImg: createProductDto.urlImg,
|
urlImg: createProductDto.urlImg,
|
||||||
stock: createProductDto.stock,
|
stock: createProductDto.stock,
|
||||||
userId: createProductDto.userId
|
userId: createProductDto.userId
|
||||||
@@ -195,6 +203,7 @@ export class InventoryService {
|
|||||||
if (updateProductDto.title) updateData.title = updateProductDto.title;
|
if (updateProductDto.title) updateData.title = updateProductDto.title;
|
||||||
if (updateProductDto.description) updateData.description = updateProductDto.description;
|
if (updateProductDto.description) updateData.description = updateProductDto.description;
|
||||||
if (updateProductDto.price) updateData.price = updateProductDto.price;
|
if (updateProductDto.price) updateData.price = updateProductDto.price;
|
||||||
|
if (updateProductDto.address) updateData.address = updateProductDto.address;
|
||||||
if (updateProductDto.stock) updateData.stock = updateProductDto.stock;
|
if (updateProductDto.stock) updateData.stock = updateProductDto.stock;
|
||||||
if (updateProductDto.urlImg) updateData.urlImg = updateProductDto.urlImg;
|
if (updateProductDto.urlImg) updateData.urlImg = updateProductDto.urlImg;
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ export default async function SurveyResponsePage({
|
|||||||
|
|
||||||
const product = data.data
|
const product = data.data
|
||||||
|
|
||||||
// console.log(data.data);
|
const lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore placeat est corporis minus exercitationem impedit ab architecto dolorum nihil nam facilis suscipit porro, iure et quidem illo mollitia officia amet?"
|
||||||
|
|
||||||
|
// console.log(data.data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// <PageContainer>
|
// <PageContainer>
|
||||||
@@ -52,19 +53,27 @@ export default async function SurveyResponsePage({
|
|||||||
</CardTitle>
|
</CardTitle>
|
||||||
<p className='font-semibold'>$ {product.price}</p>
|
<p className='font-semibold'>$ {product.price}</p>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex-grow">
|
<CardContent className="flex-grow flex justify-between flex-col gap-4">
|
||||||
|
<div>
|
||||||
<p className='font-semibold text-lg border-t border-b'> Descripción</p>
|
<p className='font-semibold text-lg border-t border-b'> Descripción</p>
|
||||||
<p className='p-1'>{product.description}</p>
|
<p className='p-1'>{product.description}</p>
|
||||||
|
{/* <p className='p-1'>{lorem+lorem+lorem+lorem}</p> */}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p className='font-semibold text-lg border-t border-b'> Dirección</p>
|
||||||
|
<p>{product.address}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter className="">
|
<CardFooter className="">
|
||||||
<div>
|
<div>
|
||||||
<p className='font-semibold text-lg border-t border-b mt-4'>Información del vendedor</p>
|
<p className='font-semibold text-lg border-t border-b mt-4'>Información del vendedor</p>
|
||||||
<p>{product.fullname}</p>
|
<p>{product.fullname}</p>
|
||||||
<p>Correo@gmail.com</p>
|
<p>{product.phone}</p>
|
||||||
<p>0412-7848101</p>
|
<p>{product.email}</p>
|
||||||
</div>
|
</div>
|
||||||
{/* <p className="font-semibold text-lg">$ {product.price}</p> */}
|
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -6,18 +6,25 @@ export type InventoryTable = z.infer<typeof product>;
|
|||||||
export type EditInventory = z.infer<typeof editInventory>; //output
|
export type EditInventory = z.infer<typeof editInventory>; //output
|
||||||
export type formDataInput = z.input<typeof editInventory>;
|
export type formDataInput = z.input<typeof editInventory>;
|
||||||
export type ProductApiResponseSchema = z.infer<typeof productApiResponseSchema>;
|
export type ProductApiResponseSchema = z.infer<typeof productApiResponseSchema>;
|
||||||
export type allProducts = z.infer<typeof allProducts>;
|
export type allProducts = z.infer<typeof productDetails>;
|
||||||
|
|
||||||
export const product = z.object({
|
export const product = z.object({
|
||||||
id: z.number().optional(),
|
id: z.number().optional(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
|
address: z.string(),
|
||||||
// category: z.string(),
|
// category: z.string(),
|
||||||
stock: z.number(),
|
stock: z.number(),
|
||||||
price: z.string(),
|
price: z.string(),
|
||||||
urlImg: z.string(),
|
urlImg: z.string(),
|
||||||
userId: z.number().optional()
|
userId: z.number().optional()
|
||||||
});
|
})
|
||||||
|
|
||||||
|
export const productDetails = product.extend({
|
||||||
|
fullname: z.string(),
|
||||||
|
phone: z.string().nullable(),
|
||||||
|
email: z.string().email().nullable()
|
||||||
|
})
|
||||||
|
|
||||||
export const editInventory = z.object({
|
export const editInventory = z.object({
|
||||||
id: z.number().optional(),
|
id: z.number().optional(),
|
||||||
@@ -31,16 +38,16 @@ export const editInventory = z.object({
|
|||||||
userId: z.number().optional(),
|
userId: z.number().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const allProducts = z.object({
|
// export const productDetails = z.object({
|
||||||
id: z.number().optional(),
|
// id: z.number().optional(),
|
||||||
title: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
|
// title: z.string().min(5),
|
||||||
description: z.string().min(10, { message: "Debe de tener 10 o más caracteres" }),
|
// description: z.string().min(10),
|
||||||
stock: z.number(),
|
// stock: z.number(),
|
||||||
price: z.string(),
|
// price: z.string(),
|
||||||
urlImg: z.string(),
|
// address: z.string(),
|
||||||
userId: z.number(),
|
// urlImg: z.string(),
|
||||||
fullname: z.string()
|
// userId: z.number(),
|
||||||
})
|
// })
|
||||||
|
|
||||||
export const ApiResponseSchema = z.object({
|
export const ApiResponseSchema = z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
@@ -59,7 +66,7 @@ export const ApiResponseSchema = z.object({
|
|||||||
|
|
||||||
export const productApiResponseSchema = z.object({
|
export const productApiResponseSchema = z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
data: z.array(allProducts),
|
data: z.array(productDetails),
|
||||||
meta: z.object({
|
meta: z.object({
|
||||||
page: z.number(),
|
page: z.number(),
|
||||||
limit: z.number(),
|
limit: z.number(),
|
||||||
@@ -79,5 +86,5 @@ export const productMutate = z.object({
|
|||||||
|
|
||||||
export const getProduct = z.object({
|
export const getProduct = z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
data: allProducts,
|
data: productDetails,
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user