diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c5a88b7..732930e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -35,17 +35,20 @@ jobs: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 name: Set up Docker Buildx + - uses: docker/login-action@v3 - name: Login to Docker Hub + name: Login to GitHub Container Registry with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push uses: docker/build-push-action@v6 with: push: true context: ./client - tags: rmcampos/tasknote:${{ github.event.number }} + tags: ghcr.io/ricardo-campos-org/react-typescript-todolist/client:${{ github.event.number }} build-args: BUILD=${{ github.event.number }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index b4850e6..4ec0a9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,16 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules -/.pnp -.pnp.js +client/node_modules +client/.pnp +client.pnp.js # testing -/coverage +client/coverage # production -/build -/dist +client/build +client/dist # misc .DS_Store diff --git a/client/src/App.tsx b/client/src/App.tsx index 2f71b60..82fc9b7 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -11,14 +11,23 @@ import Layout from './layout/PrivateLayout'; import browserRoutes from './routes'; import NotFound from './views/NotFound'; import AuthContext from './context/AuthContext'; +import Login from './views/Login'; const App: React.FC = () => { const { signed, checkCurrentAuthUser } = useContext(AuthContext); const notSignedRouter = createBrowserRouter([ { - path: '*', + path: '/', element: + }, + { + path: '/signin', + element: + }, + { + path: '*', + element: } ]); diff --git a/client/src/views/Landing/index.tsx b/client/src/views/Landing/index.tsx index 32f83e1..1b04833 100644 --- a/client/src/views/Landing/index.tsx +++ b/client/src/views/Landing/index.tsx @@ -1,22 +1,22 @@ -import React, { useContext } from 'react'; +import React from 'react'; import { Button } from 'react-bootstrap'; import './styles.scss'; -import AuthContext from '../../context/AuthContext'; +import { useNavigate } from 'react-router-dom'; /** * */ function Landing() { - const { signIn } = useContext(AuthContext); + const navigate = useNavigate(); return ( <>

This is landing page

); diff --git a/client/src/views/Login/index.tsx b/client/src/views/Login/index.tsx new file mode 100644 index 0000000..68e9473 --- /dev/null +++ b/client/src/views/Login/index.tsx @@ -0,0 +1,108 @@ +import React, { useContext, useEffect, useState } from 'react'; +import { Button, Form } from 'react-bootstrap'; +import { FeedbackType } from 'react-bootstrap/esm/Feedback'; +import AuthContext from '../../context/AuthContext'; + +/** + * Created the Login component. + */ +function Login() { + const { signIn } = useContext(AuthContext); + const [validated, setValidated] = useState(true); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [emailValidType, setEmailValidType] = useState('valid'); + const [emailValidMsg, setEmailValidMsg] = useState('Looks good!'); + const [passwordValidType, setPasswordValidType] = useState('valid'); + const [passwordValidMsg, setPasswordValidMsg] = useState('Looks good!'); + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + event.stopPropagation(); + setValidated(true); + + const form = event.currentTarget; + if (form.checkValidity() === false) { + if (email.length === 0) { + setEmailValidType('invalid'); + setEmailValidMsg('Please type your email!'); + } else { + setEmailValidType('valid'); + setEmailValidMsg('Looks good!'); + } + + if (password.length === 0) { + setPasswordValidType('invalid'); + setPasswordValidMsg('Please type your password!'); + } else { + setPasswordValidType('valid'); + setPasswordValidMsg('Looks good!'); + } + + return; + } + + setEmailValidType('valid'); + setEmailValidMsg('Looks good!'); + + setPasswordValidType('valid'); + setPasswordValidMsg('Looks good!'); + signIn(); + }; + + const resetForm = () => { + setValidated(false); + setEmail(''); + setEmailValidType('valid'); + setPassword(''); + setPasswordValidType('valid'); + }; + + useEffect(() => {}, [validated]); + + return ( + <> +

This is login page

+
+ + Email address + setEmail(e.target.value)} + isInvalid={emailValidType === 'invalid'} + /> + + {emailValidMsg} + + + + + Password + setPassword(e.target.value)} + isInvalid={passwordValidType === 'invalid'} + /> + + {passwordValidMsg} + + + + + +
+ + ); +} + +export default Login; diff --git a/docker-compose.yml b/docker-compose.yml index 71f3ee4..10f645e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,19 +2,23 @@ services: client: - container_name: tasknote + container_name: client image: node:20.17-bullseye-slim ports: - "5000:5000" entrypoint: sh -c "npm i --no-update-notifier && npm start" user: root volumes: - - "./:/app" + - "./client:/app" working_dir: /app environment: LOG_LEVEL: debug healthcheck: - test: timeout 10s bash -c 'true > /dev/tcp/127.0.0.1/3000' + test: timeout 10s bash -c 'true > /dev/tcp/127.0.0.1/5000' + interval: 1m30s + timeout: 15s + retries: 3 + start_period: 10s java-api: container_name: java-api @@ -39,9 +43,9 @@ services: healthcheck: test: curl -f http://localhost:8585/actuator/health | grep '"status":"UP"' interval: 1m30s - timeout: 30s - retries: 5 - start_period: 30s + timeout: 15s + retries: 3 + start_period: 10s postgres: container_name: postgres @@ -52,8 +56,9 @@ services: POSTGRES_USER: tasknoteuser POSTGRES_PASSWORD: default POSTGRES_PORT: 5432 + PGDATA: /tmp volumes: - - "/pgdata" + - "./data:/tmp" ports: - "5432:5432" healthcheck: @@ -61,7 +66,7 @@ services: interval: 1m30s timeout: 15s retries: 3 - start_period: 15s + start_period: 10s caddy: container_name: caddy diff --git a/tools/run-docker.sh b/tools/run-docker.sh new file mode 100755 index 0000000..4a16708 --- /dev/null +++ b/tools/run-docker.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker compose up -d diff --git a/tools/stop-docker.sh b/tools/stop-docker.sh new file mode 100755 index 0000000..5e50d10 --- /dev/null +++ b/tools/stop-docker.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker compose down