Skip to content

Commit

Permalink
integrated bulkcreateusers in association admin
Browse files Browse the repository at this point in the history
  • Loading branch information
baufaker committed May 14, 2024
1 parent 2ca891f commit e19f8b7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
5 changes: 4 additions & 1 deletion components/ui/AssociationAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ function MyAccount() {
</div>
</div>
<PreSignupUsersModal
onFinish={() => console.log("on finish")}
onFinish={() => {
displayPreSignupUsersModal.value = false;
handleGetUsers(1);
}}
/>
<AdminNewDocModal createType={createType} />
{isLoadingUsers
Expand Down
41 changes: 35 additions & 6 deletions components/ui/PreSignupUsersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Icon from "../../components/ui/Icon.tsx";
import { useState } from "preact/hooks";
import { useUI } from "../../sdk/useUI.ts";
import { h } from "preact";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { invoke } from "../../runtime.ts";

export interface Props {
onFinish: () => void;
Expand All @@ -22,14 +24,41 @@ const PreSignupUsersModal = ({ onFinish }: Props) => {
}
};

const handleCreate = () => {
const handleCreate = async () => {
let accessToken = "";

if (IS_BROWSER) {
accessToken = localStorage.getItem("AccessToken") || "";
}

setIsUploading(true);

try {
console.log("oi");
} catch (e) {
console.log({ erroUpload: e });
setIsUploading(false);
if (file) {
const formData = new FormData();
formData.append("file", file);

try {
const response = await fetch(
"https://service.ecanna.com.br/profile/",
{
method: "POST",
body: formData,
headers: {
Authorization: accessToken,
ContentType: "multipart/form-data",
},
},
);
const r = await response.json();

console.log({ responsePresignup: r });
setIsUploading(false);

onFinish();
} catch (e) {
console.log({ erroUpload: e });
setIsUploading(false);
}
}
};

Expand Down

0 comments on commit e19f8b7

Please sign in to comment.