primereact
38 строк · 1.0 Кб
1export const CarService = {2brands: ['Vapid', 'Carson', 'Kitano', 'Dabver', 'Ibex', 'Morello', 'Akira', 'Titan', 'Dover', 'Norma'],3
4colors: ['Black', 'White', 'Red', 'Blue', 'Silver', 'Green', 'Yellow'],5
6generateCar(id) {7return {8id,9vin: this.generateVin(),10brand: this.generateBrand(),11color: this.generateColor(),12year: this.generateYear()13};14},15
16generateVin() {17let text = '';18let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';19
20for (let i = 0; i < 5; i++) {21text += possible.charAt(Math.floor(Math.random() * possible.length));22}23
24return text;25},26
27generateBrand() {28return this.brands[Math.floor(Math.random() * Math.floor(10))];29},30
31generateColor() {32return this.colors[Math.floor(Math.random() * Math.floor(7))];33},34
35generateYear() {36return 2000 + Math.floor(Math.random() * Math.floor(19));37}38};39