Skip to content

Commit

Permalink
bomb commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bush1D3v committed Nov 3, 2024
1 parent 07d24a2 commit b164b0e
Show file tree
Hide file tree
Showing 45 changed files with 1,345 additions and 760 deletions.
1 change: 1 addition & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ COINMARKETCAP_HOST=your_host
COINMARKETCAP_KEY=your_key
BRAPI_HOST=your_host
BRAPI_KEY=your_key
CURRENCYQUOTES_HOST=your_host
3 changes: 0 additions & 3 deletions api/src/types/CurrencyQuotes/Rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ export interface Rates {
USD: number;
UYU: number;
UZS: number;
VEF_BLKMKT: number;
VEF_DICOM: number;
VEF_DIPRO: number;
VES: number;
VND: number;
VUV: number;
Expand Down
17 changes: 11 additions & 6 deletions app/App.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script setup lang="ts">
import {RouterView} from "vue-router";
import { RouterView } from "vue-router";
import Footer from "@/components/Layout/Footer.vue";
import Header from "@/components/Layout/Header.vue";
import Sonner from "./components/ui/sonner/Sonner.vue";
import Toaster from "./components/ui/toast/Toaster.vue";
import Sonner from "@/components/ui/sonner/Sonner.vue";
import Toaster from "@/components/ui/toast/Toaster.vue";
import Tab from "@/components/CurrencyQuotes/Tab.vue";
</script>

<template>
<Header />
<RouterView />
<main class="min-h-[95dvh] relative ">
<RouterView />
<Toaster />
<Sonner />
<Tab />
</main>
<Footer />
<Toaster />
<Sonner />
</template>
15 changes: 9 additions & 6 deletions app/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
--secondary-darker: #171b2d;
--border: #222a44;
--accent: #2d375b;
--button-bg: #2d375b;
--dark: #8b94a3;
--card: #2d375b;
--muted: #eeeeee;
--destructive: #959595;
--material: #252d4a;
}

:root {
Expand All @@ -21,7 +24,6 @@
--muted: #111111;
--muted-foreground: rgb(141, 67, 14);

--popover: rgb(255, 0, 0);
--popover-foreground: #ffffff;

--card: #c9c9c9;
Expand All @@ -47,7 +49,7 @@
--primary-foreground: #ffffff;
--secondary: #0088cc;
--surface: #17192e;
--material: #252d4a;
--material: #eeeeee;
--texture: #161727;
--positive: #28c686;
--negative: #d34545;
Expand All @@ -56,7 +58,7 @@
--negative-lighter: #db6868;
--negative-darker: #bf2d2d;
--background: #f7fafd;
--secondary-darker: #eeeeee;
--secondary-darker: #ffffff;
--fg: #ffffff;
--fg-dim: #bac8d2;
--fg-muted: #8b94a3;
Expand All @@ -68,7 +70,6 @@
--material-darker: #1d2339;
--texture-lighter: #1f2137;
--texture-darker: #0d0d17;
--on-primary: #ffffff;
--twitter: #000000;
--telegram: #0088cc;
--reddit: #ff4500;
Expand All @@ -84,10 +85,12 @@
--primary-darker: #ef233c;
--primary-darker: #edf2f4;

--accent: #d6d6d8;
--accent: #ededed;
--accent-foreground: #ffffff;

--destructive: rgb(149, 149, 149);
--button-bg: #d6d6d8;

--destructive: #5a5a5a;
--destructive-foreground: rgb(22, 22, 22);

--ring: #ffffff;
Expand Down
107 changes: 107 additions & 0 deletions app/components/CurrencyQuotes/Select.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { CaretSortIcon, CheckIcon } from "@radix-icons/vue";
import { CurrencyQuotesDto } from "@/components/Dto/CurrencyQuotesDto";
import { ref } from "vue";
import { t } from "i18next";
import { listCurrencyQuotes } from "@/services/CurrencyQuotes";
import { useCurrencyQuotesStore } from "@/stores/useCurrencyQuotesStore";
import { onMounted } from "vue";
import { CurrencyQuotesDtoValues } from "../Dto/CurrencyQuotesDtoValues";
import { watch } from "vue";
const currencyQuotesStore = useCurrencyQuotesStore();
interface Props {
direction: "left" | "right";
}
const props = defineProps<Props>();
async function loadCurrencyQuotes() {
return await listCurrencyQuotes();
}
function selectItem(currency: KeyValue) {
open.value = false;
selectedValue.value = currency.value;
if (props.direction === "left") currencyQuotesStore.leftCurrency = currency.value;
else currencyQuotesStore.rightCurrency = currency.value;
}
onMounted(async () => {
const stateCurrencyQuotes = currencyQuotesStore.currencyQuotes;
if (!stateCurrencyQuotes) {
const data = await loadCurrencyQuotes();
if (!data) {
const currencies = {
table: "default",
rates: CurrencyQuotesDtoValues,
lastupdate: "2024-11-03T18:21:47.000000-03:00", // ISO 8601 date string
};
currencyQuotesStore.setCurrencyQuotes(currencies);
}
else currencyQuotesStore.setCurrencyQuotes(data);
}
});
interface KeyValue {
key: string;
value: string;
}
const open = ref(false)
const selectedValue = props.direction === "left" ? ref(currencyQuotesStore.leftCurrency) : ref(currencyQuotesStore.rightCurrency)
const currencies: KeyValue[] = Object.entries(CurrencyQuotesDto)
.map(([ key, value ]) => ({ key, value }))
.sort((a, b) => a.value.localeCompare(b.value))
watch(() => currencyQuotesStore.leftCurrency, (value) => {
if (props.direction === 'left') {
selectedValue.value = value;
}
});
watch(() => currencyQuotesStore.rightCurrency, (value) => {
if (props.direction === 'right') {
selectedValue.value = value;
}
});
</script>

<template>
<Popover v-model:open="open">
<PopoverTrigger as-child>
<Button variant="outline" role="combobox" :aria-expanded="open" class="w-[200px] justify-between">
{{ t(selectedValue) || t("Search currency...") }}
<CaretSortIcon class="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent class="w-[290px] p-0">
<Command>
<CommandInput class="h-9" placeholder="Search currency..." />
<CommandEmpty>{{ t("Nenhuma moeda encontrada.") }}</CommandEmpty>
<CommandList>
<CommandGroup>
<CommandItem v-for="currency in currencies" :key="currency.key" :value="currency.value"
@select="() => selectItem(currency)">
{{ t(currency.value) }}
<CheckIcon
:class="`ml-auto h-4 w-4 ${selectedValue === currency.value ? 'opacity-100' : 'opacity-0'}`" />
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
</template>
44 changes: 44 additions & 0 deletions app/components/CurrencyQuotes/Tab.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script setup lang="ts">
import Select from '@/components/CurrencyQuotes/Select.vue'
import { Button } from '@/components/ui/button'
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from '@/components/ui/collapsible'
import { ChevronDownIcon, ChevronUpIcon, DoubleArrowDownIcon } from '@radix-icons/vue'
import { ref } from 'vue'
import { t } from 'i18next'
import { useCurrencyQuotesStore } from '@/stores/useCurrencyQuotesStore'
const { invertCurrencies } = useCurrencyQuotesStore()
const isOpen = ref(false)
</script>

<template>
<Collapsible v-model:open="isOpen"
class="fixed z-50 right-10 bottom-0 space-y-2 bg-material rounded-t-2xl shadow-2xl shadow-accent py-2 px-4 translate-ignore">
<div class="flex items-center justify-between space-x-4">
<h4 class="font-semibold pr-20">
{{ t("Conversor de moedas") }}
</h4>
<CollapsibleTrigger as-child>
<Button variant="ghost" size="sm" class="w-9 p-0 rounded-full">
<ChevronDownIcon class="w-6 h-6" v-if=isOpen />
<ChevronUpIcon class="w-6 h-6" v-if=!isOpen />
<span class="sr-only">{{ isOpen ? 'Fechar' : 'Abrir' }}</span>
</Button>
</CollapsibleTrigger>
</div>
<CollapsibleContent class="space-y-2 flex flex-col">
<Select direction="left" />
<Button variant="default" class="w-9 p-0 rounded-full">
<DoubleArrowDownIcon @click="invertCurrencies">
revert
</DoubleArrowDownIcon>
</Button>
<Select direction="right" />
</CollapsibleContent>
</Collapsible>
</template>
Loading

0 comments on commit b164b0e

Please sign in to comment.