Skip to content

Instantly share code, notes, and snippets.

@dralletje
Created February 12, 2020 16:02
Show Gist options
  • Save dralletje/899ce0cca6ca0485df8f6623d359d27e to your computer and use it in GitHub Desktop.
Save dralletje/899ce0cca6ca0485df8f6623d359d27e to your computer and use it in GitHub Desktop.
interface Request {
_id: string,
clientId: string,
// Needed for custom title or to add something to the existing todo title.
// For example: "Open Bank Account" + "(2 accounts)"
title: string,
// Required to set when opening a request.
todoId: string,
status: RequestStatus,
steps: (ProposalStep)[], // Copied from Todo. Used to track progress.
phases: Phase[], // Copied from Todo. Used to track progress.
createdAt: Date,
deletedAt?: Date,
deletedBy?: string, // userId
finishBefore: Date, // createdAt + todo.maxDuration
// Nice to haves
statusHistory: { status: RequestStatus, assignedAt: Date, assignedBy: string /* userId */ }[],
cancellationReason?: string,
updatedAt: Date,
updatedBy: string, // userId
// category?
// usedCredit? // See available credit per todo by adding the used credit from connected requests?
}
interface Todo {
_id: string,
steps: (ProposalStep)[],
maxDuration: Duration,
phases: Phase[],
}
type Phase = { // This kind of replaces waypoints.
_id: string,
title: string,
weight: number, // determines the position in the order of steps.
maxDuration: Duration,
// Added when copied.
completedAt: Date,
}
interface ProposalStep extends Step {
type: StepType.Proposal,
supplierCategory: SupplierCategory,
suppliers: Supplier[],
tip?: string, // What Would Martijn Do?
// Added when copied
intro: string, // "Hey Peter, I found these options for you:"
advice: string, // "In your case I would suggest going with ... because ..."
sentAt: Date, // When it was sent to the client. Can be used to determine if waiting for client.
chosenSupplier: Supplier, // A copy to make sure we do not lose the actual proposed one even if the original changes.
}
interface Step {
_id: string,
weight: number, // determines the position in the order of steps.
type: StepType, // Used to render different components for step specific logic.
maxDuration: Duration,
// These are added when copying the step from the Todo.
startedAt: Date,
updateClientAt: Date,
completeBefore: Date,
completedAt: Date,
completedBy: string, // userId
panic?: {
problem: string,
startedAt: Date,
reportedBy: string, // userId
solution: string,
resolvedAt: Date,
resolvedBy: string, // userId
}
}
interface Supplier {
_id: string,
category: SupplierCategory,
name: string,
attributes: string[], // List of things we want to include in proposals.
link?: string, // To visit the supplier's website.
tip?: string, // "Close to expat center!"
}
enum StepType {
Proposal,
}
enum RequestStatus {
Open,
Finished,
Cancelled,
Blocked, // When the panic button was used.
}
enum SupplierCategory {
Bank,
}
type Duration = {
minutes: number,
hours: number,
days: number,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment