import { createCrudRoutes } from '@d8d/shared-crud';
import { DeliveryAddress } from '../entities';
import { DeliveryAddressSchema, CreateDeliveryAddressDto, UpdateDeliveryAddressDto } from '../schemas';
import { authMiddleware } from '@d8d/auth-module';

const deliveryAddressRoutes = createCrudRoutes({
  entity: DeliveryAddress,
  createSchema: CreateDeliveryAddressDto,
  updateSchema: UpdateDeliveryAddressDto,
  getSchema: DeliveryAddressSchema,
  listSchema: DeliveryAddressSchema,
  searchFields: ['name', 'phone', 'address'],
  relations: ['user', 'province', 'city', 'district', 'town'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});

export default deliveryAddressRoutes;