import 'package:flutter/foundation.dart';

import 'package:pshared/config/constants.dart';

abstract class Storable {
  String get id;
  DateTime get createdAt;
  DateTime get updatedAt;
}

@immutable
class _StorableImp implements Storable {
  @override
  final String id;
  @override
  final DateTime createdAt;
  @override
  final DateTime updatedAt;

  const _StorableImp({
    required this.id,
    required this.createdAt,
    required this.updatedAt,
  });
}

Storable newStorable({String? id, DateTime? createdAt, DateTime? updatedAt}) =>
    _StorableImp(
      id: id ?? Constants.nilObjectRef,
      createdAt: createdAt ?? DateTime.now().toUtc(),
      updatedAt: updatedAt ?? DateTime.now().toUtc(),
    );
