All files / src/features/Events/EventDetail/reviews review.types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                                                                                                                             
/**
 * PayBuilder 034 — post-event feedback.
 *
 * Reviews are written only in the GiveCash app; from the portal the merchant
 * can do exactly one thing with them — publish a single public reply, within 30
 * days of the customer submitting.
 */
 
/** One review as `GET .../products/{id}/reviews` returns it. */
export type EventReviewApiRow = {
  id: number;
  /** Seconds since epoch, as every product timestamp on this API is. */
  createdAt: number;
  rating: number;
  /** "" for a rating submitted without words — a complete review, not a partial one. */
  comment: string;
  reviewerName: string;
  reviewerAvatarURL: string;
  hasReply: boolean;
  replyBody: string;
  /** The merchant's business name; never the staff member who wrote the reply. */
  replyAuthorName: string;
  repliedAt: number | null;
  replyDeadlineAt: number | null;
  /**
   * Server-derived: false both when a reply already exists and when the 30-day
   * window has closed. Never recomputed from the browser clock — the API owns
   * the deadline, and the write path re-checks it anyway.
   */
  canReply: boolean;
};
 
export type EventReviewListResponse = {
  data: EventReviewApiRow[] | null;
  total: number;
};
 
/** The whole-event summary, read independently of the list's filters. */
export type EventReviewStats = {
  total: number;
  averageRating: number;
  numRating1: number;
  numRating2: number;
  numRating3: number;
  numRating4: number;
  numRating5: number;
  numAwaitingReply: number;
};
 
export type EventReviewRow = EventReviewApiRow;
 
/** A 1-5 star value, the only thing the rating filter accepts. */
export type ReviewRatingFilter = 1 | 2 | 3 | 4 | 5;
 
/**
 * What the live event page gets: the same review with the merchant-only fields
 * dropped. No reviewer account, no reply deadline, no reply eligibility.
 */
export type EventPublicReviewApiRow = Omit<
  EventReviewApiRow,
  "replyDeadlineAt" | "canReply"
>;
 
export type EventPublicReviewListResponse = {
  data: EventPublicReviewApiRow[] | null;
  total: number;
};
 
/** The public summary — no awaiting-reply count. */
export type EventPublicReviewStats = Omit<EventReviewStats, "numAwaitingReply">;