Adopt page, minor adjustment to backend
This commit is contained in:
54
web/components/petUtils.js
Normal file
54
web/components/petUtils.js
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
//Temporary, until image support is added
|
||||
export const SPECIES_EMOJI = {
|
||||
dog: "🐶",
|
||||
cat: "🐱",
|
||||
bird: "🐦",
|
||||
rabbit: "🐰",
|
||||
hamster: "🐹",
|
||||
fish: "🐟",
|
||||
turtle: "🐢",
|
||||
snake: "🐍",
|
||||
lizard: "🦎",
|
||||
guinea: "🐹",
|
||||
};
|
||||
|
||||
export function getSpeciesEmoji(species) {
|
||||
if (!species) {
|
||||
|
||||
return "🐾";
|
||||
}
|
||||
|
||||
const key = species.toLowerCase();
|
||||
|
||||
for (const [k, v] of Object.entries(SPECIES_EMOJI)) {
|
||||
if (key.includes(k)) {
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
return "🐾";
|
||||
}
|
||||
|
||||
export function getStatusClass(status) {
|
||||
if (!status) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const s = status.toLowerCase();
|
||||
|
||||
if (s === "available") {
|
||||
return "status-available";
|
||||
}
|
||||
|
||||
if (s === "adopted") {
|
||||
return "status-adopted";
|
||||
}
|
||||
|
||||
if (s === "pending") {
|
||||
return "status-pending";
|
||||
}
|
||||
|
||||
return "status-other";
|
||||
}
|
||||
Reference in New Issue
Block a user