diff --git a/app/components/DataTable.tsx b/app/components/DataTable.tsx index a86ca43..4120db0 100644 --- a/app/components/DataTable.tsx +++ b/app/components/DataTable.tsx @@ -1,5 +1,6 @@ "use client"; +import Link from "next/link"; import { Progress } from "@/app/components/Progress"; import { Table, @@ -68,7 +69,9 @@ export const DataTable = ({ data, fuelType }: DataTableProps) => { return ( {MEDAL_MAPPING[serial] || serial} - {item.make} + + {item.make} + {item.number} diff --git a/app/make/[make]/page.tsx b/app/make/[make]/page.tsx new file mode 100644 index 0000000..69d1d62 --- /dev/null +++ b/app/make/[make]/page.tsx @@ -0,0 +1,80 @@ +import { API_URL } from "@/config"; +import { + Table, + TableBody, + TableCaption, + TableCell, + TableFooter, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { fetchApi } from "@/utils/fetchApi"; +import { capitaliseWords } from "@/utils/capitaliseWords"; +import type { Car } from "@/types"; +import Link from "next/link"; + +interface Props { + params: { make: string }; + searchParams: { month: string }; +} + +const CarMakePage = async ({ params, searchParams }: Props) => { + const { make } = params; + const { month } = searchParams; + + const cars = await fetchApi(`${API_URL}/make/${make}?month=${month}`); + + const excludeHeaders = ["_id", "make", "importer_type"]; + const tableHeaders = Object.keys(cars[0]) + .filter((item) => !excludeHeaders.includes(item)) + .map((header) => capitaliseWords(header)); + + return ( +
+
+

+ {decodeURIComponent(make)} +

+

Registrations

+
+ + Historical trends for {make} + + + # + {tableHeaders.map((header) => ( + {header} + ))} + + + + {cars.map((car, index) => { + const serial = index + 1; + return ( + + {serial} + {car.month} + + + {car.fuel_type} + + + {car.vehicle_type} + {car.number} + + ); + })} + + + + +
+
+ ); +}; + +export default CarMakePage; diff --git a/jest.config.js b/jest.config.ts similarity index 76% rename from jest.config.js rename to jest.config.ts index d2a283c..ab18fb8 100644 --- a/jest.config.js +++ b/jest.config.ts @@ -1,10 +1,12 @@ -const nextJest = require("next/jest"); +import type { Config } from "jest"; +import nextJest from "next/jest"; // Providing the path to your Next.js app which will enable loading next.config.js and .env files const createJestConfig = nextJest({ dir: "./" }); // Any custom config you want to pass to Jest -const customJestConfig = { +const customJestConfig: Config = { + collectCoverage: true, setupFilesAfterEnv: ["/jest.setup.js"], }; diff --git a/package.json b/package.json index cd5a875..b2a068f 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "prettier-plugin-tailwindcss": "^0.5.6", "sst": "^2.32.2", "tailwindcss": "^3", + "ts-node": "^10.9.2", "typescript": "^5" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2effa1..e80e64e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,7 +88,7 @@ importers: version: 2.3.0 tailwindcss-animate: specifier: ^1.0.7 - version: 1.0.7(tailwindcss@3.4.1) + version: 1.0.7(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))) devDependencies: '@babel/core': specifier: ^7.23.2 @@ -101,13 +101,13 @@ importers: version: 7.23.3(@babel/core@7.23.9) '@tailwindcss/forms': specifier: ^0.5.7 - version: 0.5.7(tailwindcss@3.4.1) + version: 0.5.7(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))) '@tailwindcss/typography': specifier: ^0.5.10 - version: 0.5.10(tailwindcss@3.4.1) + version: 0.5.10(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))) '@testing-library/jest-dom': specifier: ^6.1.4 - version: 6.4.2(@jest/globals@29.7.0)(@types/jest@29.5.12)(jest@29.7.0(@types/node@20.11.17)) + version: 6.4.2(@jest/globals@29.7.0)(@types/jest@29.5.12)(jest@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))) '@testing-library/react': specifier: ^14.0.0 version: 14.2.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -146,7 +146,7 @@ importers: version: 14.0.0(eslint@8.56.0)(typescript@5.3.3) jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.17) + version: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) jest-environment-jsdom: specifier: ^29.7.0 version: 29.7.0 @@ -167,7 +167,10 @@ importers: version: 2.40.3(@aws-sdk/credential-provider-node@3.513.0(aws-crt@1.21.1))(@types/react@18.2.55)(aws-crt@1.21.1) tailwindcss: specifier: ^3 - version: 3.4.1 + version: 3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) + ts-node: + specifier: ^10.9.2 + version: 10.9.2(@types/node@20.11.17)(typescript@5.3.3) typescript: specifier: ^5 version: 5.3.3 @@ -1084,6 +1087,10 @@ packages: '@cdklabs/tskb@0.0.3': resolution: {integrity: sha512-JR+MuD4awAXvutu7HArephXfZm09GPTaSAQUqNcJB5+ZENRm4kV+L6vJL6Tn1xHjCcHksO+HAqj3gYtm5K94vA==} + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + '@envelop/core@3.0.6': resolution: {integrity: sha512-06t1xCPXq6QFN7W1JUEf68aCwYN0OUDNAIoJe7bAqhaoa2vn7NCcuX1VHkJ/OWpmElUgCsRO6RiBbIru1in0Ig==} @@ -1414,6 +1421,9 @@ packages: '@jridgewell/trace-mapping@0.3.22': resolution: {integrity: sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==} + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@lukeed/ms@2.0.2': resolution: {integrity: sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==} engines: {node: '>=8'} @@ -2249,6 +2259,18 @@ packages: '@trpc/server@9.16.0': resolution: {integrity: sha512-IENsJs41ZR4oeFUJhsNNTSgEOtuRN0m9u7ec4u3eG/qOc7bIoo1nDoYtx4bl6OJJSQYEytG9tlcVz9G8OAaHbg==} + '@tsconfig/node10@1.0.11': + resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} + + '@tsconfig/node12@1.0.11': + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + + '@tsconfig/node14@1.0.3': + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + + '@tsconfig/node16@1.0.4': + resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + '@types/aria-query@5.0.4': resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} @@ -2573,6 +2595,9 @@ packages: resolution: {integrity: sha512-+25nxyyznAXF7Nef3y0EbBeqmGZgeN/BxHX29Rs39djAfaFalmQ89SE6CWyDCHzGL0yt/ycBtNOmGTW0FyGWNw==} engines: {node: '>= 10'} + arg@4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + arg@5.0.2: resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==} @@ -3055,6 +3080,9 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true + create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} @@ -3343,6 +3371,10 @@ packages: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + diff@4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + diff@5.2.0: resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==} engines: {node: '>=0.3.1'} @@ -4551,6 +4583,9 @@ packages: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} + make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + makeerror@1.0.12: resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} @@ -5609,6 +5644,20 @@ packages: ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + ts-node@10.9.2: + resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} @@ -5775,6 +5824,9 @@ packages: resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} hasBin: true + v8-compile-cache-lib@3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + v8-to-istanbul@9.2.0: resolution: {integrity: sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==} engines: {node: '>=10.12.0'} @@ -5955,6 +6007,10 @@ packages: resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} engines: {node: '>=12'} + yn@3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -7815,6 +7871,10 @@ snapshots: '@cdklabs/tskb@0.0.3': {} + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + '@envelop/core@3.0.6': dependencies: '@envelop/types': 3.0.2 @@ -8047,7 +8107,7 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0': + '@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -8061,7 +8121,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.11.17) + jest-config: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -8217,6 +8277,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.1 + '@jridgewell/sourcemap-codec': 1.4.15 + '@lukeed/ms@2.0.2': {} '@mdi/js@7.4.47': {} @@ -9248,18 +9313,18 @@ snapshots: '@swc/counter': 0.1.3 tslib: 2.6.2 - '@tailwindcss/forms@0.5.7(tailwindcss@3.4.1)': + '@tailwindcss/forms@0.5.7(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)))': dependencies: mini-svg-data-uri: 1.4.4 - tailwindcss: 3.4.1 + tailwindcss: 3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) - '@tailwindcss/typography@0.5.10(tailwindcss@3.4.1)': + '@tailwindcss/typography@0.5.10(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)))': dependencies: lodash.castarray: 4.4.0 lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 postcss-selector-parser: 6.0.10 - tailwindcss: 3.4.1 + tailwindcss: 3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) '@testing-library/dom@9.3.4': dependencies: @@ -9272,7 +9337,7 @@ snapshots: lz-string: 1.5.0 pretty-format: 27.5.1 - '@testing-library/jest-dom@6.4.2(@jest/globals@29.7.0)(@types/jest@29.5.12)(jest@29.7.0(@types/node@20.11.17))': + '@testing-library/jest-dom@6.4.2(@jest/globals@29.7.0)(@types/jest@29.5.12)(jest@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)))': dependencies: '@adobe/css-tools': 4.3.3 '@babel/runtime': 7.23.9 @@ -9285,7 +9350,7 @@ snapshots: optionalDependencies: '@jest/globals': 29.7.0 '@types/jest': 29.5.12 - jest: 29.7.0(@types/node@20.11.17) + jest: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) '@testing-library/react@14.2.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: @@ -9301,6 +9366,14 @@ snapshots: dependencies: tslib: 2.6.2 + '@tsconfig/node10@1.0.11': {} + + '@tsconfig/node12@1.0.11': {} + + '@tsconfig/node14@1.0.3': {} + + '@tsconfig/node16@1.0.4': {} + '@types/aria-query@5.0.4': {} '@types/babel__core@7.20.5': @@ -9692,6 +9765,8 @@ snapshots: tar-stream: 2.2.0 zip-stream: 4.1.1 + arg@4.1.3: {} + arg@5.0.2: {} argparse@1.0.10: @@ -10255,13 +10330,13 @@ snapshots: crc-32: 1.2.2 readable-stream: 3.6.2 - create-jest@29.7.0(@types/node@20.11.17): + create-jest@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.11.17) + jest-config: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -10270,6 +10345,8 @@ snapshots: - supports-color - ts-node + create-require@1.1.1: {} + cross-fetch@3.1.8: dependencies: node-fetch: 2.7.0 @@ -10565,6 +10642,8 @@ snapshots: diff-sequences@29.6.3: {} + diff@4.0.2: {} + diff@5.2.0: {} dir-glob@3.0.1: @@ -11668,16 +11747,16 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.11.17): + jest-cli@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: - '@jest/core': 29.7.0 + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.11.17) + create-jest: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.11.17) + jest-config: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -11687,7 +11766,7 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.11.17): + jest-config@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: '@babel/core': 7.23.9 '@jest/test-sequencer': 29.7.0 @@ -11713,6 +11792,7 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.11.17 + ts-node: 10.9.2(@types/node@20.11.17)(typescript@5.3.3) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -11954,12 +12034,12 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.11.17): + jest@29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: - '@jest/core': 29.7.0 + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.11.17) + jest-cli: 29.7.0(@types/node@20.11.17)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -12168,6 +12248,8 @@ snapshots: dependencies: semver: 7.6.0 + make-error@1.3.6: {} + makeerror@1.0.12: dependencies: tmpl: 1.0.5 @@ -12541,12 +12623,13 @@ snapshots: camelcase-css: 2.0.1 postcss: 8.4.35 - postcss-load-config@4.0.2(postcss@8.4.35): + postcss-load-config@4.0.2(postcss@8.4.35)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: lilconfig: 3.0.0 yaml: 2.3.4 optionalDependencies: postcss: 8.4.35 + ts-node: 10.9.2(@types/node@20.11.17)(typescript@5.3.3) postcss-nested@6.0.1(postcss@8.4.35): dependencies: @@ -13226,11 +13309,11 @@ snapshots: dependencies: '@babel/runtime': 7.24.6 - tailwindcss-animate@1.0.7(tailwindcss@3.4.1): + tailwindcss-animate@1.0.7(tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3))): dependencies: - tailwindcss: 3.4.1 + tailwindcss: 3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) - tailwindcss@3.4.1: + tailwindcss@3.4.1(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -13249,7 +13332,7 @@ snapshots: postcss: 8.4.35 postcss-import: 15.1.0(postcss@8.4.35) postcss-js: 4.0.1(postcss@8.4.35) - postcss-load-config: 4.0.2(postcss@8.4.35) + postcss-load-config: 4.0.2(postcss@8.4.35)(ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3)) postcss-nested: 6.0.1(postcss@8.4.35) postcss-selector-parser: 6.0.15 resolve: 1.22.8 @@ -13316,6 +13399,24 @@ snapshots: ts-interface-checker@0.1.13: {} + ts-node@10.9.2(@types/node@20.11.17)(typescript@5.3.3): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.11.17 + acorn: 8.11.3 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.3.3 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + tsconfig-paths@3.15.0: dependencies: '@types/json5': 0.0.29 @@ -13468,6 +13569,8 @@ snapshots: uuid@9.0.1: {} + v8-compile-cache-lib@3.0.1: {} + v8-to-istanbul@9.2.0: dependencies: '@jridgewell/trace-mapping': 0.3.22 @@ -13654,6 +13757,8 @@ snapshots: y18n: 5.0.8 yargs-parser: 21.1.1 + yn@3.1.1: {} + yocto-queue@0.1.0: {} yoga-wasm-web@0.3.3: {} diff --git a/types/index.ts b/types/index.ts index 16225d0..933e921 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,9 +1,11 @@ import { FUEL_TYPE } from "@/config"; export interface Car { + _id?: string; month: string; make: string; fuel_type: FUEL_TYPE | string; + vehicle_type?: string; number: number; selected?: boolean; } diff --git a/utils/capitaliseWords.test.ts b/utils/capitaliseWords.test.ts index 8e32d39..fd28ac7 100644 --- a/utils/capitaliseWords.test.ts +++ b/utils/capitaliseWords.test.ts @@ -17,4 +17,9 @@ describe("capitaliseWords", () => { expect(capitaliseWords("hello")).toBe("Hello"); expect(capitaliseWords("HELLO")).toBe("Hello"); }); + + it("should return a capitalised format for a word with underscore", () => { + expect(capitaliseWords("HELLO_WORLD")).toBe("Hello World"); + expect(capitaliseWords("hello_world")).toBe("Hello World"); + }); }); diff --git a/utils/capitaliseWords.ts b/utils/capitaliseWords.ts index 4631bb9..34c1aab 100644 --- a/utils/capitaliseWords.ts +++ b/utils/capitaliseWords.ts @@ -1,5 +1,6 @@ export const capitaliseWords = (str: string) => str + .replace("_", " ") .split(" ") .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" ");