import { createCrudRoutes } from '../../utils/generic-crud.routes';
import { DeliveryAddress } from '../../modules/delivery-address/delivery-address.entity';
import { DeliveryAddressSchema, CreateDeliveryAddressDto, UpdateDeliveryAddressDto } from '../../modules/delivery-address/delivery-address.schema';
import { authMiddleware } from '../../middleware/auth.middleware';

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;