', PasswordTokenCheckAPI.as_view(), name='password-reset-confirm'),
13 | path('api/password-reset-complete', SetNewPasswordAPIView.as_view(), name='password-reset-complete'),
14 | ]
15 |
--------------------------------------------------------------------------------
/backend/accounts/utils.py:
--------------------------------------------------------------------------------
1 | from django.core.mail import EmailMessage
2 | import threading
3 |
4 |
5 | class EmailThread(threading.Thread):
6 |
7 | def __init__(self, email):
8 | self.email = email
9 | threading.Thread.__init__(self)
10 |
11 | def run(self):
12 | self.email.send()
13 |
14 |
15 | class Util:
16 | @staticmethod
17 | def send_email(data):
18 | email = EmailMessage(subject=data['email_subject'], body=data['email_body'], to=[data['to_email']])
19 | EmailThread(email).start()
--------------------------------------------------------------------------------
/backend/accounts/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/backend/frontend/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/frontend/__init__.py
--------------------------------------------------------------------------------
/backend/frontend/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/backend/frontend/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FrontendConfig(AppConfig):
5 | name = 'frontend'
6 |
--------------------------------------------------------------------------------
/backend/frontend/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/frontend/migrations/__init__.py
--------------------------------------------------------------------------------
/backend/frontend/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/backend/frontend/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/backend/frontend/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/backend/log_app_django/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__init__.py
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/settings.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/settings.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/urls.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/urls.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/__pycache__/wsgi.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/log_app_django/__pycache__/wsgi.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/log_app_django/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for log_app_django project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'log_app_django.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/backend/log_app_django/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for log_app_django project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.2.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 | from dotenv import load_dotenv
15 | from os import getenv
16 |
17 | load_dotenv()
18 |
19 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
20 | BASE_DIR = Path(__file__).resolve().parent.parent
21 |
22 |
23 | # Quick-start development settings - unsuitable for production
24 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
25 |
26 | # SECURITY WARNING: keep the secret key used in production secret!
27 | SECRET_KEY = 'gsi%7o57z=^0*@1itd3x8o=8!=ho_&&_hrj(72z+!c-&v&mk4t'
28 |
29 | # SECURITY WARNING: don't run with debug turned on in production!
30 | DEBUG = True
31 |
32 | ALLOWED_HOSTS = []
33 |
34 | AUTH_USER_MODEL = 'accounts.EmailUser'
35 |
36 | # Application definition
37 |
38 | INSTALLED_APPS = [
39 | # 'trucks.apps.TrucksConfig',
40 | 'django.contrib.admin',
41 | 'django.contrib.auth',
42 | 'django.contrib.contenttypes',
43 | 'django.contrib.sessions',
44 | 'django.contrib.messages',
45 | 'django.contrib.staticfiles',
46 |
47 | 'rest_framework',
48 | 'corsheaders',
49 | 'accounts',
50 | 'trucks',
51 | 'knox',
52 |
53 | ]
54 |
55 | REST_FRAMEWORK = {
56 | 'DEFAULT_AUTHENTICATION_CLASSES': [
57 | # 'rest_framework.authentication.BasicAuthentication',
58 | # 'rest_framework.authentication.SessionAuthentication',
59 | 'knox.auth.TokenAuthentication',
60 | ]
61 | }
62 |
63 | MIDDLEWARE = [
64 | 'django.middleware.security.SecurityMiddleware',
65 | 'django.contrib.sessions.middleware.SessionMiddleware',
66 | 'corsheaders.middleware.CorsMiddleware',
67 | 'django.middleware.common.CommonMiddleware',
68 | 'django.middleware.common.CommonMiddleware',
69 | 'django.middleware.csrf.CsrfViewMiddleware',
70 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
71 | 'django.contrib.messages.middleware.MessageMiddleware',
72 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
73 | ]
74 |
75 | ROOT_URLCONF = 'log_app_django.urls'
76 |
77 | TEMPLATES = [
78 | {
79 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
80 | 'DIRS': [],
81 | 'APP_DIRS': True,
82 | 'OPTIONS': {
83 | 'context_processors': [
84 | 'django.template.context_processors.debug',
85 | 'django.template.context_processors.request',
86 | 'django.contrib.auth.context_processors.auth',
87 | 'django.contrib.messages.context_processors.messages',
88 | ],
89 | },
90 | },
91 | ]
92 |
93 | WSGI_APPLICATION = 'log_app_django.wsgi.application'
94 |
95 |
96 | # Database
97 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
98 |
99 | # DATABASES = {
100 | # 'default': {
101 | # 'ENGINE': 'django.db.backends.sqlite3',
102 | # 'NAME': BASE_DIR / 'db.sqlite3',
103 | # }
104 | # }
105 | DATABASES = {
106 | 'default': {
107 | 'ENGINE': 'django.db.backends.postgresql_psycopg2',
108 | 'NAME': 'postgres_test_logapp',
109 | 'USER': 'postgres',
110 | 'PASSWORD': 'admin1',
111 | 'HOST': 'localhost',
112 | 'PORT': '5432',
113 | }
114 | }
115 |
116 |
117 | # Password validation
118 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
119 |
120 | AUTH_PASSWORD_VALIDATORS = [
121 | {
122 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
123 | },
124 | {
125 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
126 | },
127 | {
128 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
129 | },
130 | {
131 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
132 | },
133 | ]
134 |
135 |
136 | # Internationalization
137 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
138 |
139 | LANGUAGE_CODE = 'en-us'
140 |
141 | TIME_ZONE = 'UTC'
142 |
143 | USE_I18N = True
144 |
145 | USE_L10N = True
146 |
147 | USE_TZ = True
148 |
149 |
150 | # Static files (CSS, JavaScript, Images)
151 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
152 |
153 | STATIC_URL = '/static/'
154 |
155 | DEFAULT_FROM_EMAIL = getenv('EMAIL_HOST_USER')
156 | SERVER_EMAIL = getenv('EMAIL_HOST_USER')
157 | EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
158 | # EMAIL_USE_TLS = True
159 | EMAIL_USE_SSL = True
160 | EMAIL_HOST = 'smtp.gmail.com'
161 | EMAIL_PORT = 465
162 | EMAIL_HOST_USER = getenv('EMAIL_HOST_USER')
163 | EMAIL_HOST_PASSWORD = getenv('EMAIL_HOST_PASSWORD')
164 |
165 | CORS_ALLOW_ALL_ORIGINS = True
166 |
--------------------------------------------------------------------------------
/backend/log_app_django/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path, include
3 |
4 | urlpatterns = [
5 | path('admin/', admin.site.urls),
6 | path('', include('accounts.urls')),
7 | path('', include('trucks.urls'))
8 | ]
9 |
--------------------------------------------------------------------------------
/backend/log_app_django/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for log_app_django project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'log_app_django.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/backend/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'log_app_django.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/backend/requirements.txt:
--------------------------------------------------------------------------------
1 | asgiref==3.2.10
2 | cffi==1.14.3
3 | cryptography==3.1.1
4 | Django==3.1.2
5 | django-cors-headers==3.5.0
6 | django-rest-knox==4.1.0
7 | djangorestframework==3.12.1
8 | psycopg2==2.8.6
9 | pycparser==2.20
10 | python-dotenv==0.15.0
11 | pytz==2020.1
12 | six==1.15.0
13 | sqlparse==0.4.1
14 |
--------------------------------------------------------------------------------
/backend/trucks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__init__.py
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/admin.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/admin.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/api.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/api.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/apps.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/apps.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/models.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/models.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/serializers.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/serializers.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/__pycache__/urls.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/__pycache__/urls.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Truck
3 |
4 | # Register your models here.
5 | admin.site.register(Truck)
6 |
--------------------------------------------------------------------------------
/backend/trucks/api.py:
--------------------------------------------------------------------------------
1 | from trucks.models import Truck
2 | from rest_framework import viewsets, permissions
3 | from .serializers import TruckSerializer
4 |
5 |
6 | # Lead Viewset
7 | class TruckViewSet(viewsets.ModelViewSet):
8 | queryset = Truck.objects.all()
9 | permission_classes = [
10 | permissions.AllowAny
11 | ]
12 | serializer_class = TruckSerializer
--------------------------------------------------------------------------------
/backend/trucks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TrucksConfig(AppConfig):
5 | name = 'trucks'
6 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.2 on 2020-10-25 10:33
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Trucks',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('car', models.CharField(max_length=100)),
19 | ('semitariler', models.CharField(max_length=100)),
20 | ('capacity', models.CharField(max_length=100)),
21 | ('registration_number', models.CharField(max_length=100, unique=True)),
22 | ('message', models.CharField(blank=True, max_length=500)),
23 | ('created_at', models.DateTimeField(auto_now_add=True)),
24 | ],
25 | ),
26 | ]
27 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/0002_auto_20201025_1152.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.2 on 2020-10-25 10:52
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('trucks', '0001_initial'),
10 | ]
11 |
12 | operations = [
13 | migrations.RenameField(
14 | model_name='trucks',
15 | old_name='semitariler',
16 | new_name='semitrailer',
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/0003_auto_20201025_2132.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.2 on 2020-10-25 20:32
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('trucks', '0002_auto_20201025_1152'),
10 | ]
11 |
12 | operations = [
13 | migrations.RenameModel(
14 | old_name='Trucks',
15 | new_name='Truck',
16 | ),
17 | ]
18 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/0004_auto_20201025_2222.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.2 on 2020-10-25 21:22
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('trucks', '0003_auto_20201025_2132'),
11 | ]
12 |
13 | operations = [
14 | migrations.RenameField(
15 | model_name='truck',
16 | old_name='car',
17 | new_name='car_manufacturer',
18 | ),
19 | migrations.CreateModel(
20 | name='Car',
21 | fields=[
22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23 | ('name', models.CharField(max_length=50)),
24 | ('truck', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='trucks.truck')),
25 | ],
26 | ),
27 | ]
28 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/0005_auto_20201029_2137.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.2 on 2020-10-29 20:37
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('trucks', '0004_auto_20201025_2222'),
10 | ]
11 |
12 | operations = [
13 | migrations.RemoveField(
14 | model_name='car',
15 | name='truck',
16 | ),
17 | migrations.AddField(
18 | model_name='car',
19 | name='truck',
20 | field=models.ManyToManyField(to='trucks.Truck'),
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/backend/trucks/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__init__.py
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/0001_initial.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/0001_initial.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/0002_auto_20201025_1152.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/0002_auto_20201025_1152.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/0003_auto_20201025_2132.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/0003_auto_20201025_2132.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/0004_auto_20201025_2222.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/0004_auto_20201025_2222.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/0005_auto_20201029_2137.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/0005_auto_20201029_2137.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/migrations/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/backend/trucks/migrations/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/backend/trucks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 |
4 | class Truck(models.Model):
5 | car_manufacturer = models.CharField(max_length=100)
6 | semitrailer = models.CharField(max_length=100)
7 | capacity = models.CharField(max_length=100)
8 | registration_number = models.CharField(max_length=100, unique=True)
9 | message = models.CharField(max_length=500, blank=True)
10 | created_at = models.DateTimeField(auto_now_add=True)
11 |
12 | def __str__(self):
13 | return self.car_manufacturer
14 |
15 |
16 | class Car(models.Model):
17 | truck = models.ManyToManyField(Truck)
18 | name = models.CharField(max_length=50)
19 |
20 | def __str__(self):
21 | return self.name
--------------------------------------------------------------------------------
/backend/trucks/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from trucks.models import Truck
3 |
4 |
5 | # Trucks Serializer
6 | class TruckSerializer(serializers.ModelSerializer):
7 | class Meta:
8 | model = Truck
9 | fields = '__all__'
--------------------------------------------------------------------------------
/backend/trucks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/backend/trucks/urls.py:
--------------------------------------------------------------------------------
1 | from rest_framework import routers
2 | from .api import TruckViewSet
3 |
4 |
5 | router = routers.DefaultRouter()
6 | router.register('api/truck', TruckViewSet, 'truck')
7 |
8 | urlpatterns = router.urls
9 |
--------------------------------------------------------------------------------
/backend/trucks/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/backend/user.txt:
--------------------------------------------------------------------------------
1 | testest_user
2 | testmail@logapp.com
3 | test1234
--------------------------------------------------------------------------------
/docs/client_docs/logowanie.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/docs/client_docs/logowanie.pdf
--------------------------------------------------------------------------------
/docs/client_docs/rejestracja.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/docs/client_docs/rejestracja.pdf
--------------------------------------------------------------------------------
/docs/client_docs/start.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/docs/client_docs/start.pdf
--------------------------------------------------------------------------------
/docs/client_docs/wymiary_przestrzeni_i_ladunkow.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/docs/client_docs/wymiary_przestrzeni_i_ladunkow.xlsx
--------------------------------------------------------------------------------
/frontend/.env.development:
--------------------------------------------------------------------------------
1 | REACT_APP_API_BASE_URL=http://localhost:8000
2 | REACT_APP_API_LOGIN_URL=${REACT_APP_API_BASE_URL}/api/auth/login
3 | REACT_APP_API_REGISTER_URL=${REACT_APP_API_BASE_URL}/api/auth/register
4 | REACT_APP_API_USER_URL=${REACT_APP_API_BASE_URL}/api/auth/user
5 | REACT_APP_API_LOGOUT_URL=${REACT_APP_API_BASE_URL}/api/auth/logout
6 | REACT_APP_API_TRUCK_URL=${REACT_APP_API_BASE_URL}/api/truck
7 |
--------------------------------------------------------------------------------
/frontend/.env.production:
--------------------------------------------------------------------------------
1 | REACT_APP_API_BASE_URL=http://logapi.pl/
2 | REACT_APP_API_LOGIN_URL=${REACT_APP_API_BASE_URL}/api/auth/login
3 | REACT_APP_API_REGISTER_URL=${REACT_APP_API_BASE_URL}/api/auth/register
4 | REACT_APP_API_USER_URL=${REACT_APP_API_BASE_URL}/api/auth/user
5 | REACT_APP_API_LOGOUT_URL=${REACT_APP_API_BASE_URL}/api/auth/logout
6 | REACT_APP_API_TRUCK_URL=${REACT_APP_API_BASE_URL}/api/truck
--------------------------------------------------------------------------------
/frontend/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["airbnb", "prettier", "prettier/react"],
3 | "env": {
4 | "jest": true
5 | },
6 | "globals": {
7 | "window": true,
8 | "document": true,
9 | "localStorage": true,
10 | "fetch": true
11 | },
12 | "rules": {
13 | "no-console": 0,
14 | "jsx-a11y/no-noninteractive-element-interactions": [
15 | 0,
16 | {
17 | "handlers": [
18 | "onClick",
19 | "onMouseDown",
20 | "onMouseUp",
21 | "onKeyPress",
22 | "onKeyDown",
23 | "onKeyUp"
24 | ]
25 | }
26 | ],
27 | "jsx-a11y/no-static-element-interactions": [
28 | 0,
29 | {
30 | "handlers": [
31 | "onClick",
32 | "onMouseDown",
33 | "onMouseUp",
34 | "onKeyPress",
35 | "onKeyDown",
36 | "onKeyUp"
37 | ]
38 | }
39 | ],
40 | "jsx-a11y/click-events-have-key-events": [0, { "extensions": [".js", ".jsx"] }],
41 | "react/jsx-filename-extension": [
42 | 1,
43 | {
44 | "extensions": [".js", ".jsx"]
45 | }
46 | ]
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/frontend/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "all",
3 | "tabWidth": 4,
4 | "singleQuote": true,
5 | "printWidth": 100
6 | }
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "log_app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@fortawesome/fontawesome-svg-core": "^1.2.32",
7 | "@fortawesome/free-solid-svg-icons": "^5.15.1",
8 | "@fortawesome/react-fontawesome": "^0.1.12",
9 | "@testing-library/jest-dom": "^4.2.4",
10 | "@testing-library/react": "^9.5.0",
11 | "@testing-library/user-event": "^7.2.1",
12 | "axios": "^0.21.0",
13 | "node-sass": "^4.14.1",
14 | "normalize.css": "^8.0.1",
15 | "prop-types": "^15.7.2",
16 | "react": "^16.13.1",
17 | "react-dom": "^16.13.1",
18 | "react-loader-spinner": "^3.1.14",
19 | "react-promise-tracker": "^2.1.0",
20 | "react-router-dom": "^5.2.0",
21 | "react-scripts": "3.4.3"
22 | },
23 | "scripts": {
24 | "start": "react-scripts start",
25 | "build": "react-scripts build",
26 | "test": "react-scripts test",
27 | "eject": "react-scripts eject"
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | },
41 | "devDependencies": {
42 | "dotenv": "^8.2.0",
43 | "eslint": "^6.6.0",
44 | "eslint-config-airbnb": "^18.2.0",
45 | "eslint-config-prettier": "^6.15.0",
46 | "eslint-plugin-import": "^2.22.1",
47 | "eslint-plugin-jsx-a11y": "^6.4.1",
48 | "eslint-plugin-react": "^7.21.5",
49 | "eslint-plugin-react-hooks": "^4.0.0",
50 | "prettier": "^2.1.2"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/frontend/public/favicon-apple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/frontend/public/favicon-apple.png
--------------------------------------------------------------------------------
/frontend/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/frontend/public/favicon.png
--------------------------------------------------------------------------------
/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
--------------------------------------------------------------------------------
/frontend/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render } from '@testing-library/react';
3 | import App from './App';
4 |
5 | test('renders learn react link', () => {
6 | const { getByText } = render();
7 | const linkElement = getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/frontend/src/assets/images/404.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/frontend/src/assets/images/404.png
--------------------------------------------------------------------------------
/frontend/src/assets/images/LogAppLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/frontend/src/assets/images/LogAppLogo.png
--------------------------------------------------------------------------------
/frontend/src/components/Header/Header.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useEffect, useRef } from 'react';
2 | import { NavLink } from 'react-router-dom';
3 | import styles from './Header.module.scss';
4 | import { useStateWithLabel, isLogged } from '../../helpers/helpers';
5 | import { StoreContext } from '../../store/StoreProvider';
6 | import LoginInfo from '../LoginInfo/LoginInfo';
7 |
8 | const Header = () => {
9 | const { routerLinks, isOpenMenu, setIsOpenMenu, setUserData, userData } = useContext(
10 | StoreContext,
11 | );
12 |
13 | // eslint-disable-next-line no-unused-vars
14 | const [clickedOutsideMenu, setClickedOutsideMenu] = useStateWithLabel('clickedOutside', false);
15 |
16 | const myRef = useRef();
17 |
18 | const handleClickOutsideMenu = (e) => {
19 | if (!myRef.current.contains(e.target)) {
20 | setClickedOutsideMenu(true);
21 | setIsOpenMenu(false);
22 | }
23 | };
24 |
25 | useEffect(() => {
26 | if (isLogged() && !userData.isLogged) {
27 | const data = JSON.parse(localStorage.getItem('LogAppUser'));
28 |
29 | setUserData({
30 | username: data.username,
31 | email: data.email,
32 | isLogged: data.isLogged,
33 | token: data.token,
34 | });
35 | }
36 |
37 | document.addEventListener('mousedown', handleClickOutsideMenu);
38 | return () => document.removeEventListener('mousedown', handleClickOutsideMenu);
39 | });
40 |
41 | const menu = routerLinks.map((item) => (
42 |
43 |
44 | {item.name}
45 |
46 |
47 | ));
48 |
49 | const handleHamburgerClick = (e) => {
50 | e.preventDefault();
51 | setIsOpenMenu(!isOpenMenu);
52 | setClickedOutsideMenu(false);
53 | };
54 | const handleCloseMenu = (e) => {
55 | e.preventDefault();
56 | setIsOpenMenu(false);
57 | };
58 |
59 | return (
60 | <>
61 |
62 |
63 |
64 |
77 |
78 | >
79 | );
80 | };
81 | export default Header;
82 |
--------------------------------------------------------------------------------
/frontend/src/components/Header/Header.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../views/Root/common.scss';
2 | .header {
3 | display: flex;
4 | flex-wrap: nowrap;
5 | justify-content: space-between;
6 | padding: 10px;
7 | .logo {
8 | height: 200px;
9 | width: 300px;
10 | min-width: 70px;
11 | background-image: url('../../assets/images/LogAppLogo.png');
12 | background-size: contain;
13 | background-repeat: no-repeat;
14 | }
15 | .title {
16 | margin: 10px;
17 | text-align: center;
18 | font-size: $m-font-size * 1.2;
19 | color: $text-first-color;
20 | }
21 | .info {
22 | flex-basis: 40%;
23 | }
24 | @media (orientation: landscape) and (min-width: 1024px) {
25 | .logo {
26 | height: 200px;
27 | width: 300px;
28 | background-image: url('../../assets/images/LogAppLogo.png');
29 | background-size: auto;
30 | background-repeat: no-repeat;
31 | }
32 | .title {
33 | margin: 20px;
34 | font-size: $x-font-size * 1.8;
35 | }
36 | .info {
37 | flex-basis: 60%;
38 | }
39 | }
40 | }
41 |
42 | .nav {
43 | min-width: 100px;
44 | .menu {
45 | position: absolute;
46 | top: 3em;
47 | margin: 0.5em 0;
48 | right: 1em;
49 | display: none;
50 | // display: flex;
51 | // visibility: hidden;
52 | flex-direction: column;
53 | justify-content: flex-end;
54 | align-items: flex-start;
55 |
56 | padding: 0.4em;
57 | z-index: 100;
58 | border: 1px solid $fourth-color;
59 | border-radius: 5px;
60 | transition: 0.6s ease-in-out all;
61 | li {
62 | list-style: none;
63 | text-align: left;
64 | overflow: hidden;
65 |
66 | a {
67 | position: relative;
68 | color: $fourth-color;
69 | display: block;
70 | width: 100%;
71 | height: 100%;
72 | font-size: $m-font-size;
73 | text-transform: uppercase;
74 | text-decoration: none;
75 | text-align: center;
76 | line-height: $x-font-size !important;
77 | cursor: pointer;
78 | transition: 0.3s ease-in-out all;
79 |
80 | &::before {
81 | content: '';
82 | position: absolute;
83 | bottom: 0;
84 | left: -150%;
85 | height: 2px;
86 | width: 100%;
87 | background-color: $fourth-color;
88 | transition: 0.2s ease-in-out all;
89 | }
90 |
91 | &:hover::before {
92 | left: 0;
93 | }
94 | }
95 | }
96 | }
97 | .hamburger {
98 | display: block;
99 | position: absolute;
100 | width: 35px;
101 | font-size: 1em;
102 | right: 1.5em;
103 | cursor: pointer;
104 |
105 | & .bar1,
106 | & .bar2,
107 | & .bar3 {
108 | width: 35px;
109 | height: 5px;
110 | margin: 6px 0;
111 | -webkit-transition: 0.4s;
112 | transition: 0.4s;
113 | color: $fourth-color;
114 | background-color: $fourth-color;
115 | }
116 |
117 | & .bar1Change {
118 | width: 35px;
119 | transform: rotate(-45deg) translate(-9px, 6px);
120 | }
121 |
122 | & .bar2Change {
123 | width: 35px;
124 | opacity: 0;
125 | }
126 |
127 | & .bar3Change {
128 | width: 35px;
129 | transform: rotate(45deg) translate(-8px, -8px);
130 | }
131 | }
132 | .menuShow {
133 | // visibility: visible;
134 | display: flex;
135 | }
136 | }
137 |
138 | @media (orientation: landscape) and (min-width: 1024px) {
139 | .nav {
140 | .menu {
141 | display: flex;
142 | flex-direction: row;
143 | border: none;
144 | li {
145 | width: 200px;
146 | margin-right: 10px;
147 | overflow: visible;
148 |
149 | a {
150 | @include button;
151 | font-size: $x-font-size;
152 | line-height: 30px !important;
153 |
154 | &::before {
155 | display: none;
156 | }
157 | }
158 | }
159 | }
160 |
161 | .hamburger {
162 | display: none;
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/frontend/src/components/LoginInfo/LoginInfo.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3 | import { faSignInAlt, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
4 |
5 | import { NavLink } from 'react-router-dom';
6 |
7 | import { StoreContext } from '../../store/StoreProvider';
8 | import styles from './LoginInfo.module.scss';
9 |
10 | const LoginInfo = () => {
11 | const { userData, setUserData } = useContext(StoreContext);
12 |
13 | const Logut = (e) => {
14 | e.preventDefault();
15 | setUserData({
16 | username: null,
17 | email: null,
18 | isLogged: false,
19 | token: null,
20 | });
21 |
22 | localStorage.removeItem('LogAppUser');
23 | };
24 |
25 | return (
26 |
27 | {!userData.isLogged ? (
28 |
29 | Zaloguj się
30 |
31 | ) : (
32 |
33 |
34 | Witaj {userData.username}
35 |
36 |
37 | )}
38 |
39 | );
40 | };
41 |
42 | export default LoginInfo;
43 |
--------------------------------------------------------------------------------
/frontend/src/components/LoginInfo/LoginInfo.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../views/Root/common.scss';
2 |
3 | .loginInfo {
4 | position: absolute;
5 | margin-right: 15px;
6 | top: 17px;
7 | right: 69px;
8 |
9 | @media (orientation: landscape) and (min-width: 1024px) {
10 | right: 20px;
11 | }
12 | & .link {
13 | text-decoration: none;
14 | color: $text-first-color;
15 | & a {
16 | text-decoration: none;
17 | color: $text-first-color;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/frontend/src/components/Message/Message.jsx:
--------------------------------------------------------------------------------
1 | /* eslint-disable react/no-array-index-key */
2 | import React from 'react';
3 | import PropTypes from 'prop-types';
4 | import styles from './Message.module.scss';
5 |
6 | const Message = ({ message, alert }) => {
7 | return (
8 |
9 | {Array.isArray(message) ? message.map((v, i) =>
{v}
) : message}
10 |
11 | );
12 | };
13 | // Definiuje domyślne wartości dla właściwości:
14 | Message.defaultProps = {
15 | alert: false,
16 | };
17 |
18 | Message.propTypes = {
19 | message: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)])
20 | .isRequired,
21 | alert: PropTypes.bool,
22 | };
23 |
24 | export default Message;
25 |
--------------------------------------------------------------------------------
/frontend/src/components/Message/Message.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../views/Root/common.scss';
2 |
3 | .message {
4 | position: fixed;
5 | display: flex;
6 | flex-direction: column;
7 | align-items: center;
8 | justify-content: center;
9 | width: 100%;
10 | min-height: 50px;
11 | top: -100%;
12 | left: 0;
13 | text-align: center;
14 | background-color: green;
15 | animation: messageAnimation 5s linear;
16 | animation-iteration-count: 1;
17 | animation-direction: normal;
18 | animation-fill-mode: both;
19 | box-shadow: 0px 5px 14px 0px rgba(0, 0, 0, 0.54);
20 | z-index: 999;
21 | }
22 |
23 | @keyframes messageAnimation {
24 | 0% {
25 | top: -100%;
26 | }
27 | 20% {
28 | top: 0;
29 | }
30 | 80% {
31 | top: 0;
32 | }
33 | 100% {
34 | top: -100%;
35 | }
36 | }
37 |
38 | .messageAlert {
39 | background-color: red;
40 | }
41 |
--------------------------------------------------------------------------------
/frontend/src/components/Modal/Modal.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useRef } from "react";
2 | import ReactDOM from "react-dom";
3 |
4 | const Modal = ({
5 | children,
6 | handleOnClose,
7 | isOpen,
8 | shouldBeClosedOnOutsideClick,
9 | }) => {
10 | const modalRef = useRef(null);
11 | const previousActiveElement = useRef(null);
12 |
13 | useEffect(() => {
14 | if (!modalRef) {
15 | return;
16 | }
17 | const { current: modal } = modalRef;
18 |
19 | if (isOpen) {
20 | previousActiveElement.current = document.activeElement;
21 | modal.showModal();
22 | } else if (previousActiveElement.current) {
23 | modal.close();
24 | previousActiveElement.current.focus();
25 | }
26 | }, [isOpen]);
27 |
28 | useEffect(() => {
29 | const { current: modal } = modalRef;
30 |
31 | const handleCancel = (event) => {
32 | event.preventDefauldt();
33 | handleOnClose();
34 | };
35 |
36 | modal.addEventListener("cancel", handleCancel);
37 |
38 | return () => {
39 | modal.removeEventListener("cancel", handleCancel);
40 | };
41 | }, [handleOnClose]);
42 |
43 | const handleOutsideClick = ({ target }) => {
44 | const { current } = modalRef;
45 |
46 | if (shouldBeClosedOnOutsideClick && target === current) {
47 | handleOnClose();
48 | }
49 | };
50 |
51 | return ReactDOM.createPortal(
52 | ,
55 | document.body
56 | );
57 | };
58 |
59 | export default Modal;
60 |
--------------------------------------------------------------------------------
/frontend/src/components/ReturnButton/ReturnButton.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { useHistory } from 'react-router-dom';
3 | import styles from './ReturnButton.module.scss';
4 |
5 | const ReturnButton = () => {
6 | const history = useHistory();
7 | const handleOnClick = () => history.goBack();
8 | return (
9 |
12 | );
13 | };
14 |
15 | export default ReturnButton;
16 |
--------------------------------------------------------------------------------
/frontend/src/components/ReturnButton/ReturnButton.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../views/Root/common.scss';
2 | .returnButton {
3 | @include button($first-color);
4 | background-color: $first-color;
5 | &:hover {
6 | color: $text-first-color;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/src/components/Spinner/Spinner.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { usePromiseTracker } from 'react-promise-tracker';
3 | import Loader from 'react-loader-spinner';
4 | import styles from './Spinner.module.scss';
5 |
6 | const Spinner = () => {
7 | const { promiseInProgress } = usePromiseTracker();
8 | return (
9 | <>
10 | {promiseInProgress && (
11 |
12 |
13 |
14 | )}
15 | >
16 | );
17 | };
18 | export default Spinner;
19 |
--------------------------------------------------------------------------------
/frontend/src/components/Spinner/Spinner.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../views/Root/common.scss';
2 | @import '../../../node_modules/react-loader-spinner/dist/loader/css/react-spinner-loader.css';
3 |
4 | .loader {
5 | position: fixed;
6 | display: flex;
7 | justify-content: center;
8 | align-items: center;
9 | background-color: rgba(0, 0, 0, 0.3);
10 | width: 100%;
11 | height: 100%;
12 | z-index: 9999;
13 | }
14 |
--------------------------------------------------------------------------------
/frontend/src/helpers/helpers.jsx:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/prefer-default-export */
2 | import { useState, useDebugValue } from 'react';
3 |
4 | export const useStateWithLabel = (name, initialValue) => {
5 | const [value, setValue] = useState(initialValue);
6 | useDebugValue(`${name}: ${value}`);
7 | return [value, setValue];
8 | };
9 |
10 | export const checkEmail = (email = false) => {
11 | // don't remember from where i copied this code, but this works.
12 | const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
13 |
14 | return re.test(email);
15 | };
16 |
17 | export const isLogged = () => {
18 | return JSON.parse(localStorage.getItem('LogAppUser')) || false;
19 | };
20 |
--------------------------------------------------------------------------------
/frontend/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './views/Root/index.scss';
4 | import Root from './views/Root/Root';
5 | import Spiner from './components/Spinner/Spinner';
6 | import * as serviceWorker from './serviceWorker';
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 | ,
13 | document.getElementById('root'),
14 | );
15 |
16 | // If you want your app to work offline and load faster, you can change
17 | // unregister() to register() below. Note this comes with some pitfalls.
18 | // Learn more about service workers: https://bit.ly/CRA-PWA
19 | serviceWorker.unregister();
20 |
--------------------------------------------------------------------------------
/frontend/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { 'Service-Worker': 'script' },
105 | })
106 | .then(response => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get('content-type');
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf('javascript') === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then(registration => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | 'No internet connection found. App is running in offline mode.'
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ('serviceWorker' in navigator) {
133 | navigator.serviceWorker.ready
134 | .then(registration => {
135 | registration.unregister();
136 | })
137 | .catch(error => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/frontend/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/frontend/src/store/StoreProvider.jsx:
--------------------------------------------------------------------------------
1 | import React, { createContext } from 'react';
2 | import { useStateWithLabel } from '../helpers/helpers';
3 |
4 | import Message from '../components/Message/Message';
5 |
6 | const VECHICLES_DATA = [
7 | { name: 'BUS', dim: [420, 220, 220] },
8 | { name: 'SOLO', dim: [1200, 250, 250] },
9 | { name: 'NACZEPA', dim: [1360, 250, 275] },
10 | ];
11 |
12 | // const LOADS_DATA = [];
13 | export const StoreContext = createContext(null);
14 |
15 | const StoreProvider = (props) => {
16 | // Vehicles
17 | const [vechicleData, setVechicleData] = useStateWithLabel('vechicleData', null);
18 | const [takeVechicle, setTakeVechicle] = useStateWithLabel('takeVechicle', false);
19 |
20 | // Load
21 |
22 | const [loadData, setLoadData] = useStateWithLabel('loadData', null);
23 | const [takeLoad, setTakeLoad] = useStateWithLabel('takeLoad', false);
24 |
25 | // Menu
26 | const [isOpenMenu, setIsOpenMenu] = useStateWithLabel('isOpenMenu', false);
27 |
28 | // User data
29 | const [userData, setUserData] = useStateWithLabel('userData', {
30 | username: null,
31 | email: null,
32 | isLogged: false,
33 | token: null,
34 | });
35 |
36 | // Message
37 | const [isVisibleMessage, setIsVisibleMessage] = useStateWithLabel('isVisibleMessage', false);
38 | const [messageText, setMessageText] = useStateWithLabel('messageText', '');
39 | const [isMessageAlert, setIsMessageAlert] = useStateWithLabel('isMessageAlert', false);
40 |
41 | // Router links
42 | const routerLinks = [
43 | { name: 'start', path: '/', exact: true },
44 | { name: 'kontakt', path: '/contact' },
45 | { name: 'pomoc', path: '/help' },
46 | ];
47 |
48 | const takeVechicleData = () => {
49 | if (takeVechicle === false) {
50 | return;
51 | }
52 | const datas = VECHICLES_DATA.map((data) => {
53 | if (data.name === takeVechicle) {
54 | return ` ${data.name} / dł: ${data.dim[0] / 100}m / szer: ${
55 | data.dim[1] / 100
56 | }m / wys: ${data.dim[2] / 100}m`;
57 | }
58 | });
59 | setVechicleData(datas);
60 | setTakeVechicle(true);
61 | };
62 |
63 | const showMessage = (text, isAlert) => {
64 | setMessageText(text);
65 | setIsMessageAlert(isAlert);
66 | setIsVisibleMessage(true);
67 |
68 | setTimeout(() => {
69 | setIsVisibleMessage(false);
70 | }, 5000);
71 | };
72 |
73 | return (
74 |
92 | {isVisibleMessage ? : ''}
93 | {props.children}
94 |
95 | );
96 | };
97 |
98 | export default StoreProvider;
99 |
--------------------------------------------------------------------------------
/frontend/src/views/Contact/Contact.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './Contact.module.scss';
3 |
4 | const ContactPage = () => {
5 | return (
6 |
7 |
Contact_Page
8 |
9 | );
10 | };
11 |
12 | export default ContactPage;
13 |
--------------------------------------------------------------------------------
/frontend/src/views/Contact/Contact.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .wrapper {
3 | margin: 100px auto;
4 | h1 {
5 | text-align: center;
6 | }
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/frontend/src/views/Error/Error.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './Error.module.scss';
3 | import img404 from '../../assets/images/404.png';
4 |
5 | const ErrorPage = () => {
6 | return (
7 |
8 |
9 |
404
10 |
Niestety nie znaleziono strony.
11 |
12 |

13 |
14 | );
15 | };
16 |
17 | export default ErrorPage;
18 |
--------------------------------------------------------------------------------
/frontend/src/views/Error/Error.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 |
3 | .wrapper {
4 | display: flex;
5 | flex-direction: column;
6 |
7 | align-items: center;
8 |
9 | @media (orientation: landscape) and (min-width: 1024px) {
10 | flex-direction: row-reverse;
11 | justify-content: center;
12 | align-items: flex-end;
13 | }
14 |
15 | .info {
16 | display: flex;
17 | flex-direction: column;
18 | align-items: center;
19 | justify-content: flex-start;
20 | & h1 {
21 | font-size: $l-font-size * 4;
22 | margin: 0;
23 | margin-bottom: 0.3em;
24 | text-align: center;
25 | text-shadow: 3px 3px 12px #000000;
26 | @media (orientation: landscape) and (min-width: 1024px) {
27 | font-size: $l-font-size * 5;
28 | }
29 | }
30 | & p {
31 | font-size: $m-font-size * 1.2;
32 | text-align: center;
33 | }
34 | }
35 | img {
36 | margin: 1em 0 0 0;
37 |
38 | @media (orientation: landscape) and (min-width: 1024px) {
39 | margin: 0 40px 0 0;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/frontend/src/views/Footer/Footer.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './Footer.module.scss';
3 |
4 | const Footer = () => {
5 | return ;
6 | };
7 |
8 | export default Footer;
9 |
--------------------------------------------------------------------------------
/frontend/src/views/Footer/Footer.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 |
3 | .wrapper {
4 | display: flex;
5 | }
6 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/FreeStart.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './FreeStart.module.scss';
3 |
4 | import VechicleDetails from './subcomponents/VechicleDetails';
5 | import LoadDetails from './subcomponents/LoadsDetails';
6 | import ReturnButton from '../../components/ReturnButton/ReturnButton';
7 |
8 | const FreeStartPage = () => {
9 | return (
10 |
11 |
Free-Start
12 |
13 | To wersja bez logowania, po wyjściu Twoja praca zostanie utracona. Zaloguj się aby
14 | zapisywać swoją pracę.
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | );
30 | };
31 |
32 | export default FreeStartPage;
33 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/FreeStart.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .freeStart {
3 | position: relative;
4 | width: 95vw;
5 | margin: -20px auto 0 auto;
6 | text-align: center;
7 | .main {
8 | width: 100%;
9 | height: 900px;
10 | display: flex;
11 | flex-direction: column;
12 | .vechicleDetails,
13 | .infoDetails,
14 | .loadDetails {
15 | flex-basis: 33%;
16 | @include element;
17 | }
18 | }
19 | .returnButton {
20 | position: absolute;
21 | margin-bottom: 20px;
22 | bottom: -70px;
23 | right: 0;
24 | }
25 | @media (orientation: landscape) and (min-width: 1024px) {
26 | margin: -70px auto 0 auto;
27 | .main {
28 | flex-direction: row;
29 | height: auto;
30 | }
31 | .returnButton {
32 | bottom: -80px;
33 | right: 50px;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/InfoDetails.jsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logappopen/Log_app/4c22d52c01f5df123481e69105b8b60091bf9370/frontend/src/views/FreeStart/subcomponents/InfoDetails.jsx
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/LoadDetails.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../Root/common.scss';
2 |
3 | .loadDetails {
4 | // margin: 100px;
5 | button {
6 | @include button;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/LoadInfo.js:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 |
3 | import { StoreContext } from '../../../store/StoreProvider';
4 |
5 | const LoadInfo = () => {
6 | const { loadData } = useContext(StoreContext);
7 |
8 | return (
9 |
10 |
{loadData ? `Wybrany pojazd:${loadData}` : null}
11 |
12 | );
13 | };
14 |
15 | export default LoadInfo;
16 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/LoadPopup.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | // import PropTypes from 'prop-types';
3 |
4 | import Modal from '../../../components/Modal/Modal';
5 | import { StoreContext } from '../../../store/StoreProvider';
6 |
7 | import styles from './LoadPopup.module.scss';
8 |
9 | const LoadPopup = ({ isPopupOpen, hidePopup }) => {
10 | return (
11 |
12 |
13 |
46 |
47 |
48 | );
49 | };
50 |
51 | // VechiclePopup.propTypes = {
52 | // isPopupOpen: PropTypes.bool.isRequired,
53 | // hidePopup: PropTypes.func.isRequired,
54 | // };
55 |
56 | export default LoadPopup;
57 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/LoadPopup.module.scss:
--------------------------------------------------------------------------------
1 | @import '../../Root/common.scss';
2 |
3 | .LoadPopup {
4 | position: fixed;
5 | top: 50%;
6 | left: 50%;
7 | transform: translate(-50%, -50%);
8 | width: 280px;
9 | height: 520px;
10 | background-color: $text-third-color;
11 | @include button;
12 | form {
13 | display: flex;
14 | flex-direction: column;
15 | justify-content: space-around;
16 | height: 100%;
17 | label {
18 | display: flex;
19 | justify-content: space-between;
20 | align-items: center;
21 | margin: 20px 0 5px 0;
22 | }
23 | input {
24 | width: 80px;
25 | }
26 | button {
27 | @include button($first-color);
28 | background-color: $first-color;
29 | &:hover {
30 | color: $text-first-color;
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/LoadsDetails.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useState } from 'react';
2 | import { StoreContext } from '../../../store/StoreProvider';
3 |
4 | import LoadPopup from './LoadPopup';
5 |
6 | import LoadInfo from './LoadInfo';
7 |
8 | import styles from './LoadDetails.module.scss';
9 |
10 | const LoadDetails = () => {
11 | const [isPopupOpen, setIsPopupOpen] = useState(false);
12 |
13 | const showPopup = () => {
14 | setIsPopupOpen(true);
15 | };
16 |
17 | const hidePopup = (event) => {
18 | if (event) {
19 | event.preventDefault();
20 | }
21 | setIsPopupOpen(false);
22 | };
23 | return (
24 |
25 |
26 |
27 |
28 |
29 | );
30 | };
31 | export default LoadDetails;
32 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/VechicleDetails.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useState } from 'react';
2 | import { StoreContext } from '../../../store/StoreProvider';
3 |
4 | import VechiclePopup from './VechiclePopup';
5 |
6 | import VechicleInfo from './VechicleInfo';
7 |
8 | import styles from './VechicleDetails.module.scss';
9 |
10 | const VechicleDetails = () => {
11 | const [isPopupOpen, setIsPopupOpen] = useState(false);
12 |
13 | const takeVechicle = useContext(StoreContext);
14 |
15 | const showPopup = () => {
16 | setIsPopupOpen(true);
17 | };
18 | const hidePopup = (event) => {
19 | if (event) {
20 | event.preventDefault();
21 | }
22 | setIsPopupOpen(false);
23 | };
24 |
25 | return (
26 |
27 |
30 |
31 |
32 |
33 | );
34 | };
35 | export default VechicleDetails;
36 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/VechicleDetails.module.scss:
--------------------------------------------------------------------------------
1 | @import "../../Root/common.scss";
2 |
3 | .vechicleDetails {
4 | // margin: 100px;
5 | button {
6 | @include button;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/VechicleInfo.js:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 |
3 | import { StoreContext } from '../../../store/StoreProvider';
4 |
5 | const VechicleInfo = () => {
6 | const { vechicleData } = useContext(StoreContext);
7 |
8 | return (
9 |
10 |
{vechicleData ? `Wybrany pojazd:${vechicleData}` : 'Nie wybrano pojazdu'}
11 |
12 | );
13 | };
14 |
15 | export default VechicleInfo;
16 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/VechiclePopup.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import Modal from '../../../components/Modal/Modal';
5 | import { StoreContext } from '../../../store/StoreProvider';
6 |
7 | import styles from './VechiclePopup.module.scss';
8 |
9 | const VechiclePopup = ({ isPopupOpen, hidePopup }) => {
10 | const { setTakeVechicle, takeVechicleData } = useContext(StoreContext);
11 |
12 | const handlOnSendData = () => {
13 | takeVechicleData();
14 | hidePopup();
15 | };
16 |
17 | const handleOnChange = (event) => {
18 | setTakeVechicle(event.target.value);
19 | };
20 |
21 | return (
22 |
23 |
24 |
59 |
60 |
61 | );
62 | };
63 |
64 | VechiclePopup.propTypes = {
65 | isPopupOpen: PropTypes.bool.isRequired,
66 | hidePopup: PropTypes.func.isRequired,
67 | };
68 |
69 | export default VechiclePopup;
70 |
--------------------------------------------------------------------------------
/frontend/src/views/FreeStart/subcomponents/VechiclePopup.module.scss:
--------------------------------------------------------------------------------
1 | @import "../../Root/common.scss";
2 |
3 | .vechiclePopup {
4 | position: fixed;
5 | top: 50%;
6 | left: 50%;
7 | transform: translate(-50%, -50%);
8 | width: 250px;
9 | height: 300px;
10 | background-color: $text-third-color;
11 | @include button;
12 | form {
13 | display: flex;
14 | flex-direction: column;
15 | justify-content: space-around;
16 | height: 100%;
17 | label {
18 | display: flex;
19 | justify-content: space-between;
20 | align-items: center;
21 | }
22 | button {
23 | @include button($first-color);
24 | background-color: $first-color;
25 | &:hover {
26 | color: $text-first-color;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/frontend/src/views/Help/Help.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styles from './Help.modules.scss';
3 |
4 | const HelpPage = () => {
5 | return (
6 |
7 |
Help_Page
8 |
9 | );
10 | };
11 |
12 | export default HelpPage;
13 |
--------------------------------------------------------------------------------
/frontend/src/views/Help/Help.modules.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .wrapper {
3 | margin: 100px auto;
4 | h1 {
5 | text-align: center;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/frontend/src/views/Home/Home.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { BrowserRouter as Router } from 'react-router-dom';
3 | import styles from './Home.module.scss';
4 | import StoreProvider from '../../store/StoreProvider';
5 |
6 | import Header from '../../components/Header/Header';
7 | import Main from '../Main/Main';
8 | import Footer from '../Footer/Footer';
9 |
10 | const Home = () => {
11 | return (
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | );
28 | };
29 |
30 | export default Home;
31 |
--------------------------------------------------------------------------------
/frontend/src/views/Home/Home.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .container {
3 | display: flex;
4 | flex-direction: column;
5 | flex-wrap: nowrap;
6 | flex-grow: 1;
7 | width: 100vw;
8 | height: 100vh;
9 | margin: 0 auto;
10 | & .header {
11 | flex-basis: 20%;
12 | }
13 | & .section {
14 | flex-basis: 60%;
15 | }
16 | & .footer {
17 | flex-basis: 10%;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/frontend/src/views/Login/Login.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import { NavLink, Redirect } from 'react-router-dom';
3 | import axios from 'axios';
4 | import { trackPromise } from 'react-promise-tracker';
5 | import styles from './Login.module.scss';
6 |
7 | import { StoreContext } from '../../store/StoreProvider';
8 | import { useStateWithLabel, checkEmail, isLogged } from '../../helpers/helpers';
9 | import ReturnButton from '../../components/ReturnButton/ReturnButton';
10 |
11 | const LoginPage = () => {
12 | const [email, setEmail] = useStateWithLabel('email', '');
13 | const [isValidEmail, setIsValidEmail] = useStateWithLabel('isValidemail', false);
14 | const [password, setPassword] = useStateWithLabel('password', '');
15 |
16 | const { setUserData, showMessage } = useContext(StoreContext);
17 |
18 | const handleOnPushEmail = (e) => {
19 | setIsValidEmail(checkEmail(e.target.value));
20 | setEmail(e.target.value);
21 | };
22 |
23 | const sendCredentials = () => {
24 | trackPromise(
25 | axios
26 | .post(process.env.REACT_APP_API_LOGIN_URL, {
27 | email,
28 | password,
29 | })
30 | .then(({ data }) => {
31 | // console.log(data)
32 | localStorage.setItem(
33 | 'LogAppUser',
34 | JSON.stringify({
35 | isLogged: true,
36 | id: data.user.id,
37 | username: data.user.username,
38 | email: data.user.email,
39 | token: data.token,
40 | }),
41 | );
42 | return data;
43 | })
44 | .then((data) => {
45 | setUserData({
46 | username: data.user.username,
47 | email: data.user.email,
48 | isLogged: true,
49 | token: data.token,
50 | });
51 |
52 | return data;
53 | })
54 | .then((data) => {
55 | console.log(data);
56 |
57 | isLogged();
58 | showMessage(`Zalogowałeś się poprawnie jako ${data.user.username}`);
59 | })
60 | .catch((error) => {
61 | setUserData({
62 | username: null,
63 | email: null,
64 | isLogged: false,
65 | token: null,
66 | });
67 | localStorage.removeItem('LogAppUser');
68 | const errorsMsg = [`Wystąpiły błędy podczas logowania:`];
69 |
70 | Object.keys(error.response.data).map((v) => {
71 | return errorsMsg.push(error.response.data[v][0]);
72 | });
73 | showMessage(errorsMsg, true);
74 | }),
75 | );
76 | };
77 |
78 | const handleOnPushPassword = (e) => {
79 | setPassword(e.target.value);
80 | };
81 |
82 | const handleOnClickLogin = (e) => {
83 | e.preventDefault();
84 |
85 | const errorsMsg = [`Wypełnij poprawnie formularz:`];
86 |
87 | if (isValidEmail) {
88 | console.log('Wpisano poprawny email');
89 | sendCredentials();
90 | } else {
91 | console.log('Wpisano błędny email');
92 | errorsMsg.push(`Wpisz poprawny email`);
93 | }
94 |
95 | if (!password.length) errorsMsg.push(`Wpisz hasło.`);
96 | showMessage(errorsMsg, true);
97 | };
98 |
99 | if (isLogged()) {
100 | return ;
101 | }
102 | return (
103 |
104 |
124 |
129 |
130 |
131 |
132 |
133 | );
134 | };
135 |
136 | export default LoginPage;
137 |
--------------------------------------------------------------------------------
/frontend/src/views/Login/Login.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .sectionLogin {
3 | position: relative;
4 | width: 95vw;
5 | margin: 10px auto;
6 | display: flex;
7 | align-items: center;
8 | flex-direction: column;
9 | .form {
10 | margin: 0 auto;
11 | }
12 | .nav {
13 | ul {
14 | // margin-top: 30px;
15 | list-style: none;
16 | text-align: center;
17 | a {
18 | text-decoration: none;
19 | color: $text-first-color;
20 | cursor: pointer;
21 | }
22 | }
23 | }
24 | .returnButton {
25 | position: absolute;
26 | bottom: -50px;
27 | right: 0;
28 | }
29 | @media (orientation: landscape) and (min-width: 1024px) {
30 | .nav {
31 | ul {
32 | margin-top: 30px;
33 | }
34 | }
35 | .returnButton {
36 | bottom: -150px;
37 | right: 50px;
38 | }
39 | }
40 | }
41 |
42 | .form {
43 | display: flex;
44 | flex-direction: column;
45 | justify-content: flex-start;
46 | align-items: center;
47 |
48 | .input {
49 | @include input;
50 | }
51 | .button {
52 | @include button;
53 | }
54 | @media (orientation: landscape) and (min-width: 1024px) {
55 | width: 30%;
56 |
57 | .input {
58 | height: 50px;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/frontend/src/views/LostPassword/LostPassword.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import ReturnButton from '../../components/ReturnButton/ReturnButton';
3 | import styles from './LostPassword.module.scss';
4 |
5 | const EMAILS = [];
6 |
7 | const LostPasswordPage = () => {
8 | const [viewMessage, setViewMessage] = useState('');
9 | const [emailValue, setEmailValue] = useState('');
10 |
11 | const handleOnPushEmail = (event) => {
12 | const eMail = event.target.value;
13 |
14 | if (eMail) {
15 | setEmailValue(eMail);
16 | EMAILS.push(eMail);
17 | }
18 | return null;
19 | };
20 | const handleOnClickLogin = () => {
21 | if (EMAILS.lenght > 0) {
22 | setViewMessage(`${viewMessage}na podanego maila został wysłany reset hasła`);
23 |
24 | // setTimeout(() => {
25 | // // setEmailValue("");
26 | // setViewMessage(viewMessage + "");
27 | // }, 4000);
28 | } else {
29 | setViewMessage(`${viewMessage}nie podano adresu eMail`);
30 | }
31 | };
32 |
33 | return (
34 |
54 | );
55 | };
56 |
57 | export default LostPasswordPage;
58 |
--------------------------------------------------------------------------------
/frontend/src/views/LostPassword/LostPassword.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .wrapper {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | width: 95vw;
7 | & .form {
8 | display: flex;
9 | flex-direction: column;
10 | align-items: center;
11 | width: 100%;
12 | & .label {
13 | display: flex;
14 | flex-direction: column;
15 | flex-basis: 30%;
16 | margin: 10px 2em;
17 | text-align: center;
18 | flex-basis: 70%;
19 | text-align: center;
20 |
21 | & .input {
22 | @include input;
23 | margin-top: 1em;
24 | }
25 | }
26 |
27 | & .button {
28 | @include button;
29 | }
30 | }
31 | & .info {
32 | text-align: center;
33 | color: $second-color;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/frontend/src/views/Main/Main.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Switch, Route } from 'react-router-dom';
3 |
4 | import StartPage from '../Start/Start';
5 | import ContactPage from '../Contact/Contact';
6 | import HelpPage from '../Help/Help';
7 | import LoginPage from '../Login/Login';
8 | import RegistrationPage from '../Registration/Registration';
9 | import FreeStartPage from '../FreeStart/FreeStart';
10 | import LostPasswordPage from '../LostPassword/LostPassword';
11 | import ErrorPage from '../Error/Error';
12 |
13 | const Main = () => {
14 | return (
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | );
26 | };
27 |
28 | export default Main;
29 |
--------------------------------------------------------------------------------
/frontend/src/views/Main/Main.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 |
--------------------------------------------------------------------------------
/frontend/src/views/Registration/Registration.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { NavLink, Redirect } from 'react-router-dom';
3 | import axios from 'axios';
4 |
5 | import { trackPromise } from 'react-promise-tracker';
6 | import styles from './Registration.module.scss';
7 |
8 | import { checkEmail, useStateWithLabel, isLogged } from '../../helpers/helpers';
9 | import ReturnButton from '../../components/ReturnButton/ReturnButton';
10 | import Message from '../../components/Message/Message';
11 |
12 | const RegistrationPage = () => {
13 | const [username, setUsername] = useStateWithLabel('username', '');
14 | const [email, setEmail] = useStateWithLabel('email', '');
15 | const [userPassword, setUserPassword] = useStateWithLabel('userPassword', '');
16 | const [userPasswordRepeat, setUserPasswordRepeat] = useStateWithLabel('userPasswordRepeat', '');
17 | const [isVisibleMessage, setIsVisibleMessage] = useStateWithLabel('isVisibleMessage', false);
18 | const [messageText, setMessageText] = useStateWithLabel('messageText', []);
19 | const [isMessageAlert, setIsMessageAlert] = useStateWithLabel('isMessageAlert', false);
20 |
21 | const showMessage = (text = messageText, isAlert) => {
22 | setMessageText(text);
23 | setIsMessageAlert(isAlert);
24 | setIsVisibleMessage(true);
25 |
26 | setTimeout(() => {
27 | setIsVisibleMessage(false);
28 | }, 5000);
29 | };
30 |
31 | const checkFrom = () => {
32 | const errors = [];
33 | const message = [];
34 |
35 | if (!email) {
36 | message.push('Brak email-a');
37 | errors.push(false);
38 | }
39 | if (!username) {
40 | message.push('Brak username');
41 | errors.push(false);
42 | }
43 | if (!userPassword) {
44 | message.push('Brak hasła');
45 | errors.push(false);
46 | }
47 | if (!userPasswordRepeat) {
48 | message.push('Brak powtórzenia hasła');
49 | errors.push(false);
50 | }
51 |
52 | if (userPassword !== userPasswordRepeat) {
53 | message.push('Hasła nie są jednakowe');
54 | errors.push(false);
55 | }
56 | if (!checkEmail(email)) {
57 | message.push('Email jest niepoprawny');
58 | errors.push(false);
59 | }
60 |
61 | return [!errors.length, message];
62 | };
63 |
64 | const sendCredentials = () => {
65 | trackPromise(
66 | axios
67 | .post(process.env.REACT_APP_API_REGISTER_URL, {
68 | username,
69 | email,
70 | password: userPassword,
71 | })
72 | .then(({ data }) => {
73 | console.log(data);
74 | showMessage(`Zarejestrowałeś się poprawnie jako ${data.user.username}`);
75 | return data;
76 | })
77 | .catch((error) => {
78 | console.log(error);
79 | console.log(error.response.data);
80 |
81 | const errorsMsg = [`Wystąpiły błędy w rejestracji:`];
82 |
83 | Object.keys(error.response.data).map((v) => {
84 | return errorsMsg.push(error.response.data[v][0]);
85 | });
86 | showMessage(errorsMsg, true);
87 | return error;
88 | }),
89 | );
90 | };
91 |
92 | const handleRegistration = (e) => {
93 | e.preventDefault();
94 | if (checkFrom()[0]) {
95 | sendCredentials();
96 | } else {
97 | showMessage(checkFrom()[1], true);
98 | }
99 | };
100 |
101 | if (isLogged()) {
102 | return ;
103 | }
104 | return (
105 |
106 |
Zarejestruj się
107 | {isVisibleMessage ?
: ''}
108 |
139 |
144 |
145 |
146 | );
147 | };
148 |
149 | export default RegistrationPage;
150 |
--------------------------------------------------------------------------------
/frontend/src/views/Registration/Registration.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .wrapper {
3 | position: relative;
4 | width: 95vw;
5 | margin: 30px auto;
6 | text-align: center;
7 | // &__return-button {
8 | // position: absolute;
9 | // bottom: -50px;
10 | // right: 0;
11 | // }
12 | // @media (orientation: landscape) and (min-width: 1024px) {
13 | // &__return-button {
14 | // bottom: -150px;
15 | // right: 50px;
16 | // }
17 | // }
18 | & .nav {
19 | ul {
20 | margin-top: 20px;
21 | list-style: none;
22 | text-align: center;
23 | a {
24 | text-decoration: none;
25 | color: $text-first-color;
26 | cursor: pointer;
27 | }
28 | }
29 | }
30 | }
31 | .form {
32 | display: flex;
33 | align-items: center;
34 | flex-direction: column;
35 | & .input {
36 | @include input // padding: 10px;
37 | // width: 100%;
38 | // color: white;
39 | // background: transparent;
40 | // border: none;
41 | // border-bottom: 1px solid #ccc;
42 | // max-width: 600px;
43 | // outline: none;
44 | // margin-bottom: 15px;
45 | // :placeholder {
46 | // color: white;
47 | // }
48 | ;
49 | }
50 | & .button {
51 | @include button // margin-top: 20px;
52 | // max-width: 150px;
53 | // background: white;
54 | // border: none;
55 | // color: #1b83de;
56 | // border-radius: 3px;
57 | // padding: 15px 30px;
58 | // text-transform: uppercase;
59 | // font-weight: 600;
60 | // outline: none;
61 | // cursor: pointer;
62 | // transition: 0.3s;
63 | // &:hover {
64 | // transform: scale(1.1);
65 | // }
66 | ;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/Root.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import 'normalize.css';
3 | import Home from '../Home/Home';
4 |
5 | const Root = () => {
6 | return (
7 |
8 |
9 |
10 | );
11 | };
12 |
13 | export default Root;
14 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/common.scss:
--------------------------------------------------------------------------------
1 | @import './variables';
2 | @import './mixins.scss';
3 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/index.scss:
--------------------------------------------------------------------------------
1 | @import './reset';
2 | @import './common';
3 |
4 | body {
5 | background-color: $basic-color;
6 | color: $text-first-color;
7 | }
8 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/mixins.scss:
--------------------------------------------------------------------------------
1 | @mixin neustyle(
2 | $color: $basic-color,
3 | $hover: true,
4 | $direction: topleft,
5 | $inset: false,
6 | $distance: 2px
7 | ) {
8 | border-radius: 20px;
9 | border: none;
10 | outline: none;
11 | $v: 2px;
12 |
13 | @if $distance {
14 | $v: $distance;
15 | }
16 |
17 | $topX: ($v * 2 * -1);
18 | $topY: ($v * 2 * -1);
19 |
20 | @if $direction == 'topcenter' {
21 | $topX: 0px;
22 | $topY: ($v * 2 * -1);
23 | }
24 | @if $direction == 'topright' {
25 | $topX: ($v * 2);
26 | $topY: ($v * 2 * -1);
27 | }
28 |
29 | $out: $topX $topY ($v * 3) lighten($color, 12),
30 | $topX * -1 $topY * -1 ($v * 3) darken($color, 12),
31 | inset $topX $topY ($v * 6) lighten($color, 0),
32 | inset $topX * -1 $topY * -1 ($v * 6) darken($color, 0);
33 |
34 | $in: $topX $topY ($v * 5) lighten($color, 0), $topX * -1 $topY * -1 ($v * 3) darken($color, 0),
35 | inset $topX $topY ($v * 6) lighten($color, 12),
36 | inset $topX/2 $topY/2 ($v) lighten($color, 12),
37 | inset $topX * -1 $topY * -1 ($v * 3) darken($color, 10);
38 |
39 | @if $inset {
40 | box-shadow: $in;
41 | } @else {
42 | box-shadow: $out;
43 | }
44 |
45 | @if $hover {
46 | &:hover {
47 | @if $inset {
48 | box-shadow: $out;
49 | } @else {
50 | box-shadow: $in;
51 | }
52 | }
53 | }
54 | }
55 |
56 | @mixin button(
57 | $color: $basic-color,
58 | $hover: true,
59 | $direction: topleft,
60 | $inset: false,
61 | $distance: 2px
62 | ) {
63 | margin: 20px 0;
64 | padding: 10px 20px;
65 | border: none;
66 | color: $text-first-color;
67 | background-color: $basic-color;
68 | @include neustyle($color, $hover, $direction, $inset, $distance);
69 | font-size: $m-font-size;
70 | cursor: pointer;
71 | transition: 0.3s;
72 | &:hover {
73 | color: $text-second-color;
74 | }
75 | }
76 |
77 | @mixin input(
78 | $color: $basic-color,
79 | $hover: false,
80 | $direction: topleft,
81 | $inset: true,
82 | $distance: 2px
83 | ) {
84 | @include neustyle($color, $hover, $direction, $inset, $distance);
85 | flex-basis: 90%;
86 | // height: 20px;
87 | line-height: 1.3em;
88 | background: transparent;
89 | margin: 0 1.5em;
90 | color: $text-first-color;
91 | padding: 12px;
92 | cursor: auto;
93 | &::placeholder {
94 | color: white;
95 | }
96 | }
97 | @mixin element($color: $basic-color, $direction: topright, $inset: false, $distance: 2px) {
98 | margin: 20px 0;
99 | padding: 10px 20px;
100 | border: none;
101 | color: $text-first-color;
102 | background-color: $basic-color;
103 | @include neustyle($color, $direction, $inset, $distance);
104 | font-size: $m-font-size;
105 | }
106 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/reset.scss:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');
2 |
3 | /* Box sizing rules */
4 | *,
5 | *::before,
6 | *::after {
7 | margin: 0;
8 | padding: 0;
9 | box-sizing: border-box;
10 | font-family: 'Lato', sans-serif;
11 | }
12 |
13 | /* Remove default padding */
14 | ul[class],
15 | ol[class] {
16 | padding: 0;
17 | }
18 |
19 | /* Remove default margin */
20 | body,
21 | h1,
22 | h2,
23 | h3,
24 | h4,
25 | p,
26 | ul[class],
27 | ol[class],
28 | li,
29 | figure,
30 | figcaption,
31 | blockquote,
32 | dl,
33 | dd {
34 | margin: 0;
35 | }
36 |
37 | /* Set core body defaults */
38 | body {
39 | min-height: 100vh;
40 | scroll-behavior: smooth;
41 | text-rendering: optimizeSpeed;
42 | line-height: 1.5;
43 | }
44 |
45 | /* Remove list styles on ul, ol elements with a class attribute */
46 | ul[class],
47 | ol[class] {
48 | list-style: none;
49 | }
50 |
--------------------------------------------------------------------------------
/frontend/src/views/Root/variables.scss:
--------------------------------------------------------------------------------
1 | $basic-color: #1b83de;
2 | $first-color: #3b0918;
3 | $second-color: #b8390e;
4 | $third-color: #d9ab30;
5 | $fourth-color: #00ebeb;
6 |
7 | $text-first-color: #fff;
8 | $text-second-color: #000;
9 | $text-third-color: #aaa;
10 |
11 | $s-font-size: 14px;
12 | $m-font-size: 18px;
13 | $l-font-size: 20px;
14 | $x-font-size: 24px;
15 |
--------------------------------------------------------------------------------
/frontend/src/views/Start/Start.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { NavLink } from 'react-router-dom';
3 | import styles from './Start.module.scss';
4 | import { isLogged } from '../../helpers/helpers';
5 |
6 | const list = [
7 | { name: 'logowanie', path: '/login', exact: true },
8 | { name: 'rejestracja', path: '/registration' },
9 | { name: 'szybki start', path: '/free_start' },
10 | ];
11 |
12 | const StartPage = () => {
13 | const menu = list.map((item) => {
14 | if ((item.name === 'logowanie' || item.name === 'rejestracja') && isLogged()) {
15 | return null;
16 | }
17 | return (
18 |
19 |
20 | {item.name}
21 |
22 |
23 | );
24 | });
25 |
26 | return (
27 | <>
28 |
33 | >
34 | );
35 | };
36 |
37 | export default StartPage;
38 |
--------------------------------------------------------------------------------
/frontend/src/views/Start/Start.module.scss:
--------------------------------------------------------------------------------
1 | @import '../Root/common.scss';
2 | .wrapper {
3 | margin: 50px auto;
4 | & .nav {
5 | width: 200px;
6 | height: 200px;
7 | margin: 0 auto;
8 | & .link {
9 | list-style: none;
10 | display: flex;
11 | flex-direction: column;
12 | justify-content: space-around;
13 | align-items: center;
14 | li a {
15 | display: block;
16 | width: 140px;
17 | height: 40px;
18 | margin: 10px;
19 | border: 1px solid $basic-color;
20 | text-decoration: none;
21 | text-transform: uppercase;
22 | text-align: center;
23 | color: $text-second-color;
24 | line-height: 40px;
25 | transition: 0.3s;
26 | }
27 | li a:hover {
28 | background-color: $basic-color;
29 | color: $text-first-color;
30 | }
31 | @media (orientation: landscape) and (min-width: 1024px) {
32 | li a {
33 | width: 160px;
34 | height: 50px;
35 | margin: 20px;
36 | line-height: 50px;
37 | font-size: $l-font-size;
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------