Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions amplify/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineBackend } from '@aws-amplify/backend'
import { auth } from './auth/resource'
import { storage, productsImages, storeLogo, templates } from './storage/resource'
import { storage } from './storage/resource'
import { createSubscription } from './functions/createSubscription/resource'
import { webHookPlan } from './functions/webHookPlan/resource'
import { cancelPlan } from './functions/cancelPlan/resource'
Expand Down Expand Up @@ -39,13 +39,10 @@ const backend = defineBackend({
checkStoreName,
postConfirmation,
generateHaikuFunction,
productsImages,
checkStoreDomain,
storeLogo,
apiKeyManager,
generateProductDescriptionFunction,
generatePriceSuggestionFunction,
templates,
getStoreProducts,
getStoreData,
storeImages,
Expand Down Expand Up @@ -118,8 +115,8 @@ backend.storeImages.resources.lambda.addToRolePolicy(
effect: Effect.ALLOW,
actions: ['s3:ListBucket', 's3:GetObject', 's3:PutObject', 's3:DeleteObject'],
resources: [
backend.productsImages.resources.bucket.bucketArn,
`${backend.productsImages.resources.bucket.bucketArn}/*`,
backend.storage.resources.bucket.bucketArn,
`${backend.storage.resources.bucket.bucketArn}/*`,
],
})
)
Expand Down
1 change: 0 additions & 1 deletion amplify/functions/storeImages/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@aws-sdk/client-s3'
import { env } from '$amplify/env/storeImages'

// Inicializar el cliente S3
const s3Client = new S3Client()

const bucketName = env.BUCKET_NAME
Expand Down
70 changes: 8 additions & 62 deletions amplify/storage/resource.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,36 @@
import { defineStorage } from '@aws-amplify/backend'

/**
* Configuración de almacenamiento para fotos de perfil
* Configuración de almacenamiento para almacenar archivos en S3
* Este bucket es el predeterminado para la aplicación
*/
export const storage = defineStorage({
name: 'profilePictures',
name: 'fasttifyAssets',
isDefault: true,
access: allow => ({
'public/profile-pictures/{entity_id}/*': [
// Cualquier usuario puede leer las fotos de perfil
'profile-pictures/{entity_id}/*': [
allow.guest.to(['read']),
// Los usuarios autenticados pueden subir archivos
allow.authenticated.to(['read', 'write']),
// El propietario tiene control total sobre sus archivos
allow.entity('identity').to(['read', 'write', 'delete']),
],
'picture-submissions/*': [
// Los usuarios autenticados pueden leer y escribir
allow.authenticated.to(['read', 'write']),
// Los invitados solo pueden leer
allow.guest.to(['read']),
// Solo el propietario puede eliminar sus archivos
allow.entity('identity').to(['delete']),
],
}),
})

/**
* Configuración de almacenamiento para imágenes de productos
* Bucket dedicado para almacenar todas las imágenes relacionadas con productos
*/
export const productsImages = defineStorage({
name: 'productsImages',
access: allow => ({
'products/{entity_id}/*': [
// Cualquier usuario puede ver las imágenes de productos
allow.guest.to(['read']),
// Los usuarios autenticados pueden subir imágenes
allow.authenticated.to(['read', 'write']),
// El propietario tiene control total sobre sus archivos
allow.entity('identity').to(['read', 'write', 'delete']),
],
'picture-submissions/*': [
// Los usuarios autenticados pueden leer y escribir
allow.authenticated.to(['read', 'write']),
// Los invitados solo pueden leer
'store-logos/{entity_id}/*': [
allow.guest.to(['read']),
// Solo el propietario puede eliminar sus archivos
allow.entity('identity').to(['delete']),
allow.authenticated.to(['read', 'write']),
allow.entity('identity').to(['read', 'write', 'delete']),
],
}),
})

/**
* Configuración de almacenamiento para logos de tiendas
* Bucket dedicado para almacenar logos e imágenes de identidad de las tiendas
*/
export const storeLogo = defineStorage({
name: 'storeLogo',
access: allow => ({
'store/{entity_id}/*': [
// Cualquier usuario puede ver los logos de tiendas
'templates/{entity_id}/*': [
allow.guest.to(['read']),
// Los usuarios autenticados pueden subir logos
allow.authenticated.to(['read', 'write']),
// El propietario tiene control total sobre sus archivos
allow.entity('identity').to(['read', 'write', 'delete']),
],
'picture-submissions/*': [
// Los usuarios autenticados pueden leer y escribir
allow.authenticated.to(['read', 'write']),
// Los invitados solo pueden leer
allow.guest.to(['read']),
// Solo el propietario puede eliminar sus archivos
allow.entity('identity').to(['delete']),
],
}),
})

export const templates = defineStorage({
name: 'templates',
access: allow => ({
'templates/{entity_id}/*': [
allow.authenticated.to(['read', 'write']),
allow.guest.to(['read']),
allow.entity('identity').to(['delete']),
],
}),
})
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export function useUpdateProfilePicture() {

// 1. Subir la imagen a S3 en una carpeta pública con el nombre único.
const result = await uploadData({
path: `public/profile-pictures/${userData?.sub}/${uniqueFileName}`,
path: `profile-pictures/${userData?.sub}/${uniqueFileName}`,
data: file,
options: {
contentType: file.type,
bucket: 'fasttifyAssets',
},
}).result

Expand Down
61 changes: 1 addition & 60 deletions app/store/components/ai-chat/AiInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { Globe, Paperclip, Send } from 'lucide-react'
import { Send } from 'lucide-react'
import { useState } from 'react'
import { Textarea } from '@/components/ui/textarea'
import { motion, AnimatePresence } from 'framer-motion'
Expand Down Expand Up @@ -73,65 +73,6 @@ export function AIInputWithSearch({
</div>

<div className="h-12 bg-black/5 dark:bg-white/5 rounded-b-xl">
<div className="absolute left-3 bottom-3 flex items-center gap-2">
<label className="cursor-pointer rounded-lg p-2 bg-black/5 dark:bg-white/5">
<input type="file" className="hidden" onChange={handleFileChange} />
<Paperclip className="w-4 h-4 text-black/40 dark:text-white/40 hover:text-black dark:hover:text-white transition-colors" />
</label>
<button
type="button"
onClick={() => setShowSearch(!showSearch)}
className={cn(
'rounded-full transition-all flex items-center gap-2 px-1.5 py-1 border h-8',
showSearch
? 'bg-sky-500/15 border-sky-400 text-sky-500'
: 'bg-black/5 dark:bg-white/5 border-transparent text-black/40 dark:text-white/40 hover:text-black dark:hover:text-white'
)}
>
<div className="w-4 h-4 flex items-center justify-center flex-shrink-0">
<motion.div
animate={{
rotate: showSearch ? 180 : 0,
scale: showSearch ? 1.1 : 1,
}}
whileHover={{
rotate: showSearch ? 180 : 15,
scale: 1.1,
transition: {
type: 'spring',
stiffness: 300,
damping: 10,
},
}}
transition={{
type: 'spring',
stiffness: 260,
damping: 25,
}}
>
<Globe
className={cn('w-4 h-4', showSearch ? 'text-sky-500' : 'text-inherit')}
/>
</motion.div>
</div>
<AnimatePresence>
{showSearch && (
<motion.span
initial={{ width: 0, opacity: 0 }}
animate={{
width: 'auto',
opacity: 1,
}}
exit={{ width: 0, opacity: 0 }}
transition={{ duration: 0.2 }}
className="text-sm overflow-hidden whitespace-nowrap text-sky-500 flex-shrink-0"
>
Search
</motion.span>
)}
</AnimatePresence>
</button>
</div>
<div className="absolute right-3 bottom-3">
<button
type="button"
Expand Down
Loading