From a0bd14abd85f7eafc36bac8eb721529e14dcd272 Mon Sep 17 00:00:00 2001 From: Guilherme Baufaker Date: Wed, 15 May 2024 13:52:22 -0300 Subject: [PATCH 1/2] implemented frontend of prescriber treatments --- components/ui/Icon.tsx | 1 + components/ui/PrescriberPatientTreatment.tsx | 246 ++++++++++++++++++ components/ui/PrescriberPatients.tsx | 92 ++++--- fresh.gen.ts | 2 + islands/PrescriberPatientTreatment.tsx | 9 + manifest.gen.ts | 117 +++++---- .../PrescriberPatientTreatment.tsx | 1 + static/sprites.svg | 3 + 8 files changed, 379 insertions(+), 92 deletions(-) create mode 100644 components/ui/PrescriberPatientTreatment.tsx create mode 100644 islands/PrescriberPatientTreatment.tsx create mode 100644 sections/Miscellaneous/PrescriberPatientTreatment.tsx diff --git a/components/ui/Icon.tsx b/components/ui/Icon.tsx index f3cf4b7..9da25a6 100644 --- a/components/ui/Icon.tsx +++ b/components/ui/Icon.tsx @@ -44,6 +44,7 @@ export type AvailableIcons = | "Secure" | "Star" | "Tiktok" + | "Drop" | "Trash" | "Truck" | "Twitter" diff --git a/components/ui/PrescriberPatientTreatment.tsx b/components/ui/PrescriberPatientTreatment.tsx new file mode 100644 index 0000000..8137e9d --- /dev/null +++ b/components/ui/PrescriberPatientTreatment.tsx @@ -0,0 +1,246 @@ +/** + * This component was made to control if user is logged in to access pages + */ +// import type { SectionProps } from "deco/types.ts"; +// import { useUI } from "../../sdk/useUI.ts"; +import { useEffect, useState } from "preact/hooks"; +import { invoke } from "../../runtime.ts"; +import PageWrap from "./PageWrap.tsx"; +import Icon from "./Icon.tsx"; +import { useUI } from "../../sdk/useUI.ts"; +import type { DocListType } from "./MyDocs.tsx"; +import Modal from "./Modal.tsx"; +import { IS_BROWSER } from "$fresh/runtime.ts"; +import type { Patient, Treatment } from "./PrescriberPatients.tsx"; + +export type Address = { + cep: string; + number: string; + complement: string; + addressType: string; +}; + +const timeAgo = (date: Date): string => { + const seconds = Math.floor((Number(new Date()) - +date) / 1000); // Explicitly convert to number + let interval = Math.floor(seconds / 31536000); + + if (interval >= 1) return `${interval}a atrás`; + interval = Math.floor(seconds / 2592000); + if (interval >= 1) return `${interval}m atrás`; + interval = Math.floor(seconds / 86400); + if (interval >= 1) return `${interval}d atrás`; + interval = Math.floor(seconds / 3600); + if (interval >= 1) return `${interval}h atrás`; + interval = Math.floor(seconds / 60); + if (interval >= 1) return `${interval}min atrás`; + return `${Math.floor(seconds)}seg atrás`; +}; + +const TreatmentCard = ({ treatment }: { treatment: Treatment }) => { + return ( +
+
+
+ {treatment.medication.map((m) => { + return ( +
+ +
+ + {m.name} + + + {m.dosage} + +
+
+ ); + })} +
+
+
+ + + {timeAgo( + new Date( + treatment.updated_at, + ), + )} + +
+
+ +
+
+
+
+ ); +}; + +function PrescriberPatientTreatments() { + const [isLoading, setIsLoading] = useState(false); + const [deleting, setDeleting] = useState(false); + const [isLoadingUsers, setIsLoadingUsers] = useState(false); + const [updating, setUpdating] = useState(false); + const [emailSearch, setEmailSearch] = useState(""); + const [associationName, setAssociationName] = useState(""); + const [associationCnpj, setAssociationCnpj] = useState(""); + const [associationLogo, setAssociationLogo] = useState(""); + const [createType, setCreateType] = useState<"user" | "association">( + "association", + ); + const [limit, setLimit] = useState(); + const [hasNextPage, setHasNextPage] = useState(false); + const [hasPrevPage, setHasPrevPage] = useState(false); + const [page, setPage] = useState(); + const [totalPages, setTotalPages] = useState(); + const [patient, setpatients] = useState( + { + name: "Célio Marcos", + email: "celiomarcos@email.com", + treatments: [ + { + updated_at: "2024-05-14T14:29:09.024+00:00", + feedback: "positive", + medication: [ + { + name: "CBD 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + { + name: "THC 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + ], + current: true, + }, + { + updated_at: "2024-05-13T14:29:09.024+00:00", + feedback: "negative", + medication: [ + { + name: "CBD 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + { + name: "THC 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + ], + current: false, + }, + { + updated_at: "2024-05-13T14:29:09.024+00:00", + feedback: "negative", + medication: [ + { + name: "CBD 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + { + name: "THC 3000mg - Abrapango", + dosage: "3 gotas 2x/ dia", + }, + ], + current: false, + }, + ], + }, + ); + const [docs, setDocs] = useState([]); + + const currentTreatment = patient.treatments?.find((t) => t.current === true); + const oldTreatments = patient.treatments?.filter((t) => t.current !== true); + + // const { + // displayPreSignupUsersModal, + // displayAssociationAdminNewDoc, + // userToAdminCreateDoc, + // associationToAdminCreateDoc, + // displayConfirmDeleteDoc, + // } = useUI(); + + return ( + + {isLoading + ? + : ( +
+
+

+ Tratamento +

+ +
+
+
+
+
+
+ +
+
+ + {patient.name} + + + {patient.email} + +
+
+
+
+
+

+ Tratamento Vigente +

+
+ +
+
+
+

+ Tratamentos Antigos +

+
+ {oldTreatments?.map((t) => { + return ; + })} +
+
+
+
+ )} +
+ ); +} + +export default PrescriberPatientTreatments; diff --git a/components/ui/PrescriberPatients.tsx b/components/ui/PrescriberPatients.tsx index 7f2183d..b22c2de 100644 --- a/components/ui/PrescriberPatients.tsx +++ b/components/ui/PrescriberPatients.tsx @@ -24,13 +24,24 @@ export type Address = { addressType: string; }; +export type Treatment = { + updated_at: string; + feedback: "positive" | "negative"; + medication: { + name: string; + dosage: string; + }[]; + current: boolean; +}; + export type Patient = { name: string; email: string; - last_treatment: { + last_treatment?: { updated_at: string | Date; feedback: "positive" | "negative"; - }; + } | undefined; + treatments?: Treatment[]; }; function PrescriberPatients() { @@ -70,10 +81,7 @@ function PrescriberPatients() { { name: "Tauane Rodrigues", email: "tauame@email.com", - last_treatment: { - updated_at: "2024-05-12T19:10:43.016+00:00", - feedback: "positive", - }, + last_treatment: undefined, }, ]); const [docs, setDocs] = useState([]); @@ -109,7 +117,7 @@ function PrescriberPatients() { : (
-

+

Meus Pacientes

@@ -143,12 +151,12 @@ function PrescriberPatients() {
    {patients && patients.map((p) => { return ( - diff --git a/fresh.gen.ts b/fresh.gen.ts index c986a62..87c0af5 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -36,6 +36,7 @@ import * as $NewTicketModal from "./islands/NewTicketModal.tsx"; import * as $Newsletter from "./islands/Newsletter.tsx"; import * as $OutOfStock from "./islands/OutOfStock.tsx"; import * as $PreSignupUsersModal from "./islands/PreSignupUsersModal.tsx"; +import * as $PrescriberPatientTreatment from "./islands/PrescriberPatientTreatment.tsx"; import * as $PrescriberPatients from "./islands/PrescriberPatients.tsx"; import * as $PrivatePageControl from "./islands/PrivatePageControl.tsx"; import * as $PrivatePageControlAdmin from "./islands/PrivatePageControlAdmin.tsx"; @@ -95,6 +96,7 @@ const manifest = { "./islands/Newsletter.tsx": $Newsletter, "./islands/OutOfStock.tsx": $OutOfStock, "./islands/PreSignupUsersModal.tsx": $PreSignupUsersModal, + "./islands/PrescriberPatientTreatment.tsx": $PrescriberPatientTreatment, "./islands/PrescriberPatients.tsx": $PrescriberPatients, "./islands/PrivatePageControl.tsx": $PrivatePageControl, "./islands/PrivatePageControlAdmin.tsx": $PrivatePageControlAdmin, diff --git a/islands/PrescriberPatientTreatment.tsx b/islands/PrescriberPatientTreatment.tsx new file mode 100644 index 0000000..4cfeb5c --- /dev/null +++ b/islands/PrescriberPatientTreatment.tsx @@ -0,0 +1,9 @@ +import Component from "deco-sites/ecannadeco/components/ui/PrescriberPatientTreatment.tsx"; +// import type { Props } from "../../components/ui/MyInfo.tsx"; + +function Island() { + return ; + // return ; +} + +export default Island; diff --git a/manifest.gen.ts b/manifest.gen.ts index 05b4f26..1d7c929 100644 --- a/manifest.gen.ts +++ b/manifest.gen.ts @@ -92,35 +92,36 @@ import * as $$$$$$47 from "./sections/Miscellaneous/MyAccount.tsx"; import * as $$$$$$48 from "./sections/Miscellaneous/MyDocs.tsx"; import * as $$$$$$49 from "./sections/Miscellaneous/MyInfo.tsx"; import * as $$$$$$50 from "./sections/Miscellaneous/MyOrders.tsx"; -import * as $$$$$$51 from "./sections/Miscellaneous/PrescriberPatients.tsx"; -import * as $$$$$$52 from "./sections/Miscellaneous/PrivatePageControl.tsx"; -import * as $$$$$$53 from "./sections/Miscellaneous/PrivatePageControlAdmin.tsx"; -import * as $$$$$$54 from "./sections/Miscellaneous/PublicPageControl.tsx"; -import * as $$$$$$55 from "./sections/Miscellaneous/PublicProfile.tsx"; -import * as $$$$$$56 from "./sections/Miscellaneous/SignIn.tsx"; -import * as $$$$$$57 from "./sections/Miscellaneous/SignInAdmin.tsx"; -import * as $$$$$$58 from "./sections/Miscellaneous/SignInPrescriber.tsx"; -import * as $$$$$$61 from "./sections/Miscellaneous/Signout.tsx"; -import * as $$$$$$59 from "./sections/Miscellaneous/SignUp.tsx"; -import * as $$$$$$60 from "./sections/Miscellaneous/SignUpPrescriber.tsx"; -import * as $$$$$$62 from "./sections/Miscellaneous/Slide.tsx"; -import * as $$$$$$63 from "./sections/Miscellaneous/UserAlerts.tsx"; -import * as $$$$$$64 from "./sections/Miscellaneous/UserAssociatedSignup.tsx"; -import * as $$$$$$65 from "./sections/Newsletter/Newsletter.tsx"; -import * as $$$$$$66 from "./sections/Product/ImageGalleryFrontBack.tsx"; -import * as $$$$$$67 from "./sections/Product/ImageGallerySlider.tsx"; -import * as $$$$$$68 from "./sections/Product/NotFound.tsx"; -import * as $$$$$$69 from "./sections/Product/NotFoundChallenge.tsx"; -import * as $$$$$$70 from "./sections/Product/ProductDetails.tsx"; -import * as $$$$$$71 from "./sections/Product/ProductInfo.tsx"; -import * as $$$$$$72 from "./sections/Product/ProductShelf.tsx"; -import * as $$$$$$73 from "./sections/Product/ProductShelfTabbed.tsx"; -import * as $$$$$$74 from "./sections/Product/SearchResult.tsx"; -import * as $$$$$$75 from "./sections/Product/ShelfWithImage.tsx"; -import * as $$$$$$76 from "./sections/Product/Wishlist.tsx"; -import * as $$$$$$77 from "./sections/Social/InstagramPosts.tsx"; -import * as $$$$$$78 from "./sections/Social/WhatsApp.tsx"; -import * as $$$$$$79 from "./sections/Theme/Theme.tsx"; +import * as $$$$$$52 from "./sections/Miscellaneous/PrescriberPatients.tsx"; +import * as $$$$$$51 from "./sections/Miscellaneous/PrescriberPatientTreatment.tsx"; +import * as $$$$$$53 from "./sections/Miscellaneous/PrivatePageControl.tsx"; +import * as $$$$$$54 from "./sections/Miscellaneous/PrivatePageControlAdmin.tsx"; +import * as $$$$$$55 from "./sections/Miscellaneous/PublicPageControl.tsx"; +import * as $$$$$$56 from "./sections/Miscellaneous/PublicProfile.tsx"; +import * as $$$$$$57 from "./sections/Miscellaneous/SignIn.tsx"; +import * as $$$$$$58 from "./sections/Miscellaneous/SignInAdmin.tsx"; +import * as $$$$$$59 from "./sections/Miscellaneous/SignInPrescriber.tsx"; +import * as $$$$$$62 from "./sections/Miscellaneous/Signout.tsx"; +import * as $$$$$$60 from "./sections/Miscellaneous/SignUp.tsx"; +import * as $$$$$$61 from "./sections/Miscellaneous/SignUpPrescriber.tsx"; +import * as $$$$$$63 from "./sections/Miscellaneous/Slide.tsx"; +import * as $$$$$$64 from "./sections/Miscellaneous/UserAlerts.tsx"; +import * as $$$$$$65 from "./sections/Miscellaneous/UserAssociatedSignup.tsx"; +import * as $$$$$$66 from "./sections/Newsletter/Newsletter.tsx"; +import * as $$$$$$67 from "./sections/Product/ImageGalleryFrontBack.tsx"; +import * as $$$$$$68 from "./sections/Product/ImageGallerySlider.tsx"; +import * as $$$$$$69 from "./sections/Product/NotFound.tsx"; +import * as $$$$$$70 from "./sections/Product/NotFoundChallenge.tsx"; +import * as $$$$$$71 from "./sections/Product/ProductDetails.tsx"; +import * as $$$$$$72 from "./sections/Product/ProductInfo.tsx"; +import * as $$$$$$73 from "./sections/Product/ProductShelf.tsx"; +import * as $$$$$$74 from "./sections/Product/ProductShelfTabbed.tsx"; +import * as $$$$$$75 from "./sections/Product/SearchResult.tsx"; +import * as $$$$$$76 from "./sections/Product/ShelfWithImage.tsx"; +import * as $$$$$$77 from "./sections/Product/Wishlist.tsx"; +import * as $$$$$$78 from "./sections/Social/InstagramPosts.tsx"; +import * as $$$$$$79 from "./sections/Social/WhatsApp.tsx"; +import * as $$$$$$80 from "./sections/Theme/Theme.tsx"; const manifest = { "loaders": { @@ -188,42 +189,44 @@ const manifest = { "deco-sites/ecannadeco/sections/Miscellaneous/MyInfo.tsx": $$$$$$49, "deco-sites/ecannadeco/sections/Miscellaneous/MyOrders.tsx": $$$$$$50, "deco-sites/ecannadeco/sections/Miscellaneous/PrescriberPatients.tsx": + $$$$$$52, + "deco-sites/ecannadeco/sections/Miscellaneous/PrescriberPatientTreatment.tsx": $$$$$$51, "deco-sites/ecannadeco/sections/Miscellaneous/PrivatePageControl.tsx": - $$$$$$52, - "deco-sites/ecannadeco/sections/Miscellaneous/PrivatePageControlAdmin.tsx": $$$$$$53, - "deco-sites/ecannadeco/sections/Miscellaneous/PublicPageControl.tsx": + "deco-sites/ecannadeco/sections/Miscellaneous/PrivatePageControlAdmin.tsx": $$$$$$54, - "deco-sites/ecannadeco/sections/Miscellaneous/PublicProfile.tsx": $$$$$$55, - "deco-sites/ecannadeco/sections/Miscellaneous/SignIn.tsx": $$$$$$56, - "deco-sites/ecannadeco/sections/Miscellaneous/SignInAdmin.tsx": $$$$$$57, + "deco-sites/ecannadeco/sections/Miscellaneous/PublicPageControl.tsx": + $$$$$$55, + "deco-sites/ecannadeco/sections/Miscellaneous/PublicProfile.tsx": $$$$$$56, + "deco-sites/ecannadeco/sections/Miscellaneous/SignIn.tsx": $$$$$$57, + "deco-sites/ecannadeco/sections/Miscellaneous/SignInAdmin.tsx": $$$$$$58, "deco-sites/ecannadeco/sections/Miscellaneous/SignInPrescriber.tsx": - $$$$$$58, - "deco-sites/ecannadeco/sections/Miscellaneous/Signout.tsx": $$$$$$61, - "deco-sites/ecannadeco/sections/Miscellaneous/SignUp.tsx": $$$$$$59, + $$$$$$59, + "deco-sites/ecannadeco/sections/Miscellaneous/Signout.tsx": $$$$$$62, + "deco-sites/ecannadeco/sections/Miscellaneous/SignUp.tsx": $$$$$$60, "deco-sites/ecannadeco/sections/Miscellaneous/SignUpPrescriber.tsx": - $$$$$$60, - "deco-sites/ecannadeco/sections/Miscellaneous/Slide.tsx": $$$$$$62, - "deco-sites/ecannadeco/sections/Miscellaneous/UserAlerts.tsx": $$$$$$63, + $$$$$$61, + "deco-sites/ecannadeco/sections/Miscellaneous/Slide.tsx": $$$$$$63, + "deco-sites/ecannadeco/sections/Miscellaneous/UserAlerts.tsx": $$$$$$64, "deco-sites/ecannadeco/sections/Miscellaneous/UserAssociatedSignup.tsx": - $$$$$$64, - "deco-sites/ecannadeco/sections/Newsletter/Newsletter.tsx": $$$$$$65, + $$$$$$65, + "deco-sites/ecannadeco/sections/Newsletter/Newsletter.tsx": $$$$$$66, "deco-sites/ecannadeco/sections/Product/ImageGalleryFrontBack.tsx": - $$$$$$66, - "deco-sites/ecannadeco/sections/Product/ImageGallerySlider.tsx": $$$$$$67, - "deco-sites/ecannadeco/sections/Product/NotFound.tsx": $$$$$$68, - "deco-sites/ecannadeco/sections/Product/NotFoundChallenge.tsx": $$$$$$69, - "deco-sites/ecannadeco/sections/Product/ProductDetails.tsx": $$$$$$70, - "deco-sites/ecannadeco/sections/Product/ProductInfo.tsx": $$$$$$71, - "deco-sites/ecannadeco/sections/Product/ProductShelf.tsx": $$$$$$72, - "deco-sites/ecannadeco/sections/Product/ProductShelfTabbed.tsx": $$$$$$73, - "deco-sites/ecannadeco/sections/Product/SearchResult.tsx": $$$$$$74, - "deco-sites/ecannadeco/sections/Product/ShelfWithImage.tsx": $$$$$$75, - "deco-sites/ecannadeco/sections/Product/Wishlist.tsx": $$$$$$76, - "deco-sites/ecannadeco/sections/Social/InstagramPosts.tsx": $$$$$$77, - "deco-sites/ecannadeco/sections/Social/WhatsApp.tsx": $$$$$$78, - "deco-sites/ecannadeco/sections/Theme/Theme.tsx": $$$$$$79, + $$$$$$67, + "deco-sites/ecannadeco/sections/Product/ImageGallerySlider.tsx": $$$$$$68, + "deco-sites/ecannadeco/sections/Product/NotFound.tsx": $$$$$$69, + "deco-sites/ecannadeco/sections/Product/NotFoundChallenge.tsx": $$$$$$70, + "deco-sites/ecannadeco/sections/Product/ProductDetails.tsx": $$$$$$71, + "deco-sites/ecannadeco/sections/Product/ProductInfo.tsx": $$$$$$72, + "deco-sites/ecannadeco/sections/Product/ProductShelf.tsx": $$$$$$73, + "deco-sites/ecannadeco/sections/Product/ProductShelfTabbed.tsx": $$$$$$74, + "deco-sites/ecannadeco/sections/Product/SearchResult.tsx": $$$$$$75, + "deco-sites/ecannadeco/sections/Product/ShelfWithImage.tsx": $$$$$$76, + "deco-sites/ecannadeco/sections/Product/Wishlist.tsx": $$$$$$77, + "deco-sites/ecannadeco/sections/Social/InstagramPosts.tsx": $$$$$$78, + "deco-sites/ecannadeco/sections/Social/WhatsApp.tsx": $$$$$$79, + "deco-sites/ecannadeco/sections/Theme/Theme.tsx": $$$$$$80, }, "actions": { "deco-sites/ecannadeco/actions/adminGetAssociation.ts": $$$$$$$$$0, diff --git a/sections/Miscellaneous/PrescriberPatientTreatment.tsx b/sections/Miscellaneous/PrescriberPatientTreatment.tsx new file mode 100644 index 0000000..07108ae --- /dev/null +++ b/sections/Miscellaneous/PrescriberPatientTreatment.tsx @@ -0,0 +1 @@ +export { default } from "../../islands/PrescriberPatientTreatment.tsx"; diff --git a/static/sprites.svg b/static/sprites.svg index 83adfe6..dbc5e12 100644 --- a/static/sprites.svg +++ b/static/sprites.svg @@ -1,4 +1,7 @@ + + + From 3f59e0786ffea5322b6355d859d45d1ea45ecabe Mon Sep 17 00:00:00 2001 From: Guilherme Baufaker Date: Wed, 15 May 2024 14:42:33 -0300 Subject: [PATCH 2/2] minor style change --- components/ui/PrescriberPatientTreatment.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ui/PrescriberPatientTreatment.tsx b/components/ui/PrescriberPatientTreatment.tsx index 8137e9d..55d39e2 100644 --- a/components/ui/PrescriberPatientTreatment.tsx +++ b/components/ui/PrescriberPatientTreatment.tsx @@ -53,7 +53,7 @@ const TreatmentCard = ({ treatment }: { treatment: Treatment }) => { {m.name} - + {m.dosage}