import { GiveActionClaim, OfferClaim, PlanActionClaim } from "./claims";
import { GenericCredWrapper } from "./common";

export interface EmojiSummaryRecord {
  issuerDid: string;
  jwtId: string;
  text: string;
  parentHandleId: string;
}

// a summary record; the VC is found the fullClaim field
export interface GiveSummaryRecord {
  [x: string]:
    | PropertyKey
    | undefined
    | GiveActionClaim
    | Record<string, number>;
  type?: string;
  agentDid: string;
  amount: number;
  amountConfirmed: number;
  description: string;
  emojiCount: Record<string, number>; // Map of emoji character to count
  fullClaim: GiveActionClaim;
  fulfillsHandleId: string;
  fulfillsPlanHandleId?: string;
  fulfillsType?: string;
  handleId: string;
  issuedAt: string;
  issuerDid: string;
  jwtId: string;
  providerPlanHandleId?: string;
  recipientDid: string;
  unit: string;
}

// a summary record; the VC is found the fullClaim field
export interface OfferSummaryRecord {
  amount: number;
  amountGiven: number;
  amountGivenConfirmed: number;
  fullClaim: OfferClaim;
  fulfillsPlanHandleId: string;
  handleId: string;
  issuerDid: string;
  jwtId: string;
  nonAmountGivenConfirmed: number;
  objectDescription: string;
  offeredByDid: string;
  recipientDid: string;
  requirementsMet: boolean;
  unit: string;
  validThrough: string;
}

export interface OfferToPlanSummaryRecord extends OfferSummaryRecord {
  planName: string;
}

/**
 * A summary record
 * The VC is not currently part of this record.
 *
 * If you change this, you may want to update NewActivityView.vue to handle differences correctly.
 */
export interface PlanSummaryRecord {
  agentDid?: string;
  description: string;
  endTime?: string;
  fulfillsPlanHandleId: string;
  handleId: string;
  image?: string;
  issuerDid: string;
  locLat?: number;
  locLon?: number;
  name?: string;
  startTime?: string;
  url?: string;
  jwtId?: string;
}

export interface PlanSummaryAndPreviousClaim {
  plan: PlanSummaryRecord;
  // This can be undefined, eg. if a project is starred after the stored last-seen-change-jwt ID.
  // The endorser-ch test code shows some cases.
  wrappedClaimBefore?: GenericCredWrapper<PlanActionClaim>;
}

/**
 * Represents data about a project
 *
 * @deprecated
 * (Maybe we should use PlanSummaryRecord instead, either by adding rowId or by iterating with jwtId.)
 **/
export interface PlanData {
  /**
   * Description of the project
   **/
  description: string;
  /**
   * URL referencing information about the project
   **/
  handleId: string;
  image?: string;
  /**
   * The DID of the issuer
   */
  issuerDid: string;
  /**
   * Name of the project
   **/
  name: string;
  /**
   * The identifier of the project record -- different from jwtId
   *
   * This has been used to iterate through plan records, because jwtId ordering doesn't match
   * chronological create ordering, though it does match most recent edit order (in reverse order).
   * (It may be worthwhile to order by jwtId instead. It is an indexed field.)
   **/
  rowId?: string;
}
