Goal.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Mushaf } from '../QuranReader';
  2. export enum GoalCategory {
  3. QURAN = 'QURAN',
  4. }
  5. export enum GoalType {
  6. TIME = 'QURAN_TIME',
  7. PAGES = 'QURAN_PAGES',
  8. RANGE = 'QURAN_RANGE',
  9. }
  10. export type Goal = {
  11. id: string;
  12. type: GoalType;
  13. targetAmount: string;
  14. duration?: number;
  15. isCompleted: boolean;
  16. createdAt: Date;
  17. updatedAt: Date;
  18. };
  19. export type CreateGoalRequest = {
  20. type: GoalType;
  21. amount: string | number;
  22. duration?: number;
  23. mushafId: Mushaf;
  24. category: GoalCategory;
  25. };
  26. export type EstimateGoalRequest = Omit<CreateGoalRequest, 'category'>;
  27. export type UpdateGoalRequest = Partial<CreateGoalRequest>;
  28. export type QuranGoalStatus = Goal & {
  29. progress: {
  30. percent: number;
  31. // this will be either a number of pages (for PAGES and RANGE goals) or a number of seconds (for TIME goals)
  32. amountLeft: number;
  33. nextVerseToRead?: string;
  34. daysLeft?: number;
  35. };
  36. };
  37. export interface EstimatedGoalDay {
  38. date: string;
  39. amount: number;
  40. }
  41. export type RangeEstimatedQuranGoalDay = Omit<EstimatedGoalDay, 'amount'> & {
  42. amount: string;
  43. };
  44. export type EstimatedQuranGoal =
  45. | {
  46. week: EstimatedGoalDay[];
  47. }
  48. | {
  49. week: RangeEstimatedQuranGoalDay[];
  50. };
  51. export enum QuranGoalPeriod {
  52. Daily = 'DAILY',
  53. Continuous = 'CONTINUOUS',
  54. }