feat: add authentication context, category management page, configuration, environment example, and CI/CD workflows
All checks were successful
Beta CI/CD Pipeline / build-and-test (push) Successful in 14s
Beta CI/CD Pipeline / deploy-beta (push) Successful in 20s

This commit is contained in:
vickytechkey 2026-10-03 16:54:18 +05:30
parent 66fe7c2d3d
commit 9eccac8b13
7 changed files with 69 additions and 27 deletions

1
.env.example Normal file
View file

@ -0,0 +1 @@
VITE_API_BASE_URL=https://betaapicsa.tradhox.com/api

View file

@ -8,9 +8,10 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
container: node:22
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: https://github.com/actions/checkout@v4
- name: Install dependencies
run: npm ci
@ -20,9 +21,11 @@ jobs:
- name: Build
run: npm run build
env:
VITE_API_BASE_URL: https://betaapicsa.tradhox.com/api
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
uses: https://github.com/actions/upload-artifact@v3
with:
name: dist
path: dist/
@ -30,17 +33,36 @@ jobs:
deploy-beta:
needs: build-and-test
runs-on: ubuntu-latest
container: node:22
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
uses: https://github.com/actions/download-artifact@v3
with:
name: dist
path: dist
- name: Deploy to Beta via FTP
env:
FTP_USERNAME: ${{ secrets.CRM_BETA_FTP_USERNAME }}
FTP_PASSWORD: ${{ secrets.CRM_BETA_FTP_PASSWORD }}
FTP_HOST: ${{ secrets.CRM_FTP_HOST }}
- name: Install AWS CLI
run: |
lftp -d -u "$FTP_USERNAME","$FTP_PASSWORD" -e "set ssl:verify-certificate no; set ftp:ssl-allow yes; set ftp:ssl-force true; set ftp:ssl-protect-data true; set ftp:passive-mode true; mirror -R dist/ ./; quit" $FTP_HOST
apt-get update && apt-get install -y awscli
- name: Deploy to AWS S3 (betacsa)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-south-2
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_BETA || 'betacsa' }}
run: |
aws s3 sync dist/ s3://$S3_BUCKET --delete
- name: Invalidate CloudFront Cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-south-2
DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_BETA }}
run: |
if [ -n "$DISTRIBUTION_ID" ]; then
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*"
else
echo "No CLOUDFRONT_DISTRIBUTION_ID_BETA specified, skipping invalidation."
fi

View file

@ -8,9 +8,10 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
container: node:22
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: https://github.com/actions/checkout@v4
- name: Install dependencies
run: npm ci
@ -20,9 +21,11 @@ jobs:
- name: Build
run: npm run build
env:
VITE_API_BASE_URL: https://apicsa.tradhox.com/api
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
uses: https://github.com/actions/upload-artifact@v3
with:
name: dist
path: dist/
@ -30,19 +33,38 @@ jobs:
deploy-prod:
needs: build-and-test
runs-on: ubuntu-latest
container: node:22
environment:
name: production
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
uses: https://github.com/actions/download-artifact@v3
with:
name: dist
path: dist
- name: Deploy to Production via FTP
env:
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
FTP_HOST: ${{ secrets.FTP_HOST }}
- name: Install AWS CLI
run: |
lftp -d -u "$FTP_USERNAME","$FTP_PASSWORD" -e "set ssl:verify-certificate no; set ftp:ssl-allow yes; set ftp:ssl-force true; set ftp:ssl-protect-data true; set ftp:passive-mode true; mirror -R dist/ ./; quit" $FTP_HOST
apt-get update && apt-get install -y awscli
- name: Deploy to AWS S3 (csawebsite)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-south-2
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_PROD || 'csawebsite' }}
run: |
aws s3 sync dist/ s3://$S3_BUCKET --delete
- name: Invalidate CloudFront Cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-south-2
DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }}
run: |
if [ -n "$DISTRIBUTION_ID" ]; then
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*"
else
echo "No CLOUDFRONT_DISTRIBUTION_ID_PROD specified, skipping invalidation."
fi

View file

@ -1,17 +1,14 @@
import React, { useState } from 'react';
import StatusBadge from './StatusBadge';
import { API_BASE_URL } from '../config';
import { useAuth } from '../context/AuthContext';
const DocumentViewer = ({ documents, sellerId }) => {
const { token } = useAuth();
const DocumentViewer = ({ documents }) => {
const [previewDoc, setPreviewDoc] = useState(null);
const resolveUrl = (url) => {
if (!url) return '';
if (url.startsWith('/') || url.startsWith('//')) {
// Use window.location.origin to match the secure public domain (e.g. crm.tipro.in)
return `${window.location.origin}/crm/api/crm${url}`;
if (url.startsWith('/')) {
return `${API_BASE_URL}${url}`;
}
return url;
};

View file

@ -1,2 +1,3 @@
// DigiHox CRM - Frontend Configuration
export const API_BASE_URL = "https://ec2-16-113-57-127.ap-south-2.compute.amazonaws.com/crm/api/crm";
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "https://betaapicsa.tradhox.com/api";

View file

@ -36,7 +36,7 @@ export const AuthProvider = ({ children }) => {
} else {
logout();
}
} catch (err) {
} catch (_err) {
// Fallback to local user session if server is offline
setUser({
username: localStorage.getItem('crm_username') || 'vignesh',

View file

@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
import { API_BASE_URL } from '../../config';
import { useAuth } from '../../context/AuthContext';
import StatusBadge from '../../components/StatusBadge';
const CategoryList = () => {
const { token } = useAuth();