Demo Talebi

This commit is contained in:
Sedat Öztürk 2025-08-17 23:05:40 +03:00
parent 284d0d777c
commit 9f33c896b9
15 changed files with 7253 additions and 217 deletions

View file

@ -0,0 +1,16 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Kurs.Platform.Demos;
public class DemoDto : FullAuditedEntityDto<Guid>
{
public string OrganizationName { get; set; }
public string FullName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public int NumberOfBranches { get; set; }
public int NumberOfUsers { get; set; }
public string Message { get; set; }
}

View file

@ -1,41 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Kurs.Platform.Data.Seeds;
using Kurs.Platform.Entities;
using Kurs.Sender.Mail;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Settings;
namespace Kurs.Platform.Dashboard;
public class ContactFormDto
{
public string OrganizationName { get; set; }
public string FullName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string NumberOfBranches { get; set; }
public string NumberOfUsers { get; set; }
public string Message { get; set; }
}
namespace Kurs.Platform.Demos;
public class DemoAppService : PlatformAppService
{
private readonly ISettingProvider settingProvider;
private readonly IKursEmailSender emailSender;
private readonly ISettingProvider _settingProvider;
private readonly IKursEmailSender _emailSender;
private readonly IRepository<Demo, Guid> _repository;
public DemoAppService(
ISettingProvider settingProvider,
IKursEmailSender emailSender
IKursEmailSender emailSender,
IRepository<Demo, Guid> repository
)
{
this.settingProvider = settingProvider;
this.emailSender = emailSender;
_settingProvider = settingProvider;
_emailSender = emailSender;
_repository = repository;
}
public async Task DemoFormAsync(ContactFormDto input)
[AllowAnonymous]
public async Task CreateDemoAsync(DemoDto input)
{
var demo = ObjectMapper.Map<DemoDto, Demo>(input);
await _repository.InsertAsync(demo);
var bodyBuilder = new StringBuilder();
bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}");
bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}");
@ -46,10 +44,10 @@ public class DemoAppService : PlatformAppService
bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}");
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);
var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
await emailSender.QueueEmailAsync(
await _emailSender.QueueEmailAsync(
SenderEmailAddress,
new KeyValuePair<string, string>(SenderName, SenderEmailAddress),
null,

View file

@ -0,0 +1,12 @@
using AutoMapper;
using Kurs.Platform.Entities;
namespace Kurs.Platform.Demos;
public class DemoAutoMapperProfile : Profile
{
public DemoAutoMapperProfile()
{
CreateMap<Demo, DemoDto>().ReverseMap();
}
}

View file

@ -13576,6 +13576,310 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
}
#endregion
#region Demos
if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.Demo))
{
var listFormDemo = await _listFormRepository.InsertAsync(
new ListForm
{
CultureName = LanguageCodes.En,
ListFormCode = ListFormCodes.Lists.Demo,
Name = AppCodes.Demos,
Title = AppCodes.Demos,
DataSourceCode = SeedConsts.DataSources.DefaultCode,
IsTenant = false,
IsBranch = false,
IsOrganizationUnit = false,
Description = AppCodes.Demos,
SelectCommandType = SelectCommandTypeEnum.Table,
SelectCommand = SelectCommandByTableName("Demo"),
KeyFieldName = "Id",
KeyFieldDbSourceType = DbType.Guid,
SortMode = GridOptions.SortModeSingle,
FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto { Visible = true }),
HeaderFilterJson = JsonSerializer.Serialize(new { Visible = true }),
SearchPanelJson = JsonSerializer.Serialize(new { Visible = true }),
GroupPanelJson = JsonSerializer.Serialize(new { Visible = false }),
SelectionJson = JsonSerializer.Serialize(new SelectionDto
{
Mode = GridOptions.SelectionModeSingle,
AllowSelectAll = false
}),
ColumnOptionJson = JsonSerializer.Serialize(new
{
ColumnFixingEnabled = true,
}),
PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
D = AppCodes.Demos + ".Delete",
E = AppCodes.Demos + ".Export",
I = AppCodes.Demos + ".Import"
}),
PagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto
{
Visible = true,
AllowedPageSizes = "10,20,50,100",
ShowPageSizeSelector = true,
ShowNavigationButtons = true,
ShowInfo = false,
InfoText = "Page {0} of {1} ({2} items)",
DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive,
ScrollingMode = GridColumnOptions.ScrollingModeStandard,
LoadPanelEnabled = "auto",
LoadPanelText = "Loading..."
}),
EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto
{
Popup = new GridEditingPopupDto
{
Title = "Demo Form",
Width = 500,
Height = 300
},
AllowDeleting = true,
AllowAdding = true,
AllowUpdating = true,
SendOnlyChangedFormValuesUpdate = false
}),
EditingFormJson = JsonSerializer.Serialize(new List<EditingFormDto>
{
new()
{
Order = 1,
ColCount = 1,
ColSpan = 2,
ItemType = "group",
Items =
[
new EditingFormItemDto { Order = 1, DataField = "Id", ColSpan = 2, IsRequired = true, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 2, DataField = "OrganizationName", ColSpan = 2, IsRequired = true, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 3, DataField = "FullName", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxTextArea },
new EditingFormItemDto { Order = 4, DataField = "Email", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 5, DataField = "Phone", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 6, DataField = "Address", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxTextArea },
new EditingFormItemDto { Order = 7, DataField = "NumberOfBranches", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxNumberBox },
new EditingFormItemDto { Order = 8, DataField = "NumberOfUsers", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxNumberBox },
new EditingFormItemDto { Order = 9, DataField = "Message", ColSpan = 2, IsRequired = false, EditorType2 = EditorTypes.dxTextArea },
]
}
})
});
#region Report Categories Fields
await _listFormFieldRepository.InsertManyAsync([
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Guid,
FieldName = "Id",
Width = 100,
ListOrderNo = 1,
Visible = false,
IsActive = true,
IsDeleted = false,
ValidationRuleJson = JsonSerializer.Serialize(new[]
{
new ValidationRuleDto { Type = "required" }
}),
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "OrganizationName",
Width = 200,
ListOrderNo = 2,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ValidationRuleJson = JsonSerializer.Serialize(new[]
{
new ValidationRuleDto { Type = "required" }
}),
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "FullName",
Width = 150,
ListOrderNo = 3,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Email",
Width = 150,
ListOrderNo = 4,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Phone",
Width = 100,
ListOrderNo = 5,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Address",
Width = 200,
ListOrderNo = 6,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "NumberOfBranches",
Width = 100,
ListOrderNo = 7,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "NumberOfUsers",
Width = 100,
ListOrderNo = 8,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
new()
{
ListFormCode = listFormDemo.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Message",
Width = 300,
ListOrderNo = 9,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.Demos + ".Create",
R = AppCodes.Demos,
U = AppCodes.Demos + ".Update",
E = true,
I = true,
Deny = false
})
},
]);
#endregion
}
#endregion
#endregion
}
}

View file

@ -10003,8 +10003,6 @@
"en": "Loading component...",
"tr": "Bileşen yükleniyor..."
},
{
"resourceName": "Platform",
"key": "Public.products.remoteBranchTraining",
@ -10172,6 +10170,12 @@
"key": "Public.products.mobileReporting.desc",
"tr": "kursyazilimi.com mobil arayüzü ile şubeler bazında akıllı telefon teknolojisi ile yönetim imkanı sağlamaktadır.",
"en": "With kursyazilimi.coms mobile interface, management is possible per branch using smartphone technology."
},
{
"resourceName": "Platform",
"key": "App.Demos",
"tr": "Demolar",
"en": "Demos"
}
],
"Settings": [
@ -12077,6 +12081,16 @@
"Icon": "FcCollect",
"RequiredPermissionName": "App.Orders.PurchaseOrders",
"IsDisabled": false
},
{
"ParentCode": "App.Saas",
"Code": "App.Demos",
"DisplayName": "App.Demos",
"Order": 16,
"Url": "/admin/list/list-demo",
"Icon": "FcMissedCall",
"RequiredPermissionName": "App.Demos",
"IsDisabled": false
}
],
"PermissionGroupDefinitionRecords": [
@ -12163,6 +12177,10 @@
{
"Name": "App.Orders",
"DisplayName": "App.Orders"
},
{
"Name": "App.Demos",
"DisplayName": "App.Demos"
}
],
"PermissionDefinitionRecords": [
@ -14477,6 +14495,54 @@
"DisplayName": "Update",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos",
"ParentName": null,
"DisplayName": "App.Demos",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos.Create",
"ParentName": "App.Demos",
"DisplayName": "Create",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos.Update",
"ParentName": "App.Demos",
"DisplayName": "Update",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos.Delete",
"ParentName": "App.Demos",
"DisplayName": "Delete",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos.Export",
"ParentName": "App.Demos",
"DisplayName": "Export",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.Demos",
"Name": "App.Demos.Import",
"ParentName": "App.Demos",
"DisplayName": "Import",
"IsEnabled": true,
"MultiTenancySide": 2
}
],
"Sectors": [

View file

@ -368,6 +368,7 @@ public static class PlatformConsts
public const string InstallmentOption = "list-installmentoption";
public const string PurchaseOrder = "list-purchaseorder";
public const string ReportCategory = "list-reportcategory";
public const string Demo = "list-demo";
}
public static class Forms

View file

@ -400,6 +400,8 @@ public static class SeedConsts
public const string Default = Prefix.App + ".Reports";
public const string Categories = Default + ".Categories";
}
public const string Demos = Prefix.App + ".Demos";
}
public static class DataSources

View file

@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
namespace Kurs.Platform.Entities;
public class Demo : FullAuditedEntity<Guid>
{
[Required]
public string OrganizationName { get; set; }
[Required]
public string FullName { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Phone { get; set; }
[Required]
public string Address { get; set; }
public int NumberOfBranches { get; set; }
public int NumberOfUsers { get; set; }
[Required]
public string Message { get; set; }
}

View file

@ -89,6 +89,7 @@ public class PlatformDbContext :
public DbSet<ReportParameter> ReportParameters { get; set; }
public DbSet<ReportGenerated> ReportGenerated { get; set; }
public DbSet<ReportCategory> ReportCategories { get; set; }
public DbSet<Demo> Demos { get; set; }
#region Entities from the modules
@ -765,5 +766,20 @@ public class PlatformDbContext :
.OnDelete(DeleteBehavior.SetNull)
.IsRequired(false);
});
builder.Entity<Demo>(b =>
{
b.ToTable(PlatformConsts.DbTablePrefix + nameof(Demo), PlatformConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.OrganizationName).IsRequired(true).HasMaxLength(256);
b.Property(x => x.FullName).IsRequired().HasMaxLength(256);
b.Property(x => x.Email).IsRequired().HasMaxLength(256);
b.Property(x => x.Phone).IsRequired().HasMaxLength(20);
b.Property(x => x.Address).IsRequired().HasMaxLength(512);
b.Property(x => x.NumberOfBranches).IsRequired();
b.Property(x => x.NumberOfUsers).IsRequired();
b.Property(x => x.Message).IsRequired().HasMaxLength(2000);
});
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,48 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Kurs.Platform.Migrations
{
/// <inheritdoc />
public partial class Demo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PDemo",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrganizationName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
FullName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: false),
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
NumberOfBranches = table.Column<int>(type: "int", nullable: false),
NumberOfUsers = table.Column<int>(type: "int", nullable: false),
Message = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PDemo", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PDemo");
}
}
}

View file

@ -2036,6 +2036,78 @@ namespace Kurs.Platform.Migrations
b.ToTable("PDataSource", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.Demo", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Message")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("NumberOfBranches")
.HasColumnType("int");
b.Property<int>("NumberOfUsers")
.HasColumnType("int");
b.Property<string>("OrganizationName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("PDemo", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.GlobalSearch", b =>
{
b.Property<int>("Id")

View file

@ -0,0 +1,11 @@
export interface DemoDto {
id: string; // Guid karşılığı string
organizationName: string;
fullName: string;
email: string;
phone: string;
address: string;
numberOfBranches: number;
numberOfUsers: number;
message: string;
}

View file

@ -0,0 +1,9 @@
import { DemoDto } from '@/proxy/demo/models'
import apiService from './api.service'
export const createDemoAsync = (input: DemoDto) =>
apiService.fetchData<DemoDto>({
method: 'POST',
url: `/api/app/demo/demo`,
data: input as any,
})

View file

@ -11,38 +11,31 @@ import {
FaCheckCircle
} from 'react-icons/fa';
import { useLocalization } from "@/utils/hooks/useLocalization";
import { createDemoAsync } from "@/services/demo.service";
import { DemoDto } from "@/proxy/demo/models";
interface DemoModalProps {
isOpen: boolean;
onClose: () => void;
}
interface FormData {
organizationName: string;
fullName: string;
email: string;
phone: string;
address: string;
numberOfBranches: string;
numberOfUsers: string;
message: string;
}
const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
const { translate } = useLocalization()
const [formData, setFormData] = useState<FormData>({
const [formData, setFormData] = useState<DemoDto>({
id: crypto.randomUUID(),
organizationName: "",
fullName: "",
email: "",
phone: "",
address: "",
numberOfBranches: "",
numberOfUsers: "",
numberOfBranches: 0,
numberOfUsers: 0,
message: "",
});
const [errors, setErrors] = useState<Partial<FormData>>({});
const [errors, setErrors] = useState<Partial<DemoDto>>({});
const [isSubmitted, setIsSubmitted] = useState(false);
const handleInputChange = (
@ -54,7 +47,7 @@ const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
[name]: value,
}));
if (errors[name as keyof FormData]) {
if (errors[name as keyof DemoDto]) {
setErrors((prev) => ({
...prev,
[name]: "",
@ -63,7 +56,7 @@ const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
};
const validateForm = (): boolean => {
const newErrors: Partial<FormData> = {};
const newErrors: Partial<DemoDto> = {};
if (!formData.organizationName.trim())
newErrors.organizationName = "Organization name is required";
@ -75,10 +68,6 @@ const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
}
if (!formData.phone.trim()) newErrors.phone = "Phone number is required";
if (!formData.address.trim()) newErrors.address = "Address is required";
if (!formData.numberOfBranches.trim())
newErrors.numberOfBranches = "Number of branches is required";
if (!formData.numberOfUsers.trim())
newErrors.numberOfUsers = "Number of users is required";
if (!formData.message.trim()) newErrors.message = "Message is required";
setErrors(newErrors);
@ -91,7 +80,7 @@ const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
if (!validateForm()) return;
try {
//await demoService.createDemoForm(formData);
await createDemoAsync(formData);
setIsSubmitted(true);
onClose(); // modal'ı otomatik kapat
} catch (error) {
@ -144,13 +133,14 @@ const Demo: React.FC<DemoModalProps> = ({ isOpen, onClose }) => {
onClick={() => {
setIsSubmitted(false);
setFormData({
id: crypto.randomUUID(),
organizationName: "",
fullName: "",
email: "",
phone: "",
address: "",
numberOfBranches: "",
numberOfUsers: "",
numberOfBranches: 0,
numberOfUsers: 0,
message: "",
});
}}