From d5e3c93520245232c28e34fbf8e31f9e3f93fd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Mon, 26 May 2025 21:40:51 +0300 Subject: [PATCH] Demo Talep Formu --- .../Demo/DemoAppService.cs | 60 ++++++++++++++ .../appsettings.json | 2 +- company/.env | 1 + company/.env.dev | 1 + company/.env.production | 1 + company/.gitignore | 1 - company/src/pages/Contact.tsx | 80 +++++++++++++++++-- company/src/pages/Home.tsx | 5 +- 8 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 api/src/Kurs.Platform.Application/Demo/DemoAppService.cs create mode 100644 company/.env create mode 100644 company/.env.dev create mode 100644 company/.env.production diff --git a/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs b/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs new file mode 100644 index 00000000..aaece1c7 --- /dev/null +++ b/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Kurs.Platform.Data.Seeds; +using Kurs.Sender.Mail; +using Volo.Abp.Settings; +using Volo.Abp.UI.Navigation.Urls; + +namespace Kurs.Platform.Dashboard; + +public class ContactFormDto +{ + public string Company { get; set; } + public string FullName { get; set; } + public string Email { get; set; } + public string Phone { get; set; } + public string Address { get; set; } + public string BranchCount { get; set; } + public string UserCount { get; set; } + public string Message { get; set; } +} + +public class DemoAppService : PlatformAppService +{ + private readonly ISettingProvider settingProvider; + private readonly IKursEmailSender emailSender; + + public DemoAppService( + ISettingProvider settingProvider, + IKursEmailSender emailSender + ) + { + this.settingProvider = settingProvider; + this.emailSender = emailSender; + } + + public async Task DemoFormAsync(ContactFormDto input) + { + var bodyBuilder = new StringBuilder(); + bodyBuilder.AppendLine($"Şirket: {input.Company}"); + bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}"); + bodyBuilder.AppendLine($"E-Posta: {input.Email}"); + bodyBuilder.AppendLine($"Telefon: {input.Phone}"); + bodyBuilder.AppendLine($"Adres: {input.Address}"); + bodyBuilder.AppendLine($"Şube Sayısı: {input.BranchCount}"); + bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.UserCount}"); + bodyBuilder.AppendLine($"Mesaj: {input.Message}"); + + var SenderName = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName); + var SenderEmailAddress = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress); + + await emailSender.QueueEmailAsync( + SenderEmailAddress, + new KeyValuePair(SenderName, SenderEmailAddress), + null, + bodyBuilder.ToString(), + subject: PlatformConsts.AppName + " : Demo Talebi"); + + } +} diff --git a/api/src/Kurs.Platform.HttpApi.Host/appsettings.json b/api/src/Kurs.Platform.HttpApi.Host/appsettings.json index cd574834..e66ea7c7 100644 --- a/api/src/Kurs.Platform.HttpApi.Host/appsettings.json +++ b/api/src/Kurs.Platform.HttpApi.Host/appsettings.json @@ -2,7 +2,7 @@ "App": { "SelfUrl": "https://localhost:44344", "ClientUrl": "http://localhost:3000", - "CorsOrigins": "http://localhost,http://localhost:3000,http://localhost:4200,http://localhost:5173", + "CorsOrigins": "http://localhost,http://localhost:3000,http://localhost:3003,http://localhost:4200,http://localhost:5173", "RedirectAllowedUrls": "http://localhost:4200,http://localhost:4200/authentication/callback", "AttachmentsPath": "C:\\Private\\Projects\\kurs-platform\\configs\\mail-queue\\attachments", "CdnPath": "C:\\Private\\Projects\\kurs-platform\\configs\\docker\\data\\cdn", diff --git a/company/.env b/company/.env new file mode 100644 index 00000000..8a5f9aa2 --- /dev/null +++ b/company/.env @@ -0,0 +1 @@ +VITE_API_BASE_URL='https://localhost:44344' \ No newline at end of file diff --git a/company/.env.dev b/company/.env.dev new file mode 100644 index 00000000..9e52720a --- /dev/null +++ b/company/.env.dev @@ -0,0 +1 @@ +VITE_API_BASE_URL='https://kurs-dev-api.sozsoft.com' diff --git a/company/.env.production b/company/.env.production new file mode 100644 index 00000000..c6242c12 --- /dev/null +++ b/company/.env.production @@ -0,0 +1 @@ +VITE_API_BASE_URL='https://kurs-api.sozsoft.com' diff --git a/company/.gitignore b/company/.gitignore index 7ceb59f8..a547bf36 100644 --- a/company/.gitignore +++ b/company/.gitignore @@ -22,4 +22,3 @@ dist-ssr *.njsproj *.sln *.sw? -.env diff --git a/company/src/pages/Contact.tsx b/company/src/pages/Contact.tsx index ea7f5040..2836408a 100644 --- a/company/src/pages/Contact.tsx +++ b/company/src/pages/Contact.tsx @@ -1,10 +1,8 @@ -import React from "react"; +import React, { useState } from "react"; import { Mail, Phone, MapPin, - Clock, - Globe, FileText, Building, CalendarDays, @@ -16,6 +14,62 @@ import { useLanguage } from "../context/LanguageContext"; const Contact: React.FC = () => { const { t } = useLanguage(); + const [formData, setFormData] = useState({ + company: "", + fullName: "", + email: "", + phone: "", + address: "", + branchCount: "", + userCount: "", + message: "", + }); + + const handleChange = ( + e: React.ChangeEvent + ) => { + const { name, value } = e.target; + setFormData((prev: any) => ({ + ...prev, + [name]: value, + })); + }; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + const apiUrl = `${import.meta.env.VITE_API_BASE_URL}/api/app/demo/demo-form`; + + try { + const response = await fetch(apiUrl, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(formData), + }); + + if (response.ok) { + alert("Form başarıyla gönderildi."); + setFormData({ + company: "", + fullName: "", + email: "", + phone: "", + address: "", + branchCount: "", + userCount: "", + message: "", + }); + } else { + alert("Bir hata oluştu. Lütfen tekrar deneyin."); + } + } catch (error) { + console.error("Gönderim hatası:", error); + alert("Sunucuya ulaşılamıyor."); + } + }; + return (
{/* Hero Section */} @@ -149,7 +203,7 @@ const Contact: React.FC = () => {

{t("demo.form.title")}

-
+
@@ -176,6 +232,8 @@ const Contact: React.FC = () => { type="text" id="fullName" name="fullName" + value={formData.fullName} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
@@ -193,6 +251,8 @@ const Contact: React.FC = () => { type="email" id="email" name="email" + value={formData.email} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
@@ -207,6 +267,8 @@ const Contact: React.FC = () => { type="tel" id="phone" name="phone" + value={formData.phone} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> @@ -223,6 +285,8 @@ const Contact: React.FC = () => { type="text" id="address" name="address" + value={formData.address} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> @@ -239,6 +303,8 @@ const Contact: React.FC = () => { type="number" id="branchCount" name="branchCount" + value={formData.branchCount} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> @@ -253,6 +319,8 @@ const Contact: React.FC = () => { type="number" id="userCount" name="userCount" + value={formData.userCount} + onChange={handleChange} className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> @@ -268,7 +336,9 @@ const Contact: React.FC = () => {