Created
May 13, 2024 12:29
-
-
Save Klerith/833e30a7c42ec126495656fe80ddd745 to your computer and use it in GitHub Desktop.
Generador de data para pruebas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { v4 as uuidV4 } from "uuid"; | |
import { uniqueNamesGenerator, Config, names } from "unique-names-generator"; | |
const config: Config = { | |
dictionaries: [names], | |
}; | |
export type Payment = { | |
id: string; | |
amount: number; | |
status: "pending" | "processing" | "success" | "failed"; | |
email: string; | |
clientName: string; | |
}; | |
const randomStatus = () => { | |
const statuses = ["pending", "processing", "success", "failed"] as const; | |
return statuses[Math.floor(Math.random() * statuses.length)]; | |
}; | |
const randomEmail = (clientName: string) => { | |
const domains = ["gmail.com", "yahoo.com", "outlook.com", "hotmail.com"]; | |
const randomDomain = domains[Math.floor(Math.random() * domains.length)]; | |
return `${clientName}@${randomDomain}`; | |
}; | |
export const payments: Payment[] = Array.from({ length: 500 }, (_) => { | |
const randomName = uniqueNamesGenerator(config); | |
return { | |
id: uuidV4(), | |
amount: Math.floor(Math.random() * 10000) / 100, | |
status: randomStatus(), | |
clientName: randomName, | |
email: randomEmail(randomName.toLowerCase()), | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment