From 6f7d70ec8d896a8617f3429a8471d7de8425c838 Mon Sep 17 00:00:00 2001 From: femsci Date: Sat, 21 Oct 2023 22:18:14 +0200 Subject: [PATCH] Form minimum working draft & rework docker --- dev.Caddyfile | 2 +- dev.Dockerfile | 3 +- src/Nyanlabs.SFood.UI/sfood/index.html | 5 +- src/Nyanlabs.SFood.UI/sfood/src/App.tsx | 4 + .../sfood/src/pages/Submit.tsx | 120 ++++++++++++++++++ 5 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 src/Nyanlabs.SFood.UI/sfood/src/pages/Submit.tsx diff --git a/dev.Caddyfile b/dev.Caddyfile index ee21926..efb8463 100644 --- a/dev.Caddyfile +++ b/dev.Caddyfile @@ -1,6 +1,6 @@ http://localhost { reverse_proxy /api/* http://sfood_api:80 - reverse_proxy http://sfood_ui:80 + reverse_proxy http://sfood_ui:44420 } http://localhost:44420 { diff --git a/dev.Dockerfile b/dev.Dockerfile index 76d493e..e6dfa34 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -29,4 +29,5 @@ FROM base AS ui RUN apk add npm USER $USERNAME -ENTRYPOINT [ "dotnet", "watch", "--project", "./src/Nyanlabs.SFood.UI", "run", "--", "--urls", "http://0.0.0.0:80" ] +WORKDIR /source/src/Nyanlabs.SFood.UI/sfood +ENTRYPOINT [ "npm", "start" ] diff --git a/src/Nyanlabs.SFood.UI/sfood/index.html b/src/Nyanlabs.SFood.UI/sfood/index.html index 15a23fc..e1e6e4e 100644 --- a/src/Nyanlabs.SFood.UI/sfood/index.html +++ b/src/Nyanlabs.SFood.UI/sfood/index.html @@ -2,7 +2,7 @@ - BezpiecznaZywnosc + Bezpieczna Żywność @@ -18,9 +18,8 @@ - - + diff --git a/src/Nyanlabs.SFood.UI/sfood/src/App.tsx b/src/Nyanlabs.SFood.UI/sfood/src/App.tsx index 6033a6a..2a60eaf 100644 --- a/src/Nyanlabs.SFood.UI/sfood/src/App.tsx +++ b/src/Nyanlabs.SFood.UI/sfood/src/App.tsx @@ -21,6 +21,7 @@ import '@ionic/react/css/display.css'; /* Theme variables */ import './theme/variables.css'; +import Submit from './pages/Submit'; setupIonicReact(); @@ -34,6 +35,9 @@ const App: React.FC = () => ( + + + diff --git a/src/Nyanlabs.SFood.UI/sfood/src/pages/Submit.tsx b/src/Nyanlabs.SFood.UI/sfood/src/pages/Submit.tsx new file mode 100644 index 0000000..04e09da --- /dev/null +++ b/src/Nyanlabs.SFood.UI/sfood/src/pages/Submit.tsx @@ -0,0 +1,120 @@ +import { IonButton, IonContent, IonHeader, IonInput, IonItem, IonLabel, IonPage, IonTitle, IonToolbar } from '@ionic/react'; +import { FormEventHandler, useState } from 'react'; + +const IncidentForm: React.FC = () => { + const [formData, setFormData] = useState({ + name: '', + productName: '', + producer: '', + submitterAddress: '', + description: '', + location: '' + }); + +const handleSubmit: FormEventHandler = async (e) => { + e.preventDefault(); + + try { + const response = await fetch('/api/incident/submit', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(formData), + }); + + if (response.ok) { + console.log('Form submitted successfully.'); + } else { + console.error('Form submission failed.'); + } + } catch (error) { + console.error('Error:', error); + } + }; + + +const handleInputChange = (fieldName: any, value: any) => { + setFormData({ + ...formData, + [fieldName]: value, + }); + }; + + return ( + + + + Bezpieczna żywnosc + + + + + + Bezpieczna żywnosc + + +
+ + Imię + handleInputChange('name', e.detail.value)} + /> + + + + Nazwa produktu + handleInputChange('productName', e.detail.value)} + /> + + + + Producent + handleInputChange('producer', e.detail.value)} + /> + + + + Lokalizacja + handleInputChange('location', e.detail.value)} + /> + + + + Opis + handleInputChange('description', e.detail.value)} + /> + + + + Adres e-mail + handleInputChange('submitterAddress', e.detail.value)} + /> + + + + Wyślij + +
+
+
+ ); +}; +export default IncidentForm;