Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented just the frontend signin for prescriber #31

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions components/ui/SignInFormPrescriber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { invoke } from "../../runtime.ts";
import { useState } from "preact/hooks";
import { IS_BROWSER } from "$fresh/runtime.ts";

export interface Props {
formTitle?: string;
}

interface SignInResponse {
AuthenticationResult: {
AccessToken: string;
};
}

function SignInFormPrescriber({ formTitle }: Props) {
const [password, setPassword] = useState<string>("");
const [email, setEmail] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false);

const handleSubmit = async (e: Event) => {
e.preventDefault();
setLoading(true);
try {
const data = await invoke["deco-sites/ecannadeco"].actions
.cognitoAdminSignIn(
{ email, password },
) as SignInResponse;
console.log({ data });
if (IS_BROWSER) {
localStorage.setItem(
"PrescriberAccessToken",
data.AuthenticationResult.AccessToken,
);
}
setLoading(false);
window.location.href = "/sys/admin/orders";
setEmail("");
setPassword("");
} catch (e) {
alert(
"Usuário ou senha incorretos",
);
console.log({ e });
setLoading(false);
}
};

return (
<div class="max-w-[480px] md:max-w-[600px]">
<form
class="form-control justify-start gap-2"
onSubmit={(e) => handleSubmit(e)}
>
<span class="text-2xl text-[#8b8b8b] font-semibold text-center my-4">
{formTitle}
</span>
<div class="flex flex-col gap-4">
<label class="w-full">
<div class="label pb-1">
<span class="label-text text-xs text-[#585858]">
Email
</span>
</div>
<input
class="input rounded-md text-[#8b8b8b] border-none w-full"
placeholder="Seu email"
name="email"
value={email}
onChange={(e) => e.target && setEmail(e.currentTarget.value)}
/>
</label>
<label class="w-full">
<div class="label pb-1">
<span class="label-text text-xs text-[#585858]">
Senha
</span>
</div>
<input
type="password"
class="input rounded-md text-[#8b8b8b] border-none w-full"
placeholder="Sua senha"
name="password"
value={password}
onChange={(e) => e.target && setPassword(e.currentTarget.value)}
/>
</label>
</div>
<button
type={"submit"}
class="btn btn-primary text-white mt-5 disabled:loading border-none uppercase text-sm font-semibold"
>
{loading ? "Entrando..." : "ENTRAR"}
</button>
</form>
</div>
);
}

export default SignInFormPrescriber;
18 changes: 18 additions & 0 deletions components/ui/SignInPrescriber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import SignInFormPrescriber from "deco-sites/ecannadeco/islands/SignInFormPrescriber.tsx";
import FormWrap from "./FormWrap.tsx";

export interface Props {
formTitle: string;
}

function SignIn(
{ formTitle }: Props,
) {
return (
<FormWrap>
<SignInFormPrescriber formTitle={formTitle} />
</FormWrap>
);
}

export default SignIn;
2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import * as $ShippingSimulation from "./islands/ShippingSimulation.tsx";
import * as $ShowMore from "./islands/ShowMore.tsx";
import * as $SignInForm from "./islands/SignInForm.tsx";
import * as $SignInFormAdmin from "./islands/SignInFormAdmin.tsx";
import * as $SignInFormPrescriber from "./islands/SignInFormPrescriber.tsx";
import * as $SignUpForm from "./islands/SignUpForm.tsx";
import * as $SignUpFormPrescriber from "./islands/SignUpFormPrescriber.tsx";
import * as $Signout from "./islands/Signout.tsx";
Expand Down Expand Up @@ -102,6 +103,7 @@ const manifest = {
"./islands/ShowMore.tsx": $ShowMore,
"./islands/SignInForm.tsx": $SignInForm,
"./islands/SignInFormAdmin.tsx": $SignInFormAdmin,
"./islands/SignInFormPrescriber.tsx": $SignInFormPrescriber,
"./islands/SignUpForm.tsx": $SignUpForm,
"./islands/SignUpFormPrescriber.tsx": $SignUpFormPrescriber,
"./islands/Signout.tsx": $Signout,
Expand Down
8 changes: 8 additions & 0 deletions islands/SignInFormPrescriber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Component from "deco-sites/ecannadeco/components/ui/SignInFormPrescriber.tsx";
import type { Props } from "deco-sites/ecannadeco/components/ui/SignInFormPrescriber.tsx";

function Island(props: Props) {
return <Component {...props} />;
}

export default Island;
87 changes: 45 additions & 42 deletions manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,28 @@ import * as $$$$$$53 from "./sections/Miscellaneous/PublicPageControl.tsx";
import * as $$$$$$54 from "./sections/Miscellaneous/PublicProfile.tsx";
import * as $$$$$$55 from "./sections/Miscellaneous/SignIn.tsx";
import * as $$$$$$56 from "./sections/Miscellaneous/SignInAdmin.tsx";
import * as $$$$$$59 from "./sections/Miscellaneous/Signout.tsx";
import * as $$$$$$57 from "./sections/Miscellaneous/SignUp.tsx";
import * as $$$$$$58 from "./sections/Miscellaneous/SignUpPrescriber.tsx";
import * as $$$$$$60 from "./sections/Miscellaneous/Slide.tsx";
import * as $$$$$$61 from "./sections/Miscellaneous/UserAlerts.tsx";
import * as $$$$$$62 from "./sections/Miscellaneous/UserAssociatedSignup.tsx";
import * as $$$$$$63 from "./sections/Newsletter/Newsletter.tsx";
import * as $$$$$$64 from "./sections/Product/ImageGalleryFrontBack.tsx";
import * as $$$$$$65 from "./sections/Product/ImageGallerySlider.tsx";
import * as $$$$$$66 from "./sections/Product/NotFound.tsx";
import * as $$$$$$67 from "./sections/Product/NotFoundChallenge.tsx";
import * as $$$$$$68 from "./sections/Product/ProductDetails.tsx";
import * as $$$$$$69 from "./sections/Product/ProductInfo.tsx";
import * as $$$$$$70 from "./sections/Product/ProductShelf.tsx";
import * as $$$$$$71 from "./sections/Product/ProductShelfTabbed.tsx";
import * as $$$$$$72 from "./sections/Product/SearchResult.tsx";
import * as $$$$$$73 from "./sections/Product/ShelfWithImage.tsx";
import * as $$$$$$74 from "./sections/Product/Wishlist.tsx";
import * as $$$$$$75 from "./sections/Social/InstagramPosts.tsx";
import * as $$$$$$76 from "./sections/Social/WhatsApp.tsx";
import * as $$$$$$77 from "./sections/Theme/Theme.tsx";
import * as $$$$$$57 from "./sections/Miscellaneous/SignInPrescriber.tsx";
import * as $$$$$$60 from "./sections/Miscellaneous/Signout.tsx";
import * as $$$$$$58 from "./sections/Miscellaneous/SignUp.tsx";
import * as $$$$$$59 from "./sections/Miscellaneous/SignUpPrescriber.tsx";
import * as $$$$$$61 from "./sections/Miscellaneous/Slide.tsx";
import * as $$$$$$62 from "./sections/Miscellaneous/UserAlerts.tsx";
import * as $$$$$$63 from "./sections/Miscellaneous/UserAssociatedSignup.tsx";
import * as $$$$$$64 from "./sections/Newsletter/Newsletter.tsx";
import * as $$$$$$65 from "./sections/Product/ImageGalleryFrontBack.tsx";
import * as $$$$$$66 from "./sections/Product/ImageGallerySlider.tsx";
import * as $$$$$$67 from "./sections/Product/NotFound.tsx";
import * as $$$$$$68 from "./sections/Product/NotFoundChallenge.tsx";
import * as $$$$$$69 from "./sections/Product/ProductDetails.tsx";
import * as $$$$$$70 from "./sections/Product/ProductInfo.tsx";
import * as $$$$$$71 from "./sections/Product/ProductShelf.tsx";
import * as $$$$$$72 from "./sections/Product/ProductShelfTabbed.tsx";
import * as $$$$$$73 from "./sections/Product/SearchResult.tsx";
import * as $$$$$$74 from "./sections/Product/ShelfWithImage.tsx";
import * as $$$$$$75 from "./sections/Product/Wishlist.tsx";
import * as $$$$$$76 from "./sections/Social/InstagramPosts.tsx";
import * as $$$$$$77 from "./sections/Social/WhatsApp.tsx";
import * as $$$$$$78 from "./sections/Theme/Theme.tsx";

const manifest = {
"loaders": {
Expand Down Expand Up @@ -194,30 +195,32 @@ const manifest = {
"deco-sites/ecannadeco/sections/Miscellaneous/PublicProfile.tsx": $$$$$$54,
"deco-sites/ecannadeco/sections/Miscellaneous/SignIn.tsx": $$$$$$55,
"deco-sites/ecannadeco/sections/Miscellaneous/SignInAdmin.tsx": $$$$$$56,
"deco-sites/ecannadeco/sections/Miscellaneous/Signout.tsx": $$$$$$59,
"deco-sites/ecannadeco/sections/Miscellaneous/SignUp.tsx": $$$$$$57,
"deco-sites/ecannadeco/sections/Miscellaneous/SignInPrescriber.tsx":
$$$$$$57,
"deco-sites/ecannadeco/sections/Miscellaneous/Signout.tsx": $$$$$$60,
"deco-sites/ecannadeco/sections/Miscellaneous/SignUp.tsx": $$$$$$58,
"deco-sites/ecannadeco/sections/Miscellaneous/SignUpPrescriber.tsx":
$$$$$$58,
"deco-sites/ecannadeco/sections/Miscellaneous/Slide.tsx": $$$$$$60,
"deco-sites/ecannadeco/sections/Miscellaneous/UserAlerts.tsx": $$$$$$61,
$$$$$$59,
"deco-sites/ecannadeco/sections/Miscellaneous/Slide.tsx": $$$$$$61,
"deco-sites/ecannadeco/sections/Miscellaneous/UserAlerts.tsx": $$$$$$62,
"deco-sites/ecannadeco/sections/Miscellaneous/UserAssociatedSignup.tsx":
$$$$$$62,
"deco-sites/ecannadeco/sections/Newsletter/Newsletter.tsx": $$$$$$63,
$$$$$$63,
"deco-sites/ecannadeco/sections/Newsletter/Newsletter.tsx": $$$$$$64,
"deco-sites/ecannadeco/sections/Product/ImageGalleryFrontBack.tsx":
$$$$$$64,
"deco-sites/ecannadeco/sections/Product/ImageGallerySlider.tsx": $$$$$$65,
"deco-sites/ecannadeco/sections/Product/NotFound.tsx": $$$$$$66,
"deco-sites/ecannadeco/sections/Product/NotFoundChallenge.tsx": $$$$$$67,
"deco-sites/ecannadeco/sections/Product/ProductDetails.tsx": $$$$$$68,
"deco-sites/ecannadeco/sections/Product/ProductInfo.tsx": $$$$$$69,
"deco-sites/ecannadeco/sections/Product/ProductShelf.tsx": $$$$$$70,
"deco-sites/ecannadeco/sections/Product/ProductShelfTabbed.tsx": $$$$$$71,
"deco-sites/ecannadeco/sections/Product/SearchResult.tsx": $$$$$$72,
"deco-sites/ecannadeco/sections/Product/ShelfWithImage.tsx": $$$$$$73,
"deco-sites/ecannadeco/sections/Product/Wishlist.tsx": $$$$$$74,
"deco-sites/ecannadeco/sections/Social/InstagramPosts.tsx": $$$$$$75,
"deco-sites/ecannadeco/sections/Social/WhatsApp.tsx": $$$$$$76,
"deco-sites/ecannadeco/sections/Theme/Theme.tsx": $$$$$$77,
$$$$$$65,
"deco-sites/ecannadeco/sections/Product/ImageGallerySlider.tsx": $$$$$$66,
"deco-sites/ecannadeco/sections/Product/NotFound.tsx": $$$$$$67,
"deco-sites/ecannadeco/sections/Product/NotFoundChallenge.tsx": $$$$$$68,
"deco-sites/ecannadeco/sections/Product/ProductDetails.tsx": $$$$$$69,
"deco-sites/ecannadeco/sections/Product/ProductInfo.tsx": $$$$$$70,
"deco-sites/ecannadeco/sections/Product/ProductShelf.tsx": $$$$$$71,
"deco-sites/ecannadeco/sections/Product/ProductShelfTabbed.tsx": $$$$$$72,
"deco-sites/ecannadeco/sections/Product/SearchResult.tsx": $$$$$$73,
"deco-sites/ecannadeco/sections/Product/ShelfWithImage.tsx": $$$$$$74,
"deco-sites/ecannadeco/sections/Product/Wishlist.tsx": $$$$$$75,
"deco-sites/ecannadeco/sections/Social/InstagramPosts.tsx": $$$$$$76,
"deco-sites/ecannadeco/sections/Social/WhatsApp.tsx": $$$$$$77,
"deco-sites/ecannadeco/sections/Theme/Theme.tsx": $$$$$$78,
},
"actions": {
"deco-sites/ecannadeco/actions/adminGetAssociation.ts": $$$$$$$$$0,
Expand Down
1 change: 1 addition & 0 deletions sections/Miscellaneous/SignInPrescriber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "../../components/ui/SignInPrescriber.tsx";
Loading