Skip to content

Commit

Permalink
fixes in users table, orders table, association admin menu item, and …
Browse files Browse the repository at this point in the history
…others
  • Loading branch information
baufaker committed Apr 13, 2024
1 parent b4f0f25 commit 54fd088
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 24 deletions.
12 changes: 7 additions & 5 deletions components/header/Drawers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ function Drawers({ menu, searchbar, children, platform }: Props) {
if (localStorage.getItem("AccessToken") == "") {
menu.items = menu.publicItems || [];
} else if (localStorage.getItem("AssociationAdmin")) {
menu.items[menu.items.length] = {
"@type": "SiteNavigationElement",
name: "Admin Associação",
url: "/admin/associacao",
};
if (!menu.items.find((i) => i.name === "Admin Associação")) {
menu.items[menu.items.length] = {
"@type": "SiteNavigationElement",
name: "Admin Associação",
url: "/admin/associacao",
};
}
}

return (
Expand Down
25 changes: 21 additions & 4 deletions components/ui/AssociationAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,30 @@ function MyAccount() {
Pacientes da Associação
</h2>
<div>
<div class="flex pb-2 px-2 border-b border-[#cdcdcd] mb-4">
<div class="w-[32%] flex justify-start">
<span>Nome</span>
</div>
<div class="w-[32%] flex justify-start">
<span>Email</span>
</div>
<div class="w-[32%] flex justify-end">
<span>CPF</span>
</div>
</div>
<ul class="flex flex-col gap-2">
{associationUsers && associationUsers.map((u) => {
return (
<li class="p-3 bg-[#cacaca] flex justify-between items-center rounded-md text-[10px] sm:text-xs md:text-sm">
<span>{u.cognito_data.name}</span>
<span>{u.email}</span>
<span>{u.cognito_data.cpf}</span>
<li class="p-3 bg-[#cacaca] flex gap-[2%] justify-between items-center rounded-md text-[10px] sm:text-xs md:text-sm">
<div class="w-[32%] flex justify-start">
<span>{u.cognito_data.name}</span>
</div>
<div class="w-[32%] flex justify-start">
<span>{u.email}</span>
</div>
<div class="w-[32%] flex justify-end">
<span>{u.cognito_data.cpf}</span>
</div>
</li>
);
})}
Expand Down
36 changes: 32 additions & 4 deletions components/ui/EcannaCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,32 @@ function EcannaCardPage({ cardSkeleton }: Props) {
}
}, []); // Passando um array de dependências vazio

function downloadFile(fileUrl: string, filename: string) {
// Fetch the file data
fetch(fileUrl)
.then((response) => response.blob())
.then((blob) => {
// Create a temporary anchor element
const a = document.createElement("a");
a.style.display = "none";

// Set the download attribute and file URL
a.download = filename;
a.href = window.URL.createObjectURL(blob);

// Append the anchor to the body and trigger the download
document.body.appendChild(a);
a.click();

// Clean up
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);
})
.catch((error) => {
console.error("Error downloading file:", error);
});
}

return (
<div class="flex flex-col justify-center items-center my-10 gap-[100px] sm:gap-[30px]">
<div class="rotate-90 sm:rotate-0 flex justify-center p-3 sm:p-12 bg-[#252525] rounded-xl max-w-[424px] sm:max-w-[90%]">
Expand Down Expand Up @@ -118,14 +144,16 @@ function EcannaCardPage({ cardSkeleton }: Props) {
product={cardProduct}
address={address!}
/>
<a
<button
type="button"
href={cardUrl}
download="carteirinha.png"
class="flex btn btn-primary text-white w-full sm:w-[48%]"
target="_blank"
onClick={() => {
downloadFile(cardUrl!, "carteirinha-ecanna.png");
}}
>
<span>Baixar Carteirinha</span> <Icon id="Download" size={19} />
</a>
</button>
<button
type="button"
download="carteirinha.png"
Expand Down
2 changes: 1 addition & 1 deletion components/ui/MyInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Icon from "../../components/ui/Icon.tsx";
import PageWrap from "../../components/ui/PageWrap.tsx";

function MyInfo() {
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [isLoadingCids, setIsLoadingCids] = useState(false);
const [isLoadingPostalCode, setIsLoadingPostalCode] = useState(false);
const [isSubmiting, setIsSubmitting] = useState(false);
Expand Down
67 changes: 58 additions & 9 deletions components/ui/MyOrders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,41 @@ import Slider from "../../components/ui/Slider.tsx";
import { useUI } from "../../sdk/useUI.ts";
import SliderJS from "../../islands/SliderJS.tsx";

const OrderItem = (
{ name, value, created_at, status }: {
name: string;
value: string;
created_at: string;
status:
| "PAID"
| "PENDING"
| "CANCELED"
| "IN_PRODUCTION"
| "PENDING_SHIPPING"
| "SHIPPED"
| "DELIVERED";
},
) => {
return (
<li class="p-3 bg-[#cacaca] flex justify-between items-center rounded-md text-[10px] sm:text-xs md:text-sm">
<div class="w-[25%] flex justify-start">
<span>{name}</span>
</div>
<div class="w-[25%] flex justify-start">
<span>{"RS " + value}</span>
</div>
<div class="w-[25%] flex justify-center">
<span>
{created_at}
</span>
</div>
<div class="w-[25%] flex justify-end">
<OrderStatus status={status} />
</div>
</li>
);
};

function MyOrders() {
const [isLoading, setIsLoading] = useState(true);
const [orders, setOrders] = useState<Order[]>();
Expand Down Expand Up @@ -51,24 +86,38 @@ function MyOrders() {
{isLoading
? <span class="loading loading-spinner text-green-600"></span>
: (
<div class="flex flex-col gap-3 w-full">
<div class="flex flex-col gap-5 w-full">
<div class="flex justify-center">
<h3 class="text-2xl text-[#8b8b8b] font-semibold text-center">
Meus Pedidos
</h3>
</div>
<div>
<div class="flex pb-2 px-2 border-b border-[#cdcdcd] mb-4">
<div class="w-[25%] flex justify-start">
<span class="text-xs">Produto</span>
</div>
<div class="w-[25%] flex justify-start">
<span class="text-xs">Valor</span>
</div>
<div class="w-[25%] flex justify-center">
<span class="text-xs">
Data
</span>
</div>
<div class="w-[25%] flex justify-end">
<span class="text-xs">Status</span>
</div>
</div>
<ul class="flex flex-col gap-2">
{orders && orders.map((o) => {
return (
<li class="p-3 bg-[#cacaca] flex justify-between items-center rounded-md text-[10px] sm:text-xs md:text-sm">
<span>{o.items[0].sku.name}</span>
<span>{"RS " + ((o.value / 100).toFixed(2))}</span>
<span>
{format(new Date(o.created_at), "dd/MM/yyyy")}
</span>
<OrderStatus status={o.status} />
</li>
<OrderItem
name={o.items[0].sku.name}
value={(o.value / 100).toFixed(2)}
created_at={format(new Date(o.created_at), "dd/MM/yyyy")}
status={o.status}
/>
);
})}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion components/ui/OrderStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function OrderStatus({ status }: Props) {

return (
<span
class={`badge badge-xs border-none text-white text-[10px] sm:text-xs md:text-sm ${
class={`badge badge-sm border-none text-white text-[10px] sm:text-xs md:text-sm ${
style[status].style
}`}
>
Expand Down

0 comments on commit 54fd088

Please sign in to comment.