From d625215bb025d4fa357551c8f2c2198e5c9f9775 Mon Sep 17 00:00:00 2001 From: byeolhaha Date: Mon, 3 Jun 2024 12:56:58 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=EC=99=B8=EA=B5=AD=EC=9D=B8=20?= =?UTF-8?q?=EA=B3=A0=EA=B0=9D=EC=9D=B8=20=EC=84=A4=EB=AC=B8=20=EC=A1=B0?= =?UTF-8?q?=EC=82=AC=EB=A5=BC=20=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=EC=97=90=20=EB=8C=80=ED=95=9C=20alert=20?= =?UTF-8?q?=EA=B2=BD=EA=B3=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 2 +- src/main/resources/static/js/index.js | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index fe1d7b5..100ea99 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -82,7 +82,7 @@ jobs: - name: Build with gradle run: ./gradlew build - - name: Docker login + - name: Docker build & push if: contains(github.ref, 'main') run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} diff --git a/src/main/resources/static/js/index.js b/src/main/resources/static/js/index.js index 74cd9c2..675c893 100644 --- a/src/main/resources/static/js/index.js +++ b/src/main/resources/static/js/index.js @@ -7,7 +7,12 @@ document.getElementById("newCustomer").addEventListener("click", function() { }); document.getElementById("existingCustomer").addEventListener("click", function() { - window.location.href = "/templates/client-chatrooms.html"; + userId = getUserIdFromCookie(); + if (userId === 0) { + alert("This is your first visit. Please click on the 'No first visit✅' button"); + } else { + window.location.href = "/templates/client-chatrooms.html"; + } }); document.getElementsByClassName("close")[0].addEventListener("click", function() { @@ -18,4 +23,18 @@ window.addEventListener("click", function(event) { if (event.target == document.getElementById("myModal")) { document.getElementById("myModal").style.display = "none"; } -}); \ No newline at end of file +}); + +function getUserIdFromCookie() { + const cookieString = document.cookie; + const cookies = cookieString.split(';'); + + for (let cookie of cookies) { + const [cookieName, cookieValue] = cookie.split('='); + if (cookieName.trim() === 'userId') { + return parseInt(cookieValue) || 0; + } + } + + return 0; +} \ No newline at end of file