mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-22 16:27:55 -03:00
@@ -8,6 +8,7 @@
|
|||||||
import Spinner from '../ui/spinner/spinner.svelte';
|
import Spinner from '../ui/spinner/spinner.svelte';
|
||||||
import { register } from '@/hooks/register';
|
import { register } from '@/hooks/register';
|
||||||
import type { RegisterDto } from '../../../types';
|
import type { RegisterDto } from '../../../types';
|
||||||
|
import { invalidate } from '$app/navigation';
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -29,9 +30,18 @@
|
|||||||
cargando = true;
|
cargando = true;
|
||||||
error = '';
|
error = '';
|
||||||
|
|
||||||
await register(e, dto, () => {
|
await register(
|
||||||
|
e,
|
||||||
|
dto,
|
||||||
|
() => {
|
||||||
error = 'Error al registrar el usuario';
|
error = 'Error al registrar el usuario';
|
||||||
});
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
if (error == '') {
|
||||||
|
invalidate('admin:load');
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
|
|
||||||
cargando = false;
|
cargando = false;
|
||||||
}
|
}
|
||||||
@@ -57,11 +67,7 @@
|
|||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<InputGroupInput
|
<InputGroupInput type="email" disabled={cargando} bind:value={dto.email} />
|
||||||
type="email"
|
|
||||||
disabled={cargando}
|
|
||||||
bind:value={dto.email}
|
|
||||||
/>
|
|
||||||
<InputGroupAddon>Email</InputGroupAddon>
|
<InputGroupAddon>Email</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
@@ -71,11 +77,7 @@
|
|||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<InputGroupInput
|
<InputGroupInput type="password" disabled={cargando} bind:value={dto.password} />
|
||||||
type="password"
|
|
||||||
disabled={cargando}
|
|
||||||
bind:value={dto.password}
|
|
||||||
/>
|
|
||||||
<InputGroupAddon>Contraseña</InputGroupAddon>
|
<InputGroupAddon>Contraseña</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
@@ -90,11 +92,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button variant="secondary" disabled={cargando} onclick={() => (open = false)}>
|
||||||
variant="secondary"
|
|
||||||
disabled={cargando}
|
|
||||||
onclick={() => (open = false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import Label from '@/components/ui/label/label.svelte';
|
import Label from '@/components/ui/label/label.svelte';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { busquedaHashtags } from '@/hooks/busquedaHashtags';
|
import { busquedaHashtags } from '@/hooks/busquedaHashtags';
|
||||||
|
import Separator from '@/components/ui/separator/separator.svelte';
|
||||||
|
|
||||||
let search: string = $state('');
|
let search: string = $state('');
|
||||||
let open = $state(false);
|
let open = $state(false);
|
||||||
@@ -55,16 +56,18 @@
|
|||||||
<svelte:document onkeydown={handleKeydown} />
|
<svelte:document onkeydown={handleKeydown} />
|
||||||
|
|
||||||
<InputGroup class="group">
|
<InputGroup class="group">
|
||||||
<InputGroupAddon align="inline-start"><Search /></InputGroupAddon>
|
<InputGroupAddon class="me-3" align="inline-start"><Search /></InputGroupAddon>
|
||||||
|
<Separator orientation="vertical"></Separator>
|
||||||
|
|
||||||
<InputGroupInput
|
<InputGroupInput
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Buscar Usuario o Hashtag"
|
placeholder="Buscar Usuario o Hashtag"
|
||||||
bind:value={search}
|
bind:value={search}
|
||||||
oninput={() => (open = true)}
|
oninput={() => (open = true)}
|
||||||
class="max-w-0 transition-[max-width] duration-1000 ease-out group-hover:max-w-xs focus:max-w-xs"
|
class="max-w-0 p-1! transition-[max-width] duration-1000 ease-out group-hover:max-w-xs focus:max-w-xs"
|
||||||
/>
|
/>
|
||||||
<InputGroupAddon align="inline-end" class="flex gap-0">
|
<InputGroupAddon align="inline-end">
|
||||||
<Kbd>Ctrl</Kbd>+<Kbd>K</Kbd>
|
<Kbd>Ctrl+K</Kbd>
|
||||||
</InputGroupAddon>
|
</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
<CommandDialog bind:open>
|
<CommandDialog bind:open>
|
||||||
|
|||||||
@@ -52,14 +52,14 @@
|
|||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<a href="/" class="mr-6 flex items-center space-x-2">
|
<a href="/" class="mr-6 flex items-center space-x-2">
|
||||||
<Avatar
|
<Avatar
|
||||||
class="transform rounded-sm! transition-transform duration-300 ease-in-out hover:scale-130 hover:rotate-12"
|
class="h-8 w-8 transform rounded-sm! transition-transform duration-300 ease-in-out hover:scale-130 hover:rotate-12"
|
||||||
>
|
>
|
||||||
<AvatarImage src="/x.png" alt="minix" />
|
<AvatarImage src="/x.png" alt="minix" />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</a>
|
</a>
|
||||||
<nav class="me-2 items-center space-x-6 text-sm font-medium md:flex">
|
<!-- <nav class="me-2 items-center space-x-6 text-sm font-medium md:flex">
|
||||||
<ButtonTheme />
|
<ButtonTheme />
|
||||||
</nav>
|
</nav> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Desktop menu -->
|
<!-- Desktop menu -->
|
||||||
|
|||||||
+22
-20
@@ -1,36 +1,38 @@
|
|||||||
import { apiBase } from "@/stores/url";
|
import { apiBase } from '@/stores/url';
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from '$app/navigation';
|
||||||
import type { RegisterDto } from "../../types";
|
import type { RegisterDto } from '../../types';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
export async function register(e: SubmitEvent, dto: RegisterDto, callbackfn:()=>void){
|
export async function register(
|
||||||
|
e: SubmitEvent,
|
||||||
|
dto: RegisterDto,
|
||||||
|
callbackfn: () => void,
|
||||||
|
admin: boolean = false
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (dto.password == "" || dto.username == "" ||
|
if (
|
||||||
!dto.email?.includes("@") || dto.displayName=="") return;
|
dto.password == '' ||
|
||||||
|
dto.username == '' ||
|
||||||
|
!dto.email?.includes('@') ||
|
||||||
|
dto.displayName == ''
|
||||||
|
)
|
||||||
|
return;
|
||||||
try {
|
try {
|
||||||
|
const req = await fetch(get(apiBase) + '/api/auth/register', {
|
||||||
const { subscribe } = apiBase;
|
method: 'POST',
|
||||||
let baseUrl: string = '';
|
|
||||||
|
|
||||||
subscribe((value) => {
|
|
||||||
baseUrl = value;
|
|
||||||
})();
|
|
||||||
const req = await fetch(baseUrl + "/api/auth/register", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(dto)
|
body: JSON.stringify(dto)
|
||||||
});
|
});
|
||||||
if (req.ok) {
|
if (req.ok) {
|
||||||
const data = await req.json();
|
const data = await req.json();
|
||||||
goto("/login?msg="+data.message);
|
if (!admin) goto('/login?msg=' + data.message);
|
||||||
} else {
|
} else {
|
||||||
callbackfn();
|
callbackfn();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
callbackfn();
|
callbackfn();
|
||||||
console.error("fallo al intentar alcanzar el servidor")
|
console.error('fallo al intentar alcanzar el servidor');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { readable } from 'svelte/store';
|
import { readable } from 'svelte/store';
|
||||||
|
|
||||||
|
// export const apiBase = readable(
|
||||||
|
// dev ? 'http://localhost:5000' : 'https://minix-back-dsuk.onrender.com'
|
||||||
|
// );
|
||||||
|
|
||||||
export const apiBase = readable(
|
export const apiBase = readable(
|
||||||
dev ? 'http://localhost:5000' : 'https://minix-back-dsuk.onrender.com'
|
dev
|
||||||
|
? 'http://localhost:5000'
|
||||||
|
: 'https://minix-back-3.salmonpebble-66858787.brazilsouth.azurecontainerapps.io'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,14 +6,21 @@
|
|||||||
import TablaUsuarios from '@/components/TablaUsuarios.svelte';
|
import TablaUsuarios from '@/components/TablaUsuarios.svelte';
|
||||||
import CardTitle from '@/components/ui/card/card-title.svelte';
|
import CardTitle from '@/components/ui/card/card-title.svelte';
|
||||||
import CardHeader from '@/components/ui/card/card-header.svelte';
|
import CardHeader from '@/components/ui/card/card-header.svelte';
|
||||||
|
import type { UserResponseDto } from '../../../types';
|
||||||
|
|
||||||
let cargando = $state(true);
|
interface Prop {
|
||||||
let usuarios = $state(page.data.usuarios);
|
data: {
|
||||||
|
usuarios?: UserResponseDto[];
|
||||||
|
error: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let { data }: Prop = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex min-h-fit w-full items-center justify-center p-6 md:p-10">
|
<div class="flex min-h-fit w-full items-center justify-center p-6 md:p-10">
|
||||||
<div class="w-full max-w-6xl">
|
<div class="w-full max-w-6xl">
|
||||||
<Card class={page.data.error ? 'border-red-400' : ''}>
|
<Card class={data.error ? 'border-red-400' : ''}>
|
||||||
<CardHeader class="w-full">
|
<CardHeader class="w-full">
|
||||||
<CardTitle class="rounded-full bg-accent-foreground/10">
|
<CardTitle class="rounded-full bg-accent-foreground/10">
|
||||||
<h1 class="mt-3 mb-4 scroll-m-20 text-center text-2xl font-extrabold tracking-tight">
|
<h1 class="mt-3 mb-4 scroll-m-20 text-center text-2xl font-extrabold tracking-tight">
|
||||||
@@ -22,12 +29,10 @@
|
|||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{#if page.data.usuarios.length === 0}
|
{#if data.usuarios?.length === 0}
|
||||||
<CardDescription>No hay usuarios que mostar</CardDescription>
|
<CardDescription>No hay usuarios que mostar</CardDescription>
|
||||||
{:else}
|
{:else}
|
||||||
{#key page.data.usuarios}
|
<TablaUsuarios usuarios={data.usuarios || []}></TablaUsuarios>
|
||||||
<TablaUsuarios bind:usuarios></TablaUsuarios>
|
|
||||||
{/key}
|
|
||||||
{/if}
|
{/if}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,4 @@
|
|||||||
export interface Post {
|
export interface Post {
|
||||||
_id: string;
|
|
||||||
id: string;
|
id: string;
|
||||||
authorId: string;
|
authorId: string;
|
||||||
authorDisplayName: string;
|
authorDisplayName: string;
|
||||||
@@ -76,6 +75,7 @@ export interface PostResponseDto {
|
|||||||
isEdited: boolean;
|
isEdited: boolean;
|
||||||
visibility: string;
|
visibility: string;
|
||||||
hashtags: string[]?;
|
hashtags: string[]?;
|
||||||
|
isLiked: boolean?;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserResponseDto {
|
export interface UserResponseDto {
|
||||||
|
|||||||
Reference in New Issue
Block a user