diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..e83e811 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +NEXT_PUBLIC_STAGING=true \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..46aec0e --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +NEXT_PUBLIC_STAGING=false \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d630495..b6e5ee3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,9 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Setup Production Env + run: cp .env.production .env + - name: Build and push Docker image uses: docker/build-push-action@56932deb0a0db9d23e245320b1e45fec46b8d66f with: @@ -79,6 +82,9 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Setup Staging Env + run: cp .env.staging .env + - name: Build and push Docker image uses: docker/build-push-action@56932deb0a0db9d23e245320b1e45fec46b8d66f with: diff --git a/package-lock.json b/package-lock.json index 00313c2..a5abac2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@ericblade/quagga2": "^1.8.2", - "@frontendnetwork/vegancheck": "1.1.26", + "@frontendnetwork/vegancheck": "^1.1.31", "@socialgouv/matomo-next": "^1.6.1", "@types/node": "20.4.5", "@types/react-dom": "18.2.7", @@ -1894,9 +1894,9 @@ } }, "node_modules/@frontendnetwork/vegancheck": { - "version": "1.1.26", - "resolved": "https://registry.npmjs.org/@frontendnetwork/vegancheck/-/vegancheck-1.1.26.tgz", - "integrity": "sha512-6TRIHwK0ErMpKKaAOc0zkIReOg29xXn3wxNH3sJQINlj7vqyfg/Hai6lkKVaZHxkqdJkaG0rwZEk+GfjO42hyg==" + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/@frontendnetwork/vegancheck/-/vegancheck-1.1.31.tgz", + "integrity": "sha512-D2sFFtI/GXfUpCT6r35sGgcbKYWjTtLpMRspSVMh5cRBfUTn+hdqP2UH0PyvGuTf4qDkmFyq4Yst83MWh0rYGQ==" }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.10", diff --git a/package.json b/package.json index 3faddec..505f0d1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@ericblade/quagga2": "^1.8.2", - "@frontendnetwork/vegancheck": "1.1.26", + "@frontendnetwork/vegancheck": "^1.1.31", "@socialgouv/matomo-next": "^1.6.1", "@types/node": "20.4.5", "@types/react-dom": "18.2.7", diff --git a/src/components/check.tsx b/src/components/check.tsx index 9ee330d..be87755 100644 --- a/src/components/check.tsx +++ b/src/components/check.tsx @@ -64,7 +64,8 @@ const ProductSearch: React.FC = () => { setLoading(true); try { - const data = await VeganCheck.getProductByBarcode(barcode); + console.warn(process.env.NEXT_PUBLIC_STAGING); + const data = await VeganCheck.getProductByBarcode(barcode, process.env.NEXT_PUBLIC_STAGING === "true" ? true : false); setLoading(false); if (data.status === 200) { setResult(data.product); diff --git a/src/components/ingredientscheck.tsx b/src/components/ingredientscheck.tsx index 59d3054..f9d514e 100644 --- a/src/components/ingredientscheck.tsx +++ b/src/components/ingredientscheck.tsx @@ -28,7 +28,7 @@ const IngredientsCheck = () => { const checkIngredients = async () => { setLoading(true); try { - const data = await VeganCheck.checkIngredientsList(ingredients.value); + const data = await VeganCheck.checkIngredientsList(ingredients.value, process.env.NEXT_PUBLIC_STAGING === "true" ? true : false); if (data.data.vegan === "false") { setVegan(false); setFlagged(data.data.flagged);