Add sale management feature for admin panel

- Add database migration for sale fields (percentage, active, dates)
- Update API to handle sale operations and bulk updates
- Create SaleManager component for admin interface
- Update FilamentTableV2 to display sale prices on frontend
- Add sale column in admin dashboard
- Implement sale price calculations with strikethrough styling
This commit is contained in:
DaX
2025-07-05 14:48:31 +02:00
parent c0682e1969
commit 0df9d5d294
10 changed files with 354 additions and 5 deletions

39
scripts/deploy-api-update.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
echo "Deploying API update to EC2 instance..."
# Get instance ID
INSTANCE_ID="i-03956ecf32292d7d9"
# Create update script
cat > /tmp/update-api.sh << 'EOF'
#!/bin/bash
cd /home/ubuntu/filamenteka-api
# Backup current server.js
cp server.js server.js.backup
# Download the updated server.js from GitHub
curl -o server.js https://raw.githubusercontent.com/daxdax89/Filamenteka/sale/api/server.js
# Restart the service
sudo systemctl restart node-api
echo "API server updated and restarted"
EOF
# Send command to EC2 instance
aws ssm send-command \
--region eu-central-1 \
--instance-ids "$INSTANCE_ID" \
--document-name "AWS-RunShellScript" \
--parameters "commands=[
'cd /home/ubuntu/filamenteka-api',
'cp server.js server.js.backup',
'curl -o server.js https://raw.githubusercontent.com/daxdax89/Filamenteka/sale/api/server.js',
'sudo systemctl restart node-api',
'sudo systemctl status node-api'
]" \
--output json
echo "Command sent. Check AWS Systems Manager for execution status."

17
scripts/run-sale-migration.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
echo "Running sale fields migration..."
# Get RDS endpoint from AWS
RDS_ENDPOINT=$(aws rds describe-db-instances --region eu-central-1 --db-instance-identifier filamenteka --query 'DBInstances[0].Endpoint.Address' --output text)
# Get database credentials from Secrets Manager
DB_CREDS=$(aws secretsmanager get-secret-value --region eu-central-1 --secret-id filamenteka-db-credentials --query 'SecretString' --output text)
DB_USER=$(echo $DB_CREDS | jq -r '.username')
DB_PASS=$(echo $DB_CREDS | jq -r '.password')
DB_NAME=$(echo $DB_CREDS | jq -r '.database')
# Run the migration
PGPASSWORD="$DB_PASS" psql -h $RDS_ENDPOINT -U $DB_USER -d $DB_NAME -f database/migrations/014_add_sale_fields.sql
echo "Migration completed!"