From 7a2ad4bf9c202071ccf1d89eee5eb35eefbd1931 Mon Sep 17 00:00:00 2001 From: nyatindopatrick Date: Mon, 14 Oct 2024 09:00:18 +0300 Subject: [PATCH] update login redirect --- .env | 2 +- .github/workflows/deploy.yml | 20 ++++++++++++-------- src/pages/Login.jsx | 9 ++++----- src/pages/VaccinationSchedule.jsx | 1 + 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.env b/.env index 64b276e..137a199 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VITE_SERVER_BASE_URL=https://chanjoke.intellisoftkenya.com \ No newline at end of file +VITE_SERVER_BASE_URL=https://openchanjotest.intellisoftkenya.com \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 209b017..249bb94 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -66,16 +66,20 @@ jobs: echo "Error: Docker login failed" exit 1 fi - - docker pull --quiet \$IMAGE_NAME - if [ \$? -ne 0 ]; then - echo "Error: Failed to pull Docker image \$IMAGE_NAME" - exit 1 + + if [ "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'Dev') }}" == "Dev" ]; then + cd /opt/ChanjoKe-HIE/hie + else + cd /opt/chanjoke-hie/hie fi - - sudo docker run -d --name \$CONTAINER_NAME -p 8098:3000 \$IMAGE_NAME + + sudo docker compose pull client + + # recreate the client service with the new image + sudo docker compose up -d client --force-recreate + sudo docker logout echo "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'Dev') }} deployment completed successfully" EOF - rm -f private_key + rm -f private_key \ No newline at end of file diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index 9b2fb3f..f6294ad 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -1,15 +1,14 @@ -import MOHLogo from "../assets/nav-logo.png"; import { LockOutlined, UserOutlined, WarningTwoTone } from "@ant-design/icons"; -import { Link, useNavigate } from "react-router-dom"; +import { Button, Form, Input } from "antd"; import { useState } from "react"; -import { Button, Input, Form, Row, Col } from "antd"; +import { Link } from "react-router-dom"; import { useApiRequest } from "../api/useApi"; +import MOHLogo from "../assets/nav-logo.png"; export default function Login() { const [loading, setLoading] = useState(false); const [loginError, setLoginError] = useState(false); - const navigation = useNavigate(); const { post, get } = useApiRequest(); const [form] = Form.useForm(); @@ -31,7 +30,7 @@ export default function Login() { localStorage.setItem("user", JSON.stringify(userData?.user)); - navigation("/"); + window.location.href = "/"; } } catch (e) { console.log({ e }); diff --git a/src/pages/VaccinationSchedule.jsx b/src/pages/VaccinationSchedule.jsx index 7c9a30f..57db3cd 100644 --- a/src/pages/VaccinationSchedule.jsx +++ b/src/pages/VaccinationSchedule.jsx @@ -81,6 +81,7 @@ export default function VaccinationSchedule() { immunizations, fetchPatientImmunizations, } = useImmunization() + const user = JSON.parse(localStorage.getItem('user')) const [vaccineSchedules, setVaccineSchedules] = useState([])