Skip to content

Commit

Permalink
updated parseTypes with validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pfed-prog committed Dec 11, 2024
1 parent 908642a commit 25c7547
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion with-tailwindcss-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"postcss": "^8.4.49",
"prettier": "3.x",
"tailwindcss": "^3.4.16",
"typescript": "^5.7.2"
"typescript": "^5.7.0"
}
}
61 changes: 28 additions & 33 deletions with-tailwindcss-app/styles/parseTypes.ts
Original file line number Diff line number Diff line change
@@ -1,74 +1,69 @@
export function parseTxTypes(txTypes: string[]) {
if (txTypes.length === 0) {
if (!txTypes) {
return {
background: 'bg-[#e058]',
placeholder: 'Empty',
background: "bg-[#9b4569]",
placeholder: "contract creation",
};
}

if (txTypes.length === 1) {
if (txTypes.includes('coin_transfer')) {
if (txTypes.includes("coin_transfer")) {
return {
background: 'bg-[#e05875]',
placeholder: '(coin transfer)',
background: "bg-[#e05875]",
placeholder: "(coin transfer)",
};
}
if (txTypes.includes('token_transfer')) {
if (txTypes.includes("token_transfer")) {
return {
background: 'bg-[#cce058]',
placeholder: '(token transfer)',
background: "bg-[#cce058]",
placeholder: "(token transfer)",
};
}
if (txTypes.includes('contract_call')) {
if (txTypes.includes("contract_call")) {
return {
background: 'bg-[#5888e0]',
placeholder: '(contract call)',
background: "bg-[#5888e0]",
placeholder: "(contract call)",
};
}

return {
background: 'bg-[#E88300]',
placeholder: '(contract creation)',
background: "bg-[#E88300]",
placeholder: "(contract creation)",
};
}
if (txTypes.length === 2) {
if (
txTypes.includes('contract_call') &&
txTypes.includes('token_transfer')
txTypes.includes("contract_call") &&
txTypes.includes("token_transfer")
) {
return {
background: 'bg-[#36be56]',
placeholder: '(token transfer + contract call)',
background: "bg-[#36be56]",
placeholder: "(token transfer + contract call)",
};
}
if (
txTypes.includes('contract_call') &&
txTypes.includes('coin_transfer')
txTypes.includes("contract_call") &&
txTypes.includes("coin_transfer")
) {
return {
background: 'bg-[#FDA737]',
placeholder: '(coin transfer + contract call)',
background: "bg-[#FDA737]",
placeholder: "(coin transfer + contract call)",
};
}
if (
txTypes.includes('contract_creation') &&
txTypes.includes('token_transfer')
txTypes.includes("contract_creation") &&
txTypes.includes("token_transfer")
) {
return {
background: 'bg-[#a9c400]',
placeholder: '(contract creation + token transfer)',
background: "bg-[#a9c400]",
placeholder: "(contract creation + token transfer)",
};
}
}
if (txTypes.length === 3) {
return {
background: 'bg-[#FC05EC]',
placeholder: '(coin transfer + token_transfer + contract call)',
background: "bg-[#FC05EC]",
placeholder: "(coin transfer + token_transfer + contract call)",
};
}

return {
background: 'bg-[#e058]',
placeholder: '???',
};
}
2 changes: 1 addition & 1 deletion with-tailwindcss-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5548,7 +5548,7 @@ typed-array-length@^1.0.6:
is-typed-array "^1.1.13"
possible-typed-array-names "^1.0.0"

typescript@^5.7.2:
typescript@^5.7.0:
version "5.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6"
integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==
Expand Down

0 comments on commit 25c7547

Please sign in to comment.