[Classroom][BE] Fixes #8 Fix error setting expiration date
This commit is contained in:
parent
c78dbf479f
commit
5f1a46747a
@ -52,7 +52,7 @@ pub async fn classroom_post_redirect(
|
||||
match response.text() {
|
||||
Ok(t) => {
|
||||
log_html(&t);
|
||||
Err(format!("Unexpected response from classroom."))
|
||||
Err(format!("Expected HTTP 302, got other code."))
|
||||
}
|
||||
Err(err) => Err(format!("Error getting text from response: {:?}", err)),
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ pub async fn update_expiration_date(
|
||||
email.into(),
|
||||
username.into(),
|
||||
new_expiration_date,
|
||||
user_id,
|
||||
protect_token.into(),
|
||||
)
|
||||
};
|
||||
@ -87,6 +88,7 @@ fn get_body(
|
||||
email: String,
|
||||
username: String,
|
||||
new_expiration_date: String,
|
||||
user_id: i32,
|
||||
protect_token: String,
|
||||
) -> String {
|
||||
format!(
|
||||
@ -251,7 +253,7 @@ Content-Disposition: form-data; name="protect_token"
|
||||
-----------------------------318235432819784070062970146417
|
||||
Content-Disposition: form-data; name="user_id"
|
||||
|
||||
2140
|
||||
{user_id}
|
||||
-----------------------------318235432819784070062970146417
|
||||
Content-Disposition: form-data; name="MAX_FILE_SIZE"
|
||||
|
||||
@ -267,7 +269,7 @@ Content-Disposition: form-data; name="picture_crop_image_base_64"
|
||||
-----------------------------318235432819784070062970146417
|
||||
Content-Disposition: form-data; name="item_id"
|
||||
|
||||
2140
|
||||
{user_id}
|
||||
-----------------------------318235432819784070062970146417--
|
||||
"#
|
||||
)
|
||||
|
@ -4,14 +4,16 @@ import { LoadingStatus, backend, useLoading, wait } from "../../utils/functions"
|
||||
import { LoadingIcon } from "../../icons/LoadingIcon";
|
||||
import { ArrowsClockwiseIcon } from "../../icons/ArrowsClockwiseIcon";
|
||||
import { JsonResult } from "../../types/JsonResult";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
export function AccountExpiration(props: {userId: number}) {
|
||||
const [expirationDate, setExpirationDate] = createSignal<string | null>(null); // YYYY-MM-DD
|
||||
const {status, setStatus} = useLoading();
|
||||
const {status, setStatus, error, setError} = useLoading();
|
||||
|
||||
const loading = createMemo(() => status() === LoadingStatus.Loading);
|
||||
|
||||
const loadExpiration = async() => {
|
||||
setError("");
|
||||
setStatus(LoadingStatus.Loading);
|
||||
setExpirationDate(null);
|
||||
if (import.meta.env.DEV) await wait(1500);
|
||||
@ -25,10 +27,16 @@ export function AccountExpiration(props: {userId: number}) {
|
||||
setStatus(LoadingStatus.Ok);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError<JsonResult<null>>) => {
|
||||
console.log(err);
|
||||
|
||||
setStatus(LoadingStatus.Error);
|
||||
|
||||
if (err.response?.status === 500) {
|
||||
setError(`Error: ${err?.response?.data?.Error}`);
|
||||
} else {
|
||||
setError("Error estableciendo fecha de expiracion. Revisar consola");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -78,7 +86,10 @@ export function AccountExpiration(props: {userId: number}) {
|
||||
/>
|
||||
</p>
|
||||
|
||||
<div class="text-right pt-2">
|
||||
<div class="pt-2 grid grid-cols-[auto_8.5rem] items-center gap-2">
|
||||
<span class="text-c-error">
|
||||
{error()}
|
||||
</span>
|
||||
<button
|
||||
class="bg-c-primary text-c-on-primary px-4 py-2 rounded-full cursor-pointer
|
||||
disabled:opacity-50 disabled:cursor-not-allowed relative"
|
||||
@ -87,7 +98,7 @@ export function AccountExpiration(props: {userId: number}) {
|
||||
onclick={setExpiration}
|
||||
>
|
||||
<span class="mr-6">
|
||||
Actualizar expiracion
|
||||
Actualizar
|
||||
</span>
|
||||
<span
|
||||
class="absolute top-1 right-2"
|
||||
|
Loading…
Reference in New Issue
Block a user