diff --git a/.env.sample b/.env.sample index 76c7afc8e..5f751562f 100644 --- a/.env.sample +++ b/.env.sample @@ -40,7 +40,7 @@ binance_mainnet_rpc=https://bsc-dataseed.binance.org/ astar_mainnet_rpc=https://astar-mainnet.g.alchemy.com/v2/9KZaDwMUro6LImKeM717TmysfBSi3iNH base_mainnet_rpc=https://base-mainnet.g.alchemy.com/v2/LPVexfumI81FHrSqJyhwpZ9ybdXXx4SM #default image for NFTs that have no metadata -default_product_cover=https://rair.mypinata.cloud/ipfs/QmNtfjBAPYEFxXiHmY5kcPh9huzkwquHBcn9ZJHGe7hfaW +default_product_cover=https://rair.myfilebase.com/ipfs/QmcV94NurwfWVGpXTST1we8uDbYiVQamKe87WEHK6DRzqa #ipfs configuration - pinata or ipfs ipfs_service=pinata ipfs_gateway=http://rairipfs:8080/ipfs @@ -148,6 +148,9 @@ VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_ID="" VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_SECRET_ID="" VAULT_BLOCKCHAIN_NETWORK_use_x509_cert_auth=true +#rair-front +front_socket_uri=:5000 + # media-service media_service_port=5002 base_rairnode_url=http://rair-node:5000 diff --git a/.github/workflows/HotDrops.yml b/.github/workflows/HotDrops.yml new file mode 100644 index 000000000..a4867261d --- /dev/null +++ b/.github/workflows/HotDrops.yml @@ -0,0 +1,52 @@ +name: Build and Push rair-front Docker Image to Docker Hub + +on: + workflow_dispatch: + +#Allow repo secrets +env: + VITE_ALCHEMY_KEY: ${{ secrets.VITE_ALCHEMY_KEY }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v4 + with: + ref: 'dev' + + - name: login to docker registry + uses: docker/login-action@v3 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + + - name: build and push rair-front docker image to registry + run: cp rair-front/.env.sample rair-front/.env + - name: appending VITE_MATIC_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_MATIC_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_MATIC_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_MATIC_MAINNET_GAS_POLICY in .env file + run: echo "VITE_MATIC_MAINNET_GAS_POLICY"=${{ secrets.VITE_MATIC_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_ETH_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_ETH_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_ETH_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_ETH_MAINNET_GAS_POLICY in .env file + run: echo "VITE_ETH_MAINNET_GAS_POLICY"=${{ secrets.VITE_ETH_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_BASE_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_BASE_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_BASE_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_BASE_MAINNET_GAS_POLICY in .env file + run: echo "VITE_BASE_MAINNET_GAS_POLICY"=${{ secrets.VITE_BASE_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_ETH_SEPOLIA_ALCHEMY_KEY in .env file + run: echo "VITE_ETH_SEPOLIA_ALCHEMY_KEY"=${{ secrets.VITE_ETH_SEPOLIA_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_ETH_SEPOLIA_GAS_POLICY in .env file + run: echo "VITE_ETH_SEPOLIA_GAS_POLICY"=${{ secrets.VITE_ETH_SEPOLIA_GAS_POLICY }} >> rair-front/.env + - name: build rair-front docker image + run: sudo docker build -t rair-front:${{github.sha}} -f rair-front/Dockerfile.prod rair-front + - name: tag image + run: | + docker tag rair-front:${{github.sha}} ${{secrets.DOCKERHUB_USERNAME}}/rair-front:_${{github.sha}} + docker tag rair-front:${{github.sha}} ${{secrets.DOCKERHUB_USERNAME}}/rair-front:_latest + - name: Docker push + run: | + docker push ${{secrets.DOCKERHUB_USERNAME}}/rair-front:_${{github.sha}} + docker push ${{secrets.DOCKERHUB_USERNAME}}/rair-front:_latest diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 65fc9ebb4..346ce7530 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,8 +38,22 @@ jobs: - name: build and push rair-front docker image to registry run: cp rair-front/.env.sample rair-front/.env - - name: appending VITE_ALCHEMY_KEY in .env file - run: echo "VITE_ALCHEMY_KEY"=${{ secrets.VITE_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_MATIC_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_MATIC_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_MATIC_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_MATIC_MAINNET_GAS_POLICY in .env file + run: echo "VITE_MATIC_MAINNET_GAS_POLICY"=${{ secrets.VITE_MATIC_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_ETH_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_ETH_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_ETH_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_ETH_MAINNET_GAS_POLICY in .env file + run: echo "VITE_ETH_MAINNET_GAS_POLICY"=${{ secrets.VITE_ETH_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_BASE_MAINNET_ALCHEMY_KEY in .env file + run: echo "VITE_BASE_MAINNET_ALCHEMY_KEY"=${{ secrets.VITE_BASE_MAINNET_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_BASE_MAINNET_GAS_POLICY in .env file + run: echo "VITE_BASE_MAINNET_GAS_POLICY"=${{ secrets.VITE_BASE_MAINNET_GAS_POLICY }} >> rair-front/.env + - name: appending VITE_ETH_SEPOLIA_ALCHEMY_KEY in .env file + run: echo "VITE_ETH_SEPOLIA_ALCHEMY_KEY"=${{ secrets.VITE_ETH_SEPOLIA_ALCHEMY_KEY }} >> rair-front/.env + - name: appending VITE_ETH_SEPOLIA_GAS_POLICY in .env file + run: echo "VITE_ETH_SEPOLIA_GAS_POLICY"=${{ secrets.VITE_ETH_SEPOLIA_GAS_POLICY }} >> rair-front/.env - name: build rair-front docker image run: sudo docker build -t rair-front:${{github.sha}} -f rair-front/Dockerfile.prod rair-front - name: tag image diff --git a/docker-compose-web.yml b/docker-compose-web.yml index 4e5c10737..cead2db25 100644 --- a/docker-compose-web.yml +++ b/docker-compose-web.yml @@ -201,6 +201,7 @@ services: VITE_HOME_PAGE: / VITE_MATIC_MAIN_DIAMOND_FACTORY: ${matic_mainnet_diamond_factory_address} VITE_MATIC_MAIN_DIAMOND_MARKETPLACE: ${matic_mainnet_diamond_marketplace_address} + VITE_NODE_SOCKET_URI: ${base_rairnode_url} ports: - 8088:80 networks: diff --git a/docker-compose.local-new.yml b/docker-compose.local-new.yml index 2a1f28e31..7ff694d2e 100644 --- a/docker-compose.local-new.yml +++ b/docker-compose.local-new.yml @@ -209,6 +209,7 @@ services: VITE_HOME_PAGE: / VITE_MATIC_MAIN_DIAMOND_FACTORY: ${matic_mainnet_diamond_factory_address} VITE_MATIC_MAIN_DIAMOND_MARKETPLACE: ${matic_mainnet_diamond_marketplace_address} + VITE_NODE_SOCKET_URI: ${front_socket_uri} ports: - 8088:80 networks: diff --git a/docker-compose.local-ssl-with_certbot.yml b/docker-compose.local-ssl-with_certbot.yml new file mode 100644 index 000000000..7b158bc24 --- /dev/null +++ b/docker-compose.local-ssl-with_certbot.yml @@ -0,0 +1,250 @@ +version: '3.9' + +services: + certbot: + image: certbot/certbot + container_name: certbot + volumes: + - ./data/certbot/conf:/etc/letsencrypt + - ./data/certbot/www:/var/www/certbot + command: certonly --webroot -w /var/www/certbot --force-renewal --email {email} -d {domain} --agree-tos + networks: + - rair-local + rair-node: + container_name: 'rair-node' + build: + context: rair-node/ + dockerfile: Dockerfile + volumes: + - ./rair-node/db:/usr/src/rair-node/db + - ./rair-node/bin/Videos:/usr/src/rair-node/bin/Videos + environment: + PRODUCTION: "false" + MONGO_URI: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + MONGO_URI_LOCAL: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + GENERATE_MONGO_URI_WITH_VAULT_CREDENTIAL_UTIL: ${rairnode_generate_mongo_uri_with_vault_credential_util} + USE_X509_CERT_AUTH: ${VAULT_RAIRNODE_use_x509_cert_auth} + MONGO_DB_HOSTNAME: ${RAIRNODE_mongo_db_hostname} + MONGO_DB_NAME: ${mongo_db_name} + JWT_SECRET: ${jwt_secret} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + ADMIN_NETWORK: ${admin_nft_chain} + ADMIN_CONTRACT: ${admin_contract} + SUPER_ADMIN_VAULT_STORE: ${SUPER_ADMIN_VAULT_STORE} + SERVICE_HOST: ${hostname} + DEFAULT_PRODUCT_COVER: ${default_product_cover} + GCP_PROJECT_ID: ${gcp_project_id} + GCP_IMAGE_BUCKET_NAME: ${gcp_image_bucket_name} + GCP_VIDEO_BUCKET_NAME: ${gcp_video_bucket_name} + GCP_GATEWAY: ${gcp_gateway} + GCP_CREDENTIALS: ${gcp_credentials} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + PINATA_GATEWAY: ${pinata_gateway} + MATIC_TESTNET_RPC: ${matic_testnet_rpc} + MATIC_MAINNET_RPC: ${matic_mainnet_rpc} + BINANCE_MAINNET_RPC: ${binance_mainnet_rpc} + BINANCE_TESTNET_RPC: ${binance_testnet_rpc} + ETHEREUM_MAINNET_RPC: ${ethereum_mainnet_rpc} + ETHEREUM_TESTNET_SEPOLIA_RPC: ${ethereum_testnet_sepolia_rpc} + BASE_MAINNET_RPC: ${base_mainnet_rpc} + ASTAR_MAINNET_RPC: ${astar_mainnet_rpc} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_RAIRNODE_APP_ROLE_ID: ${VAULT_RAIRNODE_APP_ROLE_ID} + VAULT_RAIRNODE_APP_ROLE_SECRET_ID: ${VAULT_RAIRNODE_APP_ROLE_SECRET_ID} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + SESSION_SECRET: ${session_secret} + SESSION_TTL: ${session_ttl} + SENTRY_DSN: ${sentry_dsn} + BASE_BCN_URL: ${base_bcn_url} + ZOOM_API_KEY: ${zoom_api_key} + ZOOM_API_SECRET: ${zoom_api_secret} + KOHLER_MEETING_ID: ${kohler_meeting_id} + ALCHEMY_API_KEY: ${alchemy_api_key} + WITHDRAWER_PRIVATE_KEY: ${withdrawer_private_key} + APP_NAME: ${app_name} + SEPOLIA_DIAMOND_MARKETPLACE_ADDRESS: ${sepolia_diamond_marketplace_address} + MATIC_MUMBAI_DIAMOND_MARKETPLACE_ADDRESS: ${matic_mumbai_diamond_marketplace_address} + MATIC_MAINNET_DIAMOND_MARKETPLACE_ADDRESS: ${matic_mainnet_diamond_marketplace_address} + ASTAR_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + BASE_DIAMOND_MARKETPLACE_ADDRESS: ${base_diamond_marketplace_address} + AWS_ACCESS_KEY_ID: ${filebase_access_key} + AWS_SECRET_ACCESS_KEY: ${filebase_secret_access_key} + FILEBASE_BUCKET: ${filebase_bucket} + YOTI_CLIENT_ID: ${yoti_client_id} + ports: + - 3000:3000 + - 5000:5000 + depends_on: + - rair-redis + - mongo + networks: + - rair-local + rair-sync: + container_name: 'rair-sync' + build: + context: rair-sync/ + dockerfile: Dockerfile + environment: + PRODUCTION: "false" + MONGO_URI: mongodb+srv://${dbuser}:${dbpass}@${dbhost} + MONGO_URI_LOCAL: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + MONGO_DB_HOSTNAME: ${BLOCKCHAIN_NETWORK_mongo_db_hostname} + MONGO_DB_NAME: ${mongo_db_name} + GENERATE_MONGO_URI_WITH_VAULT_CREDENTIAL_UTIL: ${blockchain_network_generate_mongo_uri_with_vault_credential_util} + USE_X509_CERT_AUTH: ${VAULT_BLOCKCHAIN_NETWORK_use_x509_cert_auth} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + PINATA_GATEWAY: ${pinata_gateway} + INFURA_PROJECT_ID: ${infura_project_id} + DEFAULT_PRODUCT_COVER: ${default_product_cover} + BINANCE_TESTNET_FACTORY_ADDRESS: ${binance_testnet_factory_addres} + BINANCE_TESTNET_MINTER_ADDRESS: ${binance_testnet_minter_address} + BINANCE_MAINNET_FACTORY_ADDRESS: ${binance_mainnet_factory_addres} + BINANCE_MAINNET_MINTER_ADDRESS: ${binance_mainnet_minter_address} + SEPOLIA_FACTORY_ADDRESS: ${sepolia_factory_addres} + SEPOLIA_MINTER_ADDRESS: ${sepolia_minter_address} + MATIC_MUMBAI_FACTORY_ADDRESS: ${matic_mumbai_factory_addres} + MATIC_MUMBAI_MINTER_ADDRESS: ${matic_mumbai_minter_address} + MATIC_MAINNET_FACTORY_ADDRESS: ${matic_mainnet_factory_addres} + MATIC_MAINNET_MINTER_ADDRESS: ${matic_mainnet_minter_address} + ETHEREUM_MAINNET_FACTORY_ADDRESS: ${ethereum_mainnet_factory_addres} + ETHEREUM_MAINNET_MINTER_ADDRESS: ${ethereum_mainnet_minter_address} + BINANCE_RESALE_ADDRESS: ${binance_resale_address} + SEPOLIA_RESALE_ADDRESS: ${sepolia_resale_address} + MATIC_MUMBAI_RESALE_ADDRESS: ${matic_mumbai_resale_address} + ASTAR_DIAMOND_FACTORY_ADDRESS: ${astar_diamond_factory_address} + ASTAR_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + BASE_DIAMOND_FACTORY_ADDRESS: ${base_diamond_factory_address} + BASE_DIAMOND_MARKETPLACE_ADDRESS: ${base_diamond_marketplace_address} + SYNC_CONTRACT_REPEAT_EVERY: ${sync_contract_repeat_every} + SYNC_CONTRACT_TASK_INTERVAL: ${sync_contract_task_interval} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_ID: ${VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_ID} + VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_SECRET_ID: ${VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_SECRET_ID} + TEST_BSCSCAN_GATEWAY: ${test_bscscan_gateway} + TEST_POLYGONSCAN_GATEWAY: ${test_polygonscan_gateway} + TEST_ETHERSCAN_GATEWAY: ${test_etherscan_gateway} + POLYGONSCAN_GATEWAY: ${polygonscan_gateway} + ETHERSCAN_GATEWAY: ${etherscan_gateway} + BSCSCAN_GATEWAY: ${bscscan_gateway} + ASTAR_MAINNET_GATEWAY: ${astar_gateway} + ASTAR_MAINNET_DIAMOND_FACTORY_ADDRESS: ${astar_diamond_factory_address} + ASTAR_MAINNET_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + SENTRY_DSN: ${sentry_dsn} + BASE_RAIRNODE_URL: ${base_rairnode_url} + MATIC_TESTNET_RPC: ${matic_testnet_rpc} + MATIC_MAINNET_RPC: ${matic_mainnet_rpc} + BINANCE_MAINNET_RPC: ${binance_mainnet_rpc} + BINANCE_TESTNET_RPC: ${binance_testnet_rpc} + ETHEREUM_MAINNET_RPC: ${ethereum_mainnet_rpc} + ETHEREUM_TESTNET_SEPOLIA_RPC: ${ethereum_testnet_sepolia_rpc} + ASTAR_MAINNET_RPC: ${astar_mainnet_rpc} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + ALCHEMY_API_KEY: ${alchemy_api_key} + ports: + - 5001:5001 + depends_on: + - rair-node + - mongo + networks: + - rair-local + rair-stream: + container_name: 'rair-stream' + build: + context: rair-stream/ + dockerfile: Dockerfile + environment: + PRODUCTION: "false" + MEDIA_SERVICE_PORT: ${media_service_port} + BASE_RAIRNODE_URL: ${base_rairnode_url} + GCP_PROJECT_ID: ${gcp_project_id} + GCP_IMAGE_BUCKET_NAME: ${gcp_image_bucket_name} + GCP_VIDEO_BUCKET_NAME: ${gcp_video_bucket_name} + GCP_CREDENTIALS: ${gcp_credentials} + GCP_GATEWAY: ${gcp_gateway} + USE_X509_CERT_AUTH: ${VAULT_MEDIA_SERVICE_use_x509_cert_auth} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + PINATA_GATEWAY: ${pinata_gateway} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_MEDIA_SERVICE_APP_ROLE_ID: ${VAULT_MEDIA_SERVICE_APP_ROLE_ID} + VAULT_MEDIA_SERVICE_APP_ROLE_SECRET_ID: ${VAULT_MEDIA_SERVICE_APP_ROLE_SECRET_ID} + SENTRY_DSN: ${sentry_dsn} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + ports: + - 5002:5002 + networks: + - rair-local + rair-redis: + container_name: "rair-redis" + image: redis + command: redis-server --appendonly yes + restart: always + ports: + - 6379:6379 + networks: + - rair-local + rair-front: + container_name: rair-front + build: + context: rair-front + dockerfile: Dockerfile.prod + environment: + VITE_SENTRY_ENABLED: ${sentry_enabled} + VITE_SENTRY_IO_ENDPOINT: ${sentry_endpoint} + VITE_SENTRY_IO_TRACE_RATE: ${sentry_trace_rate} + VITE_SENTRY_RELEASE: ${sentry_release} + VITE_GOOGLE_ANALYTICS: ${react-app-google-analytics} + VITE_GA_NAME: ${react-app-ga-name} + VITE_DISABLE_CREATOR_VIEWS: ${react-app-disable-creator-views} + VITE_HOME_PAGE: / + VITE_MATIC_MAIN_DIAMOND_FACTORY: ${matic_mainnet_diamond_factory_address} + VITE_MATIC_MAIN_DIAMOND_MARKETPLACE: ${matic_mainnet_diamond_marketplace_address} + VITE_NODE_SOCKET_URI: ${front_socket_uri} + volumes: + - ./rair-front/nginx/nginx.conf:/etc/nginx/nginx.conf + - ./data/certbot/conf:/etc/letsencrypt + - ./data/certbot/www:/var/www/certbot + ports: + - 80:80 + - 443:443 + networks: + - rair-local + depends_on: + - rair-node + mongo: + container_name: mongo + image: mongo + restart: always + volumes: + - ./rair-node/dev/db-data:/data/db + - ./rair-node/dev/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro + environment: + MONGO_INITDB_ROOT_USERNAME: ${localdbuser} + MONGO_INITDB_ROOT_PASSWORD: ${localdbpass} + MONGO_INITDB_DATABASE: rair-db + ports: + - 27017:27017 + networks: + - rair-local +networks: + rair-local: + driver: bridge diff --git a/docker-compose.local-ssl-without_certbot.yml b/docker-compose.local-ssl-without_certbot.yml new file mode 100644 index 000000000..b0c651c38 --- /dev/null +++ b/docker-compose.local-ssl-without_certbot.yml @@ -0,0 +1,241 @@ +version: '3.9' + +services: + rair-node: + container_name: 'rair-node' + build: + context: rair-node/ + dockerfile: Dockerfile + volumes: + - ./rair-node/db:/usr/src/rair-node/db + - ./rair-node/bin/Videos:/usr/src/rair-node/bin/Videos + environment: + PRODUCTION: "false" + MONGO_URI: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + MONGO_URI_LOCAL: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + GENERATE_MONGO_URI_WITH_VAULT_CREDENTIAL_UTIL: ${rairnode_generate_mongo_uri_with_vault_credential_util} + USE_X509_CERT_AUTH: ${VAULT_RAIRNODE_use_x509_cert_auth} + MONGO_DB_HOSTNAME: ${RAIRNODE_mongo_db_hostname} + MONGO_DB_NAME: ${mongo_db_name} + JWT_SECRET: ${jwt_secret} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + ADMIN_NETWORK: ${admin_nft_chain} + ADMIN_CONTRACT: ${admin_contract} + SUPER_ADMIN_VAULT_STORE: ${SUPER_ADMIN_VAULT_STORE} + SERVICE_HOST: ${hostname} + DEFAULT_PRODUCT_COVER: ${default_product_cover} + GCP_PROJECT_ID: ${gcp_project_id} + GCP_IMAGE_BUCKET_NAME: ${gcp_image_bucket_name} + GCP_VIDEO_BUCKET_NAME: ${gcp_video_bucket_name} + GCP_GATEWAY: ${gcp_gateway} + GCP_CREDENTIALS: ${gcp_credentials} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + PINATA_GATEWAY: ${pinata_gateway} + MATIC_TESTNET_RPC: ${matic_testnet_rpc} + MATIC_MAINNET_RPC: ${matic_mainnet_rpc} + BINANCE_MAINNET_RPC: ${binance_mainnet_rpc} + BINANCE_TESTNET_RPC: ${binance_testnet_rpc} + ETHEREUM_MAINNET_RPC: ${ethereum_mainnet_rpc} + ETHEREUM_TESTNET_SEPOLIA_RPC: ${ethereum_testnet_sepolia_rpc} + BASE_MAINNET_RPC: ${base_mainnet_rpc} + ASTAR_MAINNET_RPC: ${astar_mainnet_rpc} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_RAIRNODE_APP_ROLE_ID: ${VAULT_RAIRNODE_APP_ROLE_ID} + VAULT_RAIRNODE_APP_ROLE_SECRET_ID: ${VAULT_RAIRNODE_APP_ROLE_SECRET_ID} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + SESSION_SECRET: ${session_secret} + SESSION_TTL: ${session_ttl} + SENTRY_DSN: ${sentry_dsn} + BASE_BCN_URL: ${base_bcn_url} + ZOOM_API_KEY: ${zoom_api_key} + ZOOM_API_SECRET: ${zoom_api_secret} + KOHLER_MEETING_ID: ${kohler_meeting_id} + ALCHEMY_API_KEY: ${alchemy_api_key} + WITHDRAWER_PRIVATE_KEY: ${withdrawer_private_key} + APP_NAME: ${app_name} + SEPOLIA_DIAMOND_MARKETPLACE_ADDRESS: ${sepolia_diamond_marketplace_address} + MATIC_MUMBAI_DIAMOND_MARKETPLACE_ADDRESS: ${matic_mumbai_diamond_marketplace_address} + MATIC_MAINNET_DIAMOND_MARKETPLACE_ADDRESS: ${matic_mainnet_diamond_marketplace_address} + ASTAR_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + BASE_DIAMOND_MARKETPLACE_ADDRESS: ${base_diamond_marketplace_address} + AWS_ACCESS_KEY_ID: ${filebase_access_key} + AWS_SECRET_ACCESS_KEY: ${filebase_secret_access_key} + FILEBASE_BUCKET: ${filebase_bucket} + YOTI_CLIENT_ID: ${yoti_client_id} + ports: + - 3000:3000 + - 5000:5000 + depends_on: + - rair-redis + - mongo + networks: + - rair-local + rair-sync: + container_name: 'rair-sync' + build: + context: rair-sync/ + dockerfile: Dockerfile + environment: + PRODUCTION: "false" + MONGO_URI: mongodb+srv://${dbuser}:${dbpass}@${dbhost} + MONGO_URI_LOCAL: mongodb://${localdbuser}:${localdbpass}@mongo:27017/rair-db?authSource=${localdbuser} + MONGO_DB_HOSTNAME: ${BLOCKCHAIN_NETWORK_mongo_db_hostname} + MONGO_DB_NAME: ${mongo_db_name} + GENERATE_MONGO_URI_WITH_VAULT_CREDENTIAL_UTIL: ${blockchain_network_generate_mongo_uri_with_vault_credential_util} + USE_X509_CERT_AUTH: ${VAULT_BLOCKCHAIN_NETWORK_use_x509_cert_auth} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + PINATA_GATEWAY: ${pinata_gateway} + INFURA_PROJECT_ID: ${infura_project_id} + DEFAULT_PRODUCT_COVER: ${default_product_cover} + BINANCE_TESTNET_FACTORY_ADDRESS: ${binance_testnet_factory_addres} + BINANCE_TESTNET_MINTER_ADDRESS: ${binance_testnet_minter_address} + BINANCE_MAINNET_FACTORY_ADDRESS: ${binance_mainnet_factory_addres} + BINANCE_MAINNET_MINTER_ADDRESS: ${binance_mainnet_minter_address} + SEPOLIA_FACTORY_ADDRESS: ${sepolia_factory_addres} + SEPOLIA_MINTER_ADDRESS: ${sepolia_minter_address} + MATIC_MUMBAI_FACTORY_ADDRESS: ${matic_mumbai_factory_addres} + MATIC_MUMBAI_MINTER_ADDRESS: ${matic_mumbai_minter_address} + MATIC_MAINNET_FACTORY_ADDRESS: ${matic_mainnet_factory_addres} + MATIC_MAINNET_MINTER_ADDRESS: ${matic_mainnet_minter_address} + ETHEREUM_MAINNET_FACTORY_ADDRESS: ${ethereum_mainnet_factory_addres} + ETHEREUM_MAINNET_MINTER_ADDRESS: ${ethereum_mainnet_minter_address} + BINANCE_RESALE_ADDRESS: ${binance_resale_address} + SEPOLIA_RESALE_ADDRESS: ${sepolia_resale_address} + MATIC_MUMBAI_RESALE_ADDRESS: ${matic_mumbai_resale_address} + ASTAR_DIAMOND_FACTORY_ADDRESS: ${astar_diamond_factory_address} + ASTAR_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + BASE_DIAMOND_FACTORY_ADDRESS: ${base_diamond_factory_address} + BASE_DIAMOND_MARKETPLACE_ADDRESS: ${base_diamond_marketplace_address} + SYNC_CONTRACT_REPEAT_EVERY: ${sync_contract_repeat_every} + SYNC_CONTRACT_TASK_INTERVAL: ${sync_contract_task_interval} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_ID: ${VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_ID} + VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_SECRET_ID: ${VAULT_BLOCKCHAIN_NETWORK_APP_ROLE_SECRET_ID} + TEST_BSCSCAN_GATEWAY: ${test_bscscan_gateway} + TEST_POLYGONSCAN_GATEWAY: ${test_polygonscan_gateway} + TEST_ETHERSCAN_GATEWAY: ${test_etherscan_gateway} + POLYGONSCAN_GATEWAY: ${polygonscan_gateway} + ETHERSCAN_GATEWAY: ${etherscan_gateway} + BSCSCAN_GATEWAY: ${bscscan_gateway} + ASTAR_MAINNET_GATEWAY: ${astar_gateway} + ASTAR_MAINNET_DIAMOND_FACTORY_ADDRESS: ${astar_diamond_factory_address} + ASTAR_MAINNET_DIAMOND_MARKETPLACE_ADDRESS: ${astar_diamond_marketplace_address} + SENTRY_DSN: ${sentry_dsn} + BASE_RAIRNODE_URL: ${base_rairnode_url} + MATIC_TESTNET_RPC: ${matic_testnet_rpc} + MATIC_MAINNET_RPC: ${matic_mainnet_rpc} + BINANCE_MAINNET_RPC: ${binance_mainnet_rpc} + BINANCE_TESTNET_RPC: ${binance_testnet_rpc} + ETHEREUM_MAINNET_RPC: ${ethereum_mainnet_rpc} + ETHEREUM_TESTNET_SEPOLIA_RPC: ${ethereum_testnet_sepolia_rpc} + ASTAR_MAINNET_RPC: ${astar_mainnet_rpc} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + ALCHEMY_API_KEY: ${alchemy_api_key} + ports: + - 5001:5001 + depends_on: + - rair-node + - mongo + networks: + - rair-local + rair-stream: + container_name: 'rair-stream' + build: + context: rair-stream/ + dockerfile: Dockerfile + environment: + PRODUCTION: "false" + MEDIA_SERVICE_PORT: ${media_service_port} + BASE_RAIRNODE_URL: ${base_rairnode_url} + GCP_PROJECT_ID: ${gcp_project_id} + GCP_IMAGE_BUCKET_NAME: ${gcp_image_bucket_name} + GCP_VIDEO_BUCKET_NAME: ${gcp_video_bucket_name} + GCP_CREDENTIALS: ${gcp_credentials} + GCP_GATEWAY: ${gcp_gateway} + USE_X509_CERT_AUTH: ${VAULT_MEDIA_SERVICE_use_x509_cert_auth} + PINATA_KEY: ${pinata_key} + PINATA_SECRET: ${pinata_secret} + PINATA_GATEWAY: ${pinata_gateway} + IPFS_SERVICE: ${ipfs_service} + IPFS_GATEWAY: ${ipfs_gateway} + IPFS_API: ${ipfs_api} + MONGO_LOG_COLLECTION: ${mongo_log_collection} + LOG_LEVEL: ${log_level} + VAULT_URL: ${VAULT_URL} + VAULT_MEDIA_SERVICE_APP_ROLE_ID: ${VAULT_MEDIA_SERVICE_APP_ROLE_ID} + VAULT_MEDIA_SERVICE_APP_ROLE_SECRET_ID: ${VAULT_MEDIA_SERVICE_APP_ROLE_SECRET_ID} + SENTRY_DSN: ${sentry_dsn} + REDIS_HOST: ${redisthhost} + REDIS_PORT: ${redisport} + ports: + - 5002:5002 + networks: + - rair-local + rair-redis: + container_name: "rair-redis" + image: redis + command: redis-server --appendonly yes + restart: always + ports: + - 6379:6379 + networks: + - rair-local + rair-front: + container_name: rair-front + build: + context: rair-front + dockerfile: Dockerfile.prod + environment: + VITE_SENTRY_ENABLED: ${sentry_enabled} + VITE_SENTRY_IO_ENDPOINT: ${sentry_endpoint} + VITE_SENTRY_IO_TRACE_RATE: ${sentry_trace_rate} + VITE_SENTRY_RELEASE: ${sentry_release} + VITE_GOOGLE_ANALYTICS: ${react-app-google-analytics} + VITE_GA_NAME: ${react-app-ga-name} + VITE_DISABLE_CREATOR_VIEWS: ${react-app-disable-creator-views} + VITE_HOME_PAGE: / + VITE_MATIC_MAIN_DIAMOND_FACTORY: ${matic_mainnet_diamond_factory_address} + VITE_MATIC_MAIN_DIAMOND_MARKETPLACE: ${matic_mainnet_diamond_marketplace_address} + VITE_NODE_SOCKET_URI: ${front_socket_uri} + volumes: + - ./rair-front/nginx/nginx.conf:/etc/nginx/nginx.conf + - ./data/certbot/conf:/etc/letsencrypt + - ./data/certbot/www:/var/www/certbot + ports: + - 80:80 + - 443:443 + networks: + - rair-local + depends_on: + - rair-node + mongo: + container_name: mongo + image: mongo + restart: always + volumes: + - ./rair-node/dev/db-data:/data/db + - ./rair-node/dev/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro + environment: + MONGO_INITDB_ROOT_USERNAME: ${localdbuser} + MONGO_INITDB_ROOT_PASSWORD: ${localdbpass} + MONGO_INITDB_DATABASE: rair-db + ports: + - 27017:27017 + networks: + - rair-local +networks: + rair-local: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index 460842f53..c6c9f4c1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -210,6 +210,7 @@ services: VITE_HOME_PAGE: / VITE_MATIC_MAIN_DIAMOND_FACTORY: ${matic_mainnet_diamond_factory_address} VITE_MATIC_MAIN_DIAMOND_MARKETPLACE: ${matic_mainnet_diamond_marketplace_address} + VITE_NODE_SOCKET_URI: ${base_rairnode_url} ports: - 80:80 networks: diff --git a/rair-front/.dockerignore b/rair-front/.dockerignore index 600e365ec..b512c09d4 100644 --- a/rair-front/.dockerignore +++ b/rair-front/.dockerignore @@ -1 +1 @@ -**/node_modules \ No newline at end of file +node_modules \ No newline at end of file diff --git a/rair-front/.env.sample b/rair-front/.env.sample index 74fc6fb26..f64e33483 100644 --- a/rair-front/.env.sample +++ b/rair-front/.env.sample @@ -16,6 +16,8 @@ VITE_GA_NAME=t #upload_progress_host VITE_UPLOAD_PROGRESS_HOST=http://localhost:5000 +VITE_NODE_SOCKET_URI=:5000 + VITE_TESTNET=false VITE_HTML_META_TITLE=RAIR Collectible Marketplace @@ -25,5 +27,5 @@ VITE_HTML_META_AUTHOR=RAIR Collectible Marketplace VITE_HTML_META_DESCRIPTION=We help IP owners make their content collectible through private label marketplaces. Mint, stream, sell digital assets. VITE_IPFS_GATEWAY=http://rair.myfilebase.com/ipfs/ -VITE_DEFAULT_BLOCKCHAIN=0x89 +VITE_DEFAULT_BLOCKCHAIN=0x2105 VITE_WEB3AUTH_CLIENT_ID=BEfl04Slm6zUDrpxC-r5qgO6cjW2mlXc82z0rvTiNL-JdYTxYQHl7YzyNy4Ja4jq8fUDhysW1hwRDqLM6tYK3-4 diff --git a/rair-front/Dockerfile b/rair-front/Dockerfile index a898880ac..4423e3a1f 100644 --- a/rair-front/Dockerfile +++ b/rair-front/Dockerfile @@ -1,16 +1,12 @@ -FROM node:21.2.0 as build +FROM node:lts as build #install dependencies WORKDIR /usr/src/minting -COPY package*.json ./ -RUN npm install +COPY package.json ./ +RUN npm install --force COPY . /usr/src/minting -#RUN mkdir -p node_modules/.cache && chmod -R 777 node_modules/.cache - -FROM node:21.2.0 WORKDIR /usr/src/minting -COPY --from=build /usr/src/minting /usr/src/minting EXPOSE 3001 -CMD npm start \ No newline at end of file +CMD npm start \ No newline at end of file diff --git a/rair-front/nginx-prod/nginx.conf b/rair-front/nginx-prod/nginx.conf index df260bfdc..e0c78d960 100644 --- a/rair-front/nginx-prod/nginx.conf +++ b/rair-front/nginx-prod/nginx.conf @@ -38,7 +38,7 @@ server { } location /socket.io { - proxy_pass http://rair-stream:5002; + proxy_pass http://rair-node:5000; client_max_body_size 200000M; } } \ No newline at end of file diff --git a/rair-front/nginx/nginx.conf b/rair-front/nginx/nginx.conf index 0a02356e3..f97889611 100644 --- a/rair-front/nginx/nginx.conf +++ b/rair-front/nginx/nginx.conf @@ -39,7 +39,7 @@ server { } location /socket.io { - proxy_pass http://rair-stream:5002; + proxy_pass http://rair-node:5000; client_max_body_size 200000M; } -} \ No newline at end of file +} diff --git a/rair-front/nginx/nginx.conf.ssl b/rair-front/nginx/nginx.conf.ssl new file mode 100644 index 000000000..3b9ef8868 --- /dev/null +++ b/rair-front/nginx/nginx.conf.ssl @@ -0,0 +1,65 @@ +events {} +http { +server { + listen 80; + server_name {domain}; + location / { + return 301 https://$host$request_uri; + } + location ~ /.well-known/acme-challenge/ { + root /var/www/certbot; + } +} +server { + listen 443 ssl; + #listen [::]:80; + + #Docker DNS + #resolver 127.0.0.11; + + server_name {domain}; + access_log /var/log/nginx/appstore.access.log; + error_log /var/log/nginx/appstore.error.log; + ssl_certificate /etc/letsencrypt/live/{domain}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/{domain}/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header 'Access-Control-Allow-Origin' 'https://new-api.rair.tech'; + add_header 'Access-Control-Allow-Origin' 'https://new-ms.rair.tech'; + add_header 'Access-Control-Allow-Origin' 'https://api.hotdrops.live'; + + location ~ /.well-known/acme-challenge/ { + root /var/www/certbot; + } + location / { + root /usr/share/nginx/html; + index index.html index.htm; + include /etc/nginx/mime.types; + try_files $uri $uri/ /index.html; + # add header Cache-Control "public, max-age=3600, must-revalidate"; + } + + location /api { + proxy_pass http://rair-node:5000; + client_max_body_size 200000M; + #proxy_set_header X-Forwarded-Proto $scheme; + #proxy_cookie_path ~^/(.+)$ "/$1; secure; SameSite=none"; + } + + location /stream { + proxy_pass http://rair-node:5000; + #proxy_set_header X-Forwarded-Proto $scheme; + } + + location /ms { + proxy_pass http://rair-stream:5002; + client_max_body_size 200000M; + #proxy_set_header X-Forwarded-Proto $scheme; + } + + location /socket.io { + proxy_pass http://rair-stream:5002; + client_max_body_size 200000M; + } +} +} diff --git a/rair-front/package.json b/rair-front/package.json index 92b7e9e1b..ec4e654fe 100644 --- a/rair-front/package.json +++ b/rair-front/package.json @@ -13,11 +13,11 @@ "prepare": "cd ../ && husky install ./minting-marketplace/.husky" }, "dependencies": { - "@alchemy/aa-accounts": "^3.5.1", - "@alchemy/aa-alchemy": "^3.5.1", - "@alchemy/aa-core": "^3.5.1", - "@alchemy/aa-ethers": "^3.5.1", - "@alchemy/aa-signers": "^3.5.1", + "@alchemy/aa-accounts": "^3.18.2", + "@alchemy/aa-alchemy": "^3.18.2", + "@alchemy/aa-core": "^3.18.2", + "@alchemy/aa-ethers": "^3.18.2", + "@alchemy/aa-signers": "^3.18.2", "@analytics/google-analytics": "^1.0.7", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", @@ -38,8 +38,8 @@ "@types/uuid": "^9.0.7", "@walletconnect/sign-client": "^2.10.6", "@walletconnect/utils": "^2.11.0", - "@web3auth/base": "^8.0.0", - "@web3auth/modal": "^8.0.1", + "@web3auth/base": "^8.6.2", + "@web3auth/modal": "^8.6.2", "alchemy-sdk": "^3.2.0", "analytics": "^0.8.9", "axios": "^1.6.2", @@ -58,6 +58,7 @@ "react-ga": "^3.3.1", "react-helmet-async": "^2.0.3", "react-hook-form": "^7.49.0", + "react-hot-toast": "^2.4.1", "react-modal": "^3.16.1", "react-moment": "^1.1.3", "react-multi-carousel": "^2.8.4", @@ -72,7 +73,7 @@ "redux": "^4.2.1", "redux-saga": "^1.2.3", "slick-carousel": "^1.8.1", - "socket.io-client": "^4.7.2", + "socket.io-client": "^4.7.5", "styled-components": "^5.3.3", "sweetalert2": "^11.10.1", "sweetalert2-react-content": "^5.0.7", @@ -98,7 +99,7 @@ "eslint-plugin-react-refresh": "^0.4.4", "eslint-plugin-simple-import-sort": "^10.0.0", "typescript": "^5.4.2", - "vite": "^5.1.6", + "vite": "^5.2.11", "vite-plugin-node-polyfills": "^0.21.0" } } diff --git a/rair-front/src/App.tsx b/rair-front/src/App.tsx index 0f682af9b..911c04ce6 100644 --- a/rair-front/src/App.tsx +++ b/rair-front/src/App.tsx @@ -1,5 +1,6 @@ //@ts-nocheck import { Fragment, useCallback, useEffect, useState } from 'react'; +import { Toaster } from 'react-hot-toast'; import { useDispatch, useSelector } from 'react-redux'; import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; // React Redux types @@ -92,7 +93,7 @@ import { detectBlockchain } from './utils/blockchainData'; // import getInformationGoogleAnalytics from './utils/googleAnalytics'; import gtag from './utils/gtag'; // views -import { ErrorFallback } from './views/ErrorFallback/ErrorFallback'; +import ErrorFallback from './views/ErrorFallback/ErrorFallback'; import 'bootstrap/dist/css/bootstrap.min.css'; import './App.css'; @@ -181,10 +182,15 @@ function App() { useEffect(() => { if (window.ethereum) { - window.ethereum.on('chainChanged', async (chainId) => { + const foo = async (chainId) => { dispatch(setChainId(chainId)); - }); + }; + window.ethereum.on('chainChanged', foo); window.ethereum.on('accountsChanged', logoutUser); + return () => { + window.ethereum.off('chainChanged', foo); + window.ethereum.off('accountsChanged', logoutUser); + }; } }, [dispatch, logoutUser]); @@ -304,7 +310,7 @@ function App() { }, [settings]); return ( - + }> {showAlert === true && (
+ {carousel && !isIframePage ? ( = ({ setDisabledBtn(false); } } catch (e) { - console.info(e); + console.error(e); toggleTitleVideo(); setDisabledBtn(false); } diff --git a/rair-front/src/components/DemoMediaUpload/MediaListBox/MediaListBox.tsx b/rair-front/src/components/DemoMediaUpload/MediaListBox/MediaListBox.tsx index d69e1f16c..a27d77616 100644 --- a/rair-front/src/components/DemoMediaUpload/MediaListBox/MediaListBox.tsx +++ b/rair-front/src/components/DemoMediaUpload/MediaListBox/MediaListBox.tsx @@ -1,6 +1,5 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Provider, useDispatch, useSelector, useStore } from 'react-redux'; -import { io } from 'socket.io-client'; import { RootState } from '../../../ducks'; import { ColorStoreType } from '../../../ducks/colors/colorStore.types'; @@ -11,6 +10,7 @@ import { import useSwal from '../../../hooks/useSwal'; import chainData from '../../../utils/blockchainData'; import { rFetch } from '../../../utils/rFetch'; +import sockets from '../../../utils/sockets'; import InputField from '../../common/InputField'; import InputSelect from '../../common/InputSelect'; import LinearProgressWithLabel from '../LinearProgressWithLabel/LinearProgressWithLabel'; @@ -298,7 +298,6 @@ const MediaListBox: React.FC = ({ newUserStatus, rerender }) => { - const [thisSessionId, setThisSessionId] = useState(''); const [uploadProgress, setUploadProgress] = useState(0); const [contract, setContract] = useState(item.contractAddress); @@ -314,12 +313,15 @@ const MediaListBox: React.FC = ({ const [uploading, setUploading] = useState(false); const [socketMessage, setSocketMessage] = useState(''); const [uploadSuccess, setUploadSuccess] = useState(false); - const [categoryOptions, setCategoryOptions] = useState([]); - - const { primaryColor, textColor, primaryButtonColor } = useSelector< - RootState, - ColorStoreType - >((store) => store.colorStore); + const [categoryOptions, setCategoryOptions] = useState([]); + + const { + primaryColor, + secondaryColor, + textColor, + primaryButtonColor, + secondaryButtonColor + } = useSelector((store) => store.colorStore); const store = useStore(); const reactSwal = useSwal(); const dispatch = useDispatch(); @@ -341,32 +343,34 @@ const MediaListBox: React.FC = ({ }, [getCategories]); useEffect(() => { - const sessionId = Math.random().toString(36).slice(2, 9); - setThisSessionId(sessionId); - const so = io(); - so.emit('init', sessionId); - so.on('uploadProgress', (data) => { - const { last, message, done } = data; - setSocketMessage(message); - setUploadProgress(done); - if (last) { - setSocketMessage(''); - setUploading(false); - setUploadSuccess(true); - setTimeout(() => { - dispatch(uploadVideoEnd()); - rerender?.(); - deleter(index); - }, 3000); + const report = (socketData) => { + if (!socketData) { + return; } - }); + setUploading(true); + const { message, data } = socketData; + const [videoTitle, progress] = data; + if (item.file.name === videoTitle) { + setSocketMessage(message); + setUploadProgress(progress); + if (progress === 100) { + setSocketMessage(''); + setUploading(false); + setUploadSuccess(true); + setTimeout(() => { + dispatch(uploadVideoEnd()); + rerender?.(); + deleter(index); + }, 3000); + } + } + }; + sockets.nodeSocket.on('uploadProgress', report); return () => { - so.removeListener('uploadProgress'); - so.emit('end', sessionId); + sockets.nodeSocket.off('uploadProgress', report); }; - //eslint-disable-next-line - }, []); + }, [deleter, dispatch, index, item.file.name, rerender]); const uploadVideo = useCallback( async (storage) => { @@ -400,27 +404,21 @@ const MediaListBox: React.FC = ({ icon: 'info', showConfirmButton: false }); - const request = await rFetch( - `/ms/api/v1/media/upload?socketSessionId=${thisSessionId}`, - // `${import.meta.env.VITE_UPLOAD_PROGRESS_HOST}/ms/api/v1/media/upload${ - // newUserStatus ? '/demo' : '' - // }?socketSessionId=${thisSessionId}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'x-rair-token': tokenRequest.secret - }, - body: formData - } - ); - - if (request && request.status === 'faild') { + const request = await rFetch(`/ms/api/v1/media/upload`, { + method: 'POST', + headers: { + Accept: 'application/json', + 'x-rair-token': tokenRequest.secret + }, + body: formData + }); + + if (request?.status === 'error') { setUploading(false); setUploadProgress(0); setUploadSuccess(false); setSocketMessage(''); - } else { + } else if (request?.success) { reactSwal.close(); } } catch (e) { @@ -441,7 +439,6 @@ const MediaListBox: React.FC = ({ demo, category, rerender, - thisSessionId, reactSwal ] ); @@ -479,137 +476,142 @@ const MediaListBox: React.FC = ({ showCancelButton: true, width: '40vw' }); - }, [reactSwal, uploadVideo]); + }, [reactSwal, uploadVideo, primaryButtonColor, textColor]); + + const editVideoTitle = useCallback(() => { + reactSwal.fire({ + html: ( + + + + ), + showConfirmButton: false + }); + }, [reactSwal, category, categoryOptions, description, store, title]); + + const selectVideoOffer = useCallback(() => { + reactSwal.fire({ + html: ( + + + + ), + showConfirmButton: false + }); + }, [reactSwal, store, contract, product, offer, demo]); return (
-
+