From c11781e2b9e6eb129f6e8b87b50d115c6c8d590c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:46:07 +0300 Subject: [PATCH] Eksik permission, Formik --- .../Seeds/SeederData.json | 296 ++++++ ui/dev-dist/sw.js | 2 +- ui/src/store/abpConfig.model.ts | 5 +- ui/src/types/wm.ts | 2 +- ui/src/utils/hooks/useMenuData.ts | 3 +- .../admin/role-management/RolesPermission.tsx | 2 +- .../views/warehouse/components/SerialForm.tsx | 369 +++---- .../components/WarehouseDefinitions.tsx | 2 +- .../warehouse/components/WarehouseForm.tsx | 515 --------- .../components/modals/LocationModal.tsx | 996 ++++++++---------- .../components/modals/WarehouseModal.tsx | 641 +++++------ .../warehouse/components/modals/ZoneModal.tsx | 562 +++++----- 12 files changed, 1439 insertions(+), 1956 deletions(-) delete mode 100644 ui/src/views/warehouse/components/WarehouseForm.tsx diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json b/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json index 222341bb..bd61493c 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json @@ -1063,6 +1063,7 @@ "IsEnabled": true, "MultiTenancySide": 2 }, + { "GroupName": "App.Saas", "Name": "App.BlogManagement.Category", @@ -1111,6 +1112,301 @@ "IsEnabled": true, "MultiTenancySide": 2 }, + + { + "GroupName": "App.Saas", + "Name": "App.About", + "ParentName": null, + "DisplayName": "App.About", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.About.Create", + "ParentName": "App.About", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.About.Delete", + "ParentName": "App.About", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.About.Export", + "ParentName": "App.About", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.About.Import", + "ParentName": "App.About", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.About.Update", + "ParentName": "App.About", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + + { + "GroupName": "App.Saas", + "Name": "App.Services", + "ParentName": null, + "DisplayName": "App.Services", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Services.Create", + "ParentName": "App.Services", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Services.Delete", + "ParentName": "App.Services", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Services.Export", + "ParentName": "App.Services", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Services.Import", + "ParentName": "App.Services", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Services.Update", + "ParentName": "App.Services", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products", + "ParentName": null, + "DisplayName": "App.Orders.Products", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products.Create", + "ParentName": "App.Orders.Products", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products.Delete", + "ParentName": "App.Orders.Products", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products.Export", + "ParentName": "App.Orders.Products", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products.Import", + "ParentName": "App.Orders.Products", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.Products.Update", + "ParentName": "App.Orders.Products", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods", + "ParentName": null, + "DisplayName": "App.Orders.PaymentMethods", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods.Create", + "ParentName": "App.Orders.PaymentMethods", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods.Delete", + "ParentName": "App.Orders.PaymentMethods", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods.Export", + "ParentName": "App.Orders.PaymentMethods", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods.Import", + "ParentName": "App.Orders.PaymentMethods", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PaymentMethods.Update", + "ParentName": "App.Orders.PaymentMethods", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions", + "ParentName": null, + "DisplayName": "App.Orders.InstallmentOptions", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions.Create", + "ParentName": "App.Orders.InstallmentOptions", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions.Delete", + "ParentName": "App.Orders.InstallmentOptions", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions.Export", + "ParentName": "App.Orders.InstallmentOptions", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions.Import", + "ParentName": "App.Orders.InstallmentOptions", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.InstallmentOptions.Update", + "ParentName": "App.Orders.InstallmentOptions", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders", + "ParentName": null, + "DisplayName": "App.Orders.PurchaseOrders", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders.Create", + "ParentName": "App.Orders.PurchaseOrders", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders.Delete", + "ParentName": "App.Orders.PurchaseOrders", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders.Export", + "ParentName": "App.Orders.PurchaseOrders", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders.Import", + "ParentName": "App.Orders.PurchaseOrders", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { + "GroupName": "App.Saas", + "Name": "App.Orders.PurchaseOrders.Update", + "ParentName": "App.Orders.PurchaseOrders", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2 + }, + { "GroupName": "App.Saas", "Name": "App.BlogManagement.Posts", diff --git a/ui/dev-dist/sw.js b/ui/dev-dist/sw.js index 6099ffb9..dde24430 100644 --- a/ui/dev-dist/sw.js +++ b/ui/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-a959eb95'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "/index.html", - "revision": "0.v5arcquq4lo" + "revision": "0.sjlnuata16g" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html"), { diff --git a/ui/src/store/abpConfig.model.ts b/ui/src/store/abpConfig.model.ts index fc51b688..158ca770 100644 --- a/ui/src/store/abpConfig.model.ts +++ b/ui/src/store/abpConfig.model.ts @@ -53,7 +53,10 @@ export const abpConfigModel: AbpConfigModel = { actions.setConfig(result.data) - await actions.getMenu() + //Eğer login değilse + if (result.data.currentUser.isAuthenticated) { + await actions.getMenu() + } }), texts: undefined, setTexts: action((state, payload) => { diff --git a/ui/src/types/wm.ts b/ui/src/types/wm.ts index 01d3a3f0..3b20e2c9 100644 --- a/ui/src/types/wm.ts +++ b/ui/src/types/wm.ts @@ -41,7 +41,7 @@ export interface WmLocation { // Lokasyon id: string warehouseId: string - zoneId?: string + zoneId: string locationCode: string name: string description?: string diff --git a/ui/src/utils/hooks/useMenuData.ts b/ui/src/utils/hooks/useMenuData.ts index 3808f4a2..2517e6ca 100644 --- a/ui/src/utils/hooks/useMenuData.ts +++ b/ui/src/utils/hooks/useMenuData.ts @@ -1,14 +1,15 @@ import { MenuItem } from '@/@types/menu' -import isDisabled from '@/components/ui/DatePicker/tables/components/props/isDisabled' import { getMenus, MenuService } from '@/services/menu.service' import { useStoreActions } from '@/store/store' import { useState, useEffect } from 'react' +import useAuth from './useAuth' export const useMenuData = () => { const [menuItems, setMenuItems] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const { getConfig } = useStoreActions((a) => a.abpConfig) + const { authenticated } = useAuth() const buildHierarchy = (items: MenuItem[]): MenuItem[] => { const itemMap = new Map() diff --git a/ui/src/views/admin/role-management/RolesPermission.tsx b/ui/src/views/admin/role-management/RolesPermission.tsx index 2c50806c..6660aa91 100644 --- a/ui/src/views/admin/role-management/RolesPermission.tsx +++ b/ui/src/views/admin/role-management/RolesPermission.tsx @@ -102,7 +102,7 @@ function RolesPermission({ setTimeout(async () => { getConfig(true) - }, 2000) + }, 4000) } function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] { diff --git a/ui/src/views/warehouse/components/SerialForm.tsx b/ui/src/views/warehouse/components/SerialForm.tsx index 753dfbcf..d58ac9ed 100644 --- a/ui/src/views/warehouse/components/SerialForm.tsx +++ b/ui/src/views/warehouse/components/SerialForm.tsx @@ -1,10 +1,13 @@ import React from 'react' -import { useFormik } from 'formik' +import { Formik, Form, Field } from 'formik' import * as Yup from 'yup' import { FaSave, FaTimes } from 'react-icons/fa' import { SerialStatusEnum, MmSerialNumber, MmMaterial } from '../../../types/mm' import { getSerialStatusText } from '@/utils/erp' +import { Input, Checkbox, Button } from '@/components/ui' +import Select from '@/components/ui/Select' + export interface SerialFormProps { isOpen: boolean onClose: () => void @@ -31,188 +34,202 @@ const SerialForm: React.FC = ({ initial = null, mode = 'create', }) => { - const formik = useFormik({ - initialValues: { - materialId: '', - serialNumber: '', - lotId: lots.length ? lots[0].id : '', - productionDate: '', - warrantyExpiryDate: '', - currentLocationId: '', - status: SerialStatusEnum.Available, - isActive: true, - }, - validationSchema, - onSubmit: async (values) => { - const newSerial: MmSerialNumber = { - id: (initial && initial.id) || Date.now().toString(), - materialId: values.materialId, - serialNumber: values.serialNumber, - lotId: values.lotId || undefined, - productionDate: values.productionDate ? new Date(values.productionDate) : new Date(), - warrantyExpiryDate: values.warrantyExpiryDate - ? new Date(values.warrantyExpiryDate) - : undefined, - currentLocationId: values.currentLocationId || undefined, - status: values.status, - isActive: !!values.isActive, - } - - // simulate API - await new Promise((r) => setTimeout(r, 300)) - if (mode === 'edit' && onUpdate) { - onUpdate(newSerial) - } else { - onSave(newSerial) - } - onClose() - }, - }) - - // sync initial values when editing/viewing - React.useEffect(() => { - if (initial) { - const src = initial - formik.setValues({ - materialId: src.materialId || '', - serialNumber: src.serialNumber || '', - lotId: src.lotId || (lots.length ? lots[0].id : ''), - productionDate: src.productionDate - ? new Date(src.productionDate).toISOString().slice(0, 10) - : '', - warrantyExpiryDate: src.warrantyExpiryDate - ? new Date(src.warrantyExpiryDate).toISOString().slice(0, 10) - : '', - currentLocationId: src.currentLocationId || '', - status: src.status || SerialStatusEnum.Available, - isActive: !!src.isActive, - }) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [initial]) - if (!isOpen) return null + const initialValues = { + materialId: initial?.materialId || '', + serialNumber: initial?.serialNumber || '', + lotId: initial?.lotId || '', + productionDate: initial?.productionDate + ? new Date(initial.productionDate).toISOString().slice(0, 10) + : '', + warrantyExpiryDate: initial?.warrantyExpiryDate + ? new Date(initial.warrantyExpiryDate).toISOString().slice(0, 10) + : '', + currentLocationId: initial?.currentLocationId || '', + status: initial?.status || SerialStatusEnum.Available, + isActive: initial?.isActive ?? true, + } + return (
-
-
-
-

- {mode === 'create' - ? 'Yeni Seri Kaydı' - : mode === 'edit' - ? 'Seri Düzenle' - : 'Seri Detayı'} -

-

- {mode === 'create' - ? 'Seri numarası girin' - : mode === 'edit' - ? 'Mevcut seri bilgisini güncelleyin' - : 'Seri bilgileri (sadece gösterim)'} -

-
-
- - {mode !== 'view' && ( - + {mode !== 'view' && ( + + )} +
+
+ + {/* Grid Form */} +
+ {/* Material */} +
+ + ({ value: l.id, label: l.label }))} + value={lots + .map((l) => ({ value: l.id, label: l.label })) + .find((opt) => opt.value === values.lotId)} + onChange={(opt) => setFieldValue('lotId', opt?.value || '')} + /> +
+ + {/* Status */} +
+ + - - {materials.map((m) => ( - - ))} - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
-
+ Aktif + +
+ + )} +
) diff --git a/ui/src/views/warehouse/components/WarehouseDefinitions.tsx b/ui/src/views/warehouse/components/WarehouseDefinitions.tsx index 8fc4f669..a14f189f 100644 --- a/ui/src/views/warehouse/components/WarehouseDefinitions.tsx +++ b/ui/src/views/warehouse/components/WarehouseDefinitions.tsx @@ -733,7 +733,7 @@ const WarehouseDefinitions: React.FC = () => {
-

{location.name}

+
{location.name}

{location.locationCode}

diff --git a/ui/src/views/warehouse/components/WarehouseForm.tsx b/ui/src/views/warehouse/components/WarehouseForm.tsx deleted file mode 100644 index 3a319048..00000000 --- a/ui/src/views/warehouse/components/WarehouseForm.tsx +++ /dev/null @@ -1,515 +0,0 @@ -import React, { useState, useEffect, useCallback } from 'react' -import { useNavigate, useParams } from 'react-router-dom' -import { FaSave, FaTimes, FaBox, FaMapMarkerAlt, FaLayerGroup, FaBuilding } from 'react-icons/fa' -import LoadingSpinner from '../../../components/common/LoadingSpinner' -import { WmWarehouse, WarehouseTypeEnum } from '../../../types/wm' -import { SecurityLevelEnum } from '../../../types/mrp' -import { mockWarehouses } from '../../../mocks/mockWarehouses' -import { Container } from '@/components/shared' -import { ROUTES_ENUM } from '@/routes/route.constant' -import { getWarehouseTypeText } from '@/utils/erp' - -interface ValidationErrors { - [key: string]: string -} - -const WarehouseForm: React.FC = () => { - const navigate = useNavigate() - const { id } = useParams<{ id: string }>() - const isEdit = Boolean(id) - - const [loading, setLoading] = useState(false) - const [saving, setSaving] = useState(false) - const [errors, setErrors] = useState({}) - - const [formData, setFormData] = useState({ - id: '', - code: '', - name: '', - description: '', - address: { - street: '', - city: '', - state: '', - postalCode: '', - country: 'Türkiye', - }, - warehouseType: WarehouseTypeEnum.RawMaterials, - locations: [], - isMainWarehouse: false, - capacity: 0, - currentUtilization: 0, - zones: [], - isActive: true, - securityLevel: SecurityLevelEnum.Low, - temperatureControlled: false, - managerId: 0, - creationTime: new Date(), - lastModificationTime: new Date(), - }) - - const loadFormData = useCallback(async () => { - setLoading(true) - try { - if (isEdit && id) { - // Simulate API call - await new Promise((resolve) => setTimeout(resolve, 1000)) - const warehouse = mockWarehouses.find((w) => w.id === id) - if (warehouse) { - setFormData(warehouse) - } - } - } catch (error) { - console.error('Error loading form data:', error) - } finally { - setLoading(false) - } - }, [isEdit, id]) - - useEffect(() => { - loadFormData() - }, [loadFormData]) - - const validateForm = (): boolean => { - const newErrors: ValidationErrors = {} - - if (!formData.code.trim()) { - newErrors.code = 'Depo kodu zorunludur' - } - if (!formData.name.trim()) { - newErrors.name = 'Depo adı zorunludur' - } - if (!formData.warehouseType) { - newErrors.warehouseType = 'Depo tipi seçilmelidir' - } - if (!formData.address?.street.trim()) { - newErrors['address.street'] = 'Adres zorunludur' - } - if (!formData.address?.city.trim()) { - newErrors['address.city'] = 'Şehir zorunludur' - } - if (!formData.address?.country.trim()) { - newErrors['address.country'] = 'Ülke zorunludur' - } - if (formData.capacity <= 0) { - newErrors.capacity = "Kapasite 0'dan büyük olmalıdır" - } - - setErrors(newErrors) - return Object.keys(newErrors).length === 0 - } - - const handleInputChange = (field: string, value: any) => { - setFormData((prev) => { - const updated = { ...prev } - const keys = field.split('.') - let current: any = updated - keys.forEach((key, index) => { - if (index === keys.length - 1) { - current[key] = value - } else { - current[key] = { ...current[key] } - current = current[key] - } - }) - return updated - }) - - if (errors[field]) { - setErrors((prev) => ({ ...prev, [field]: '' })) - } - } - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault() - - if (!validateForm()) { - return - } - - setSaving(true) - try { - // Simulate API call - await new Promise((resolve) => setTimeout(resolve, 2000)) - - console.log('Warehouse data:', { - ...formData, - id: isEdit ? id : undefined, - }) - - // Show success message - alert(isEdit ? 'Depo başarıyla güncellendi!' : 'Depo başarıyla oluşturuldu!') - - // Navigate back to list - navigate(ROUTES_ENUM.protected.warehouse.warehouses) - } catch (error) { - console.error('Error saving warehouse:', error) - alert('Bir hata oluştu. Lütfen tekrar deneyin.') - } finally { - setSaving(false) - } - } - - const handleCancel = () => { - navigate(ROUTES_ENUM.protected.warehouse.warehouses) - } - - if (loading) { - return - } - - return ( - -
- {/* Header */} -
-
-

- {isEdit ? 'Depo Düzenle' : 'Yeni Depo'} -

-

- {isEdit ? 'Mevcut depo bilgilerini güncelleyin' : 'Yeni depo bilgilerini girin'} -

-
-
- - {/* Form */} -
- {/* Basic Information */} -
-
-

- - Genel Bilgiler -

-
- -
-
-
- - handleInputChange('code', e.target.value)} - className={`block w-full px-3 py-1.5 text-sm border rounded-md shadow-sm focus:outline-none focus:ring-1 ${ - errors.code - ? 'border-red-300 focus:border-red-500 focus:ring-red-500' - : 'border-gray-300 focus:border-blue-500 focus:ring-blue-500' - }`} - placeholder="Örn: WH001" - /> - {errors.code &&

{errors.code}

} -
- -
- - - {errors.warehouseType && ( -

{errors.warehouseType}

- )} -
-
- -
- - handleInputChange('name', e.target.value)} - className={`block w-full px-3 py-1.5 text-sm border rounded-md shadow-sm focus:outline-none focus:ring-1 ${ - errors.name - ? 'border-red-300 focus:border-red-500 focus:ring-red-500' - : 'border-gray-300 focus:border-blue-500 focus:ring-blue-500' - }`} - placeholder="Depo adı" - /> - {errors.name &&

{errors.name}

} -
- -
- -