From 812029fe8441638359ee0b2ea8e789ba3d664d46 Mon Sep 17 00:00:00 2001 From: "hamed@B" Date: Wed, 16 Sep 2026 14:14:04 +0330 Subject: [PATCH] chore: format project automatically before starting dev server --- .gitea/workflows/develop.yml | 166 ++++++++--------- .gitea/workflows/rollback.yml | 54 +++--- .gitea/workflows/test.yml | 52 +++--- .idea/workspace.xml | 148 +++++++++------ .prettierignore | 9 + .prettierrc.json | 11 ++ app/cart/page.tsx | 6 +- app/context/AuthContext.tsx | 23 ++- app/context/LanguageContext.tsx | 2 +- app/context/ThemeContext.tsx | 11 +- app/dashboard/layout.tsx | 6 +- app/dashboard/orders/[id]/page.tsx | 176 +++++++++++++----- app/dashboard/orders/page.tsx | 26 ++- app/dashboard/page.tsx | 74 ++++++-- app/dashboard/profile/page.tsx | 111 +++++++++--- app/globals.css | 124 ++++++++++--- app/layout.tsx | 23 +-- app/login/page.tsx | 14 +- app/page.tsx | 13 +- app/products/[id]/page.tsx | 8 +- app/products/page.tsx | 10 +- app/providers.tsx | 2 +- components/AboutSection.tsx | 2 +- components/CartPage.tsx | 52 ++++-- components/CartPersistence.tsx | 25 ++- components/DevelopmentNotice.tsx | 15 +- components/FeaturesSection.tsx | 59 +++--- components/FloatingItems.tsx | 4 +- components/Footer.tsx | 146 ++++++++------- components/Header.tsx | 71 +++++--- components/HeroSection.tsx | 34 ++-- components/HorizontalShowcase.tsx | 24 +-- components/LanguageToggle.tsx | 20 +- components/LocationsSection.tsx | 80 ++++---- components/MobileShowcase.tsx | 9 +- components/ProductDetails.tsx | 55 ++++-- components/ProductsPage.tsx | 54 ++++-- components/QuantityControl.tsx | 43 +++-- components/ShowcaseSection.tsx | 12 +- components/ThemeToggle.tsx | 31 ++-- components/VendingCard.tsx | 32 ++-- components/auth/AuthModal.tsx | 72 ++++++-- components/auth/ProtectedLink.tsx | 18 +- components/auth/ProtectedPage.tsx | 30 +-- components/dashboard/DashboardShell.tsx | 40 +++- components/dashboard/InvoiceDocument.tsx | 91 ++++++++-- components/dashboard/OrderCard.tsx | 35 +++- components/dashboard/OrderStatusTag.tsx | 9 +- data/account.ts | 221 +++++++++++++++++++---- data/commerce.ts | 127 ++++++------- data/content.ts | 82 +++++---- docker-compose.yml | 20 +- lib/axios.ts | 23 +-- lib/invoice.ts | 17 +- next.config.js | 8 +- package-lock.json | 17 ++ package.json | 70 +++---- postcss.config.js | 8 +- services/auth.ts | 15 +- services/orders.ts | 74 +++++++- store/cartSlice.ts | 98 +++++----- store/hooks.ts | 4 +- store/store.ts | 16 +- tailwind.config.ts | 101 +++++------ tsconfig.json | 51 ++++-- types/domain.ts | 129 ++++++------- 66 files changed, 2088 insertions(+), 1125 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json diff --git a/.gitea/workflows/develop.yml b/.gitea/workflows/develop.yml index e6b93dc..c337495 100644 --- a/.gitea/workflows/develop.yml +++ b/.gitea/workflows/develop.yml @@ -5,99 +5,99 @@ name: Build & Deploy (develop) # - Direct pushes to develop # main is intentionally NOT included yet (no prod target configured) on: - push: - branches: - - develop - pull_request: - branches: - - develop + push: + branches: + - develop + pull_request: + branches: + - develop jobs: - build-and-deploy: - runs-on: ubuntu-latest + build-and-deploy: + runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Resolve commit SHA - id: vars - run: | - # For PRs, gitea.sha is a temporary merge commit — use the real - # PR head commit instead so tags map to actual git history. - FULL_SHA="${{ gitea.event.pull_request.head.sha || gitea.sha }}" - echo "sha=${FULL_SHA:0:7}" >> "$GITHUB_OUTPUT" + - name: Resolve commit SHA + id: vars + run: | + # For PRs, gitea.sha is a temporary merge commit — use the real + # PR head commit instead so tags map to actual git history. + FULL_SHA="${{ gitea.event.pull_request.head.sha || gitea.sha }}" + echo "sha=${FULL_SHA:0:7}" >> "$GITHUB_OUTPUT" - - name: Build Docker image (tagged by commit SHA) - run: | - docker build -t robot-market:${{ steps.vars.outputs.sha }} . + - name: Build Docker image (tagged by commit SHA) + run: | + docker build -t robot-market:${{ steps.vars.outputs.sha }} . - - name: Save previous tag for rollback - id: backup - run: | - if [ -f /opt/robot-market-front/.env ]; then - cp /opt/robot-market-front/.env /opt/robot-market-front/.env.previous - echo "available=true" >> "$GITHUB_OUTPUT" - fi + - name: Save previous tag for rollback + id: backup + run: | + if [ -f /opt/robot-market-front/.env ]; then + cp /opt/robot-market-front/.env /opt/robot-market-front/.env.previous + echo "available=true" >> "$GITHUB_OUTPUT" + fi - - name: Point compose at this build - run: | - echo "IMAGE_TAG=${{ steps.vars.outputs.sha }}" > /opt/robot-market-front/.env + - name: Point compose at this build + run: | + echo "IMAGE_TAG=${{ steps.vars.outputs.sha }}" > /opt/robot-market-front/.env - - name: Deploy via compose - id: deploy - run: | - docker compose --env-file /opt/robot-market-front/.env \ - -f /opt/robot-market-front/docker-compose.yml \ - up -d --force-recreate + - name: Deploy via compose + id: deploy + run: | + docker compose --env-file /opt/robot-market-front/.env \ + -f /opt/robot-market-front/docker-compose.yml \ + up -d --force-recreate - - name: Health check (retries for ~30s) - id: health - run: | - for i in $(seq 1 15); do - if docker exec robot-market node -e " - require('http').get('http://localhost:3000', res => { - process.exit(res.statusCode < 400 ? 0 : 1); - }).on('error', () => process.exit(1)); - " 2>/dev/null; then - echo "Container is healthy" - exit 0 - fi - echo "Not ready yet, retrying..." - sleep 2 - done - echo "Health check failed after 30s" - exit 1 + - name: Health check (retries for ~30s) + id: health + run: | + for i in $(seq 1 15); do + if docker exec robot-market node -e " + require('http').get('http://localhost:3000', res => { + process.exit(res.statusCode < 400 ? 0 : 1); + }).on('error', () => process.exit(1)); + " 2>/dev/null; then + echo "Container is healthy" + exit 0 + fi + echo "Not ready yet, retrying..." + sleep 2 + done + echo "Health check failed after 30s" + exit 1 - - name: Roll back after deployment or health check failure - if: ${{ failure() && steps.backup.outputs.available == 'true' && (steps.deploy.outcome == 'failure' || steps.health.outcome == 'failure') }} - run: | - if [ -f /opt/robot-market-front/.env.previous ]; then - cp /opt/robot-market-front/.env.previous /opt/robot-market-front/.env - docker compose --env-file /opt/robot-market-front/.env \ - -f /opt/robot-market-front/docker-compose.yml \ - up -d --force-recreate - echo "Rolled back to previous image." - else - echo "No previous deploy recorded — nothing to roll back to." - fi + - name: Roll back after deployment or health check failure + if: ${{ failure() && steps.backup.outputs.available == 'true' && (steps.deploy.outcome == 'failure' || steps.health.outcome == 'failure') }} + run: | + if [ -f /opt/robot-market-front/.env.previous ]; then + cp /opt/robot-market-front/.env.previous /opt/robot-market-front/.env + docker compose --env-file /opt/robot-market-front/.env \ + -f /opt/robot-market-front/docker-compose.yml \ + up -d --force-recreate + echo "Rolled back to previous image." + else + echo "No previous deploy recorded — nothing to roll back to." + fi - - name: Clean up dangling (untagged) layers - run: docker image prune -f + - name: Clean up dangling (untagged) layers + run: docker image prune -f - - name: Prune old SHA-tagged images (keep last 5) - run: | - KEEP=5 - CURRENT_TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env 2>/dev/null | cut -d= -f2) - PREVIOUS_TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env.previous 2>/dev/null | cut -d= -f2) + - name: Prune old SHA-tagged images (keep last 5) + run: | + KEEP=5 + CURRENT_TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env 2>/dev/null | cut -d= -f2) + PREVIOUS_TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env.previous 2>/dev/null | cut -d= -f2) - docker images robot-market --format '{{.Tag}} {{.CreatedAt}}' \ - | sort -t" " -k2 -r \ - | tail -n +$((KEEP + 1)) \ - | cut -f1 \ - | while read -r tag; do - if [ "$tag" != "$CURRENT_TAG" ] && [ "$tag" != "$PREVIOUS_TAG" ] && [ "$tag" != "" ]; then - echo "Removing old image robot-market:$tag" - docker rmi "robot-market:$tag" 2>/dev/null || true - fi - done + docker images robot-market --format '{{.Tag}} {{.CreatedAt}}' \ + | sort -t" " -k2 -r \ + | tail -n +$((KEEP + 1)) \ + | cut -f1 \ + | while read -r tag; do + if [ "$tag" != "$CURRENT_TAG" ] && [ "$tag" != "$PREVIOUS_TAG" ] && [ "$tag" != "" ]; then + echo "Removing old image robot-market:$tag" + docker rmi "robot-market:$tag" 2>/dev/null || true + fi + done diff --git a/.gitea/workflows/rollback.yml b/.gitea/workflows/rollback.yml index cd72baa..6895551 100644 --- a/.gitea/workflows/rollback.yml +++ b/.gitea/workflows/rollback.yml @@ -4,34 +4,34 @@ name: Rollback (develop) # Leave "sha" empty to roll back to the previous deploy. # Fill "sha" in (short 7-char form, e.g. a3f9c21) to roll back to a specific past build. on: - workflow_dispatch: - inputs: - sha: - description: "Short commit SHA to roll back to (empty = previous deploy)" - required: false - default: "" + workflow_dispatch: + inputs: + sha: + description: 'Short commit SHA to roll back to (empty = previous deploy)' + required: false + default: '' jobs: - rollback: - runs-on: ubuntu-latest - steps: - - name: Determine target tag - run: | - if [ -n "${{ gitea.event.inputs.sha }}" ]; then - TAG="${{ gitea.event.inputs.sha }}" - else - TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env.previous | cut -d= -f2) - fi - echo "Rolling back to: $TAG" - echo "IMAGE_TAG=$TAG" > /opt/robot-market-front/.env + rollback: + runs-on: ubuntu-latest + steps: + - name: Determine target tag + run: | + if [ -n "${{ gitea.event.inputs.sha }}" ]; then + TAG="${{ gitea.event.inputs.sha }}" + else + TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env.previous | cut -d= -f2) + fi + echo "Rolling back to: $TAG" + echo "IMAGE_TAG=$TAG" > /opt/robot-market-front/.env - - name: Verify that image actually exists locally - run: | - TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env | cut -d= -f2) - docker image inspect robot-market:$TAG > /dev/null + - name: Verify that image actually exists locally + run: | + TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env | cut -d= -f2) + docker image inspect robot-market:$TAG > /dev/null - - name: Redeploy target image - run: | - docker compose --env-file /opt/robot-market-front/.env \ - -f /opt/robot-market-front/docker-compose.yml \ - up -d --force-recreate \ No newline at end of file + - name: Redeploy target image + run: | + docker compose --env-file /opt/robot-market-front/.env \ + -f /opt/robot-market-front/docker-compose.yml \ + up -d --force-recreate diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 25babe4..9e94409 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -1,34 +1,34 @@ name: Runner Test on: - push: - branches: [ main ] - workflow_dispatch: # lets you trigger it manually from the UI too + push: + branches: [main] + workflow_dispatch: # lets you trigger it manually from the UI too jobs: - hello: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + hello: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Print basic info - run: | - echo "✅ Runner is working!" - echo "Hostname: $(hostname)" - echo "Date: $(date)" - echo "User: $(whoami)" - pwd - ls -la + - name: Print basic info + run: | + echo "✅ Runner is working!" + echo "Hostname: $(hostname)" + echo "Date: $(date)" + echo "User: $(whoami)" + pwd + ls -la - - name: Test env variables - run: | - echo "Branch: ${{ github.ref_name }}" - echo "Commit SHA: ${{ github.sha }}" - echo "Actor: ${{ github.actor }}" + - name: Test env variables + run: | + echo "Branch: ${{ github.ref_name }}" + echo "Commit SHA: ${{ github.sha }}" + echo "Actor: ${{ github.actor }}" - - name: Simulate a build step - run: | - mkdir -p build - echo "Build artifact content" > build/output.txt - cat build/output.txt + - name: Simulate a build step + run: | + mkdir -p build + echo "Build artifact content" > build/output.txt + cat build/output.txt diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b4ad16e..37b3ae8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,38 +4,73 @@