mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
add oauth
This commit is contained in:
@@ -19,20 +19,24 @@ export default async function CustomPageComponent(params: { customPage: CustomPa
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-screen">
|
||||
<div className="vcenter">
|
||||
<Image
|
||||
src={`data:image/png;base64,${customPage.image}`}
|
||||
alt=" "
|
||||
width={100}
|
||||
height={100}
|
||||
className="rounded-full"
|
||||
className="rounded-full zoom-animated"
|
||||
/>
|
||||
|
||||
<h1 className="mt-5 text-center">{customPage.title}</h1>
|
||||
<div className="w-full max-w-96 mb-40 p-2">
|
||||
<h1 className="mt-5 text-center zoom-animated">{customPage.title}</h1>
|
||||
<div className="w-full max-w-96 p-2">
|
||||
|
||||
{linkBlocks.map((block) => (
|
||||
<button key={block.uuid} className="bg-slate-600 hover:bg-slate-500 w-full my-2">
|
||||
{linkBlocks.map((block, index) => (
|
||||
<button
|
||||
key={block.uuid}
|
||||
className="bg-slate-600 hover:bg-slate-500 w-full my-2 slide-animated"
|
||||
style={{ animationDelay: `${1.5 + index * 0.1}s` }}
|
||||
>
|
||||
<a href={`/${block.redirectPage.page.shortcode}`}>
|
||||
<div className="relative flex items-center">
|
||||
<div className="flex-shrink-0"><LinkFavicon url={block.redirectPage.dest} /></div>
|
||||
@@ -42,7 +46,12 @@ export default async function CustomPageComponent(params: { customPage: CustomPa
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="text-slate-700"><a className="underline" target="blank" href="https://github.com/traberph/short">traberph/short</a> by me running on <a className="underline" href="https://k3s.io/" target="blank">K3s</a></div>
|
||||
<div
|
||||
className="text-slate-700 mt-10 fade-animated"
|
||||
style={{ animationDelay: `${1.5 + linkBlocks.length * 0.1}s`, opacity: 0 }}
|
||||
>
|
||||
<a className="underline" target="blank" href="https://github.com/traberph/short">traberph/short</a> by me running on <a className="underline" href="https://k3s.io/" target="blank">K3s</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { CustomPage } from "@prisma/client"
|
||||
import prisma from "../../prisma/prisma"
|
||||
import CreateLinkBlockForm from "./forms/createLinkBlockForm"
|
||||
import DeleteLinkBlockForm from "./forms/deleteLinkBlockForm"
|
||||
import { ArrowTopRightOnSquareIcon, ArrowTrendingUpIcon, ArrowUpCircleIcon, ArrowUpRightIcon } from "@heroicons/react/24/solid"
|
||||
|
||||
export default async function CustomPageDashboard(params: { customPage: CustomPage }) {
|
||||
|
||||
@@ -30,12 +31,12 @@ export default async function CustomPageDashboard(params: { customPage: CustomPa
|
||||
<div>connected link page: <span className="font-bold">{block.redirectPage.page.shortcode}</span></div>
|
||||
<div className="ml-auto">
|
||||
<button>
|
||||
<a href={`/${block.redirectPage.page.shortcode}`} className="btn btn-primary">Visit</a>
|
||||
<a href={`/${block.redirectPage.page.shortcode}`} className="btn btn-primary"><ArrowTopRightOnSquareIcon className="button-icon" /></a>
|
||||
</button>
|
||||
</div>
|
||||
<div className="ml-5">
|
||||
<button>
|
||||
<a href={`/~/dash/${block.redirectPage.page.uuid}`} className="btn btn-primary">Details</a>
|
||||
<a href={`/~/dash/${block.redirectPage.page.uuid}`} className="btn btn-primary"><ArrowTrendingUpIcon className="button-icon" /></a>
|
||||
</button>
|
||||
</div>
|
||||
<div className="ml-5">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client"
|
||||
import { createCustomPage } from "@/actions/page_actions";
|
||||
import { useActionState } from "react";
|
||||
import { useActionState, useEffect } from "react";
|
||||
import SubmitButton from "../SubmitButton";
|
||||
import { handleToast } from "@/utils";
|
||||
|
||||
|
||||
export default function CreateCustomPageForm() {
|
||||
@@ -13,6 +14,8 @@ export default function CreateCustomPageForm() {
|
||||
|
||||
const [state, formAction] = useActionState(createCustomPage, initialState);
|
||||
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
return (
|
||||
<form action={formAction}>
|
||||
<div className="form-group">
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"use client"
|
||||
import { createLinkBlock } from "@/actions/block_actions"
|
||||
import { useActionState } from "react";
|
||||
import { useActionState, useEffect } from "react";
|
||||
import SubmitButton from "../SubmitButton";
|
||||
import toast from "react-hot-toast";
|
||||
import { handleToast } from "@/utils";
|
||||
import { LinkIcon } from "@heroicons/react/24/solid";
|
||||
|
||||
|
||||
export default function CreateLinkBlockForm({ customPage, shortcodes }: { customPage: string, shortcodes: string[] }) {
|
||||
@@ -13,6 +16,8 @@ export default function CreateLinkBlockForm({ customPage, shortcodes }: { custom
|
||||
|
||||
const [state, formAction] = useActionState(createLinkBlock, initialState);
|
||||
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
return (<form action={formAction}>
|
||||
<div className="form-group">
|
||||
<label htmlFor="redirectPageShortcode">Redirect Page</label>
|
||||
@@ -32,8 +37,7 @@ export default function CreateLinkBlockForm({ customPage, shortcodes }: { custom
|
||||
<p className="form-label-error">{state.error?.order}</p>
|
||||
</div>
|
||||
<input type="hidden" name="customPageUuid" value={customPage} />
|
||||
<p className="mb-2">{state.message}</p>
|
||||
<SubmitButton>add to page</SubmitButton>
|
||||
<SubmitButton>add to page <LinkIcon className="ml-2 button-icon" /></SubmitButton>
|
||||
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { createRedirectPage } from "@/actions/page_actions";
|
||||
import { useActionState } from "react";
|
||||
import { useActionState, useEffect } from "react";
|
||||
import SubmitButton from "../SubmitButton";
|
||||
import toast from "react-hot-toast";
|
||||
import { handleToast } from "@/utils";
|
||||
|
||||
export default function CreateRedirectPageForm() {
|
||||
const initialState = {
|
||||
@@ -11,6 +13,8 @@ export default function CreateRedirectPageForm() {
|
||||
};
|
||||
const [state, formAction] = useActionState(createRedirectPage, initialState);
|
||||
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
return (
|
||||
<form action={formAction}>
|
||||
<div className="form-group">
|
||||
@@ -23,7 +27,6 @@ export default function CreateRedirectPageForm() {
|
||||
<input type='text' name='dest' id='dest' className={state.error?.dest ? "border-red-400" : ""} />
|
||||
<p className="form-label-error">{state.error?.dest}</p>
|
||||
</div>
|
||||
<p>{state.message}</p>
|
||||
<SubmitButton />
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
"use client"
|
||||
|
||||
import { deleteLinkBlock } from "@/actions/block_actions";
|
||||
import { useActionState } from "react";
|
||||
import { useActionState, useEffect } from "react";
|
||||
import SubmitButton from "../SubmitButton";
|
||||
import { handleToast } from "@/utils";
|
||||
import { LinkSlashIcon } from "@heroicons/react/24/solid";
|
||||
|
||||
export default function DeleteLinkBlockForm({linkBlockUuid}: {linkBlockUuid:string}) {
|
||||
export default function DeleteLinkBlockForm({ linkBlockUuid }: { linkBlockUuid: string }) {
|
||||
|
||||
const initialState = {
|
||||
message: "",
|
||||
@@ -13,11 +15,14 @@ export default function DeleteLinkBlockForm({linkBlockUuid}: {linkBlockUuid:stri
|
||||
|
||||
const [state, formAction] = useActionState(deleteLinkBlock, initialState);
|
||||
|
||||
return (<form action={formAction}>
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
<input type="hidden" name="uuid" id="uuid" value={linkBlockUuid}/>
|
||||
<SubmitButton>unlink</SubmitButton>
|
||||
return (<form action={formAction}>
|
||||
<input type="hidden" name="uuid" id="uuid" value={linkBlockUuid} />
|
||||
<SubmitButton>
|
||||
<LinkSlashIcon className="button-icon" />
|
||||
</SubmitButton>
|
||||
</form>
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
@@ -1,22 +1,26 @@
|
||||
"use client"
|
||||
|
||||
import { deletePage } from "@/actions/page_actions";
|
||||
import { useActionState } from "react";
|
||||
import { useActionState, useEffect } from "react";
|
||||
import SubmitButton from "../SubmitButton";
|
||||
import { redirect } from "next/navigation";
|
||||
import toast from "react-hot-toast";
|
||||
import { handleToast } from "@/utils";
|
||||
import { TrashIcon } from "@heroicons/react/24/solid";
|
||||
|
||||
export default function DeletePageForm({uuid}: {uuid: string}) {
|
||||
export default function DeletePageForm({ uuid }: { uuid: string }) {
|
||||
|
||||
const initialState = {
|
||||
message: "",
|
||||
error: {},
|
||||
};
|
||||
};
|
||||
const [state, formAction] = useActionState(deletePage, initialState);
|
||||
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
return (
|
||||
<form action={formAction}>
|
||||
<input type="hidden" name="uuid" value={uuid}/>
|
||||
<SubmitButton>Delete</SubmitButton>
|
||||
<input type="hidden" name="uuid" value={uuid} />
|
||||
<SubmitButton><TrashIcon className="button-icon" /></SubmitButton>
|
||||
</form>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"use client"
|
||||
import { pinPageToRoot } from "@/actions/page_actions";
|
||||
import { BookmarkIcon } from "@heroicons/react/24/solid";
|
||||
import { useActionState, useState } from "react";
|
||||
import { handleToast } from "@/utils";
|
||||
import { BookmarkIcon, BookmarkSlashIcon } from "@heroicons/react/24/solid";
|
||||
import { use, useActionState, useEffect, useState } from "react";
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
export default function PinPageToRootForm({ pageUuid, disabled }: { pageUuid: string, disabled: boolean }) {
|
||||
export default function PinPageToRootForm({ pageUuid, pinned }: { pageUuid: string, pinned: boolean }) {
|
||||
|
||||
const initialState = {
|
||||
message: "",
|
||||
@@ -12,10 +14,17 @@ export default function PinPageToRootForm({ pageUuid, disabled }: { pageUuid: st
|
||||
|
||||
const [state, formAction] = useActionState(pinPageToRoot, initialState);
|
||||
|
||||
useEffect(() => { handleToast(state); }, [state]);
|
||||
|
||||
return ( <form action={formAction}>
|
||||
return (<form action={formAction}>
|
||||
<input type="hidden" name="uuid" value={pageUuid} />
|
||||
{/* <p>{state.message}</p> */}
|
||||
<button type="submit" className="btn btn-primary" disabled={disabled}><BookmarkIcon className="h-5 w-5 inline-block align-middle"/></button>
|
||||
<input type="hidden" name="unpin" value={"" + pinned} />
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{pinned ?
|
||||
<BookmarkSlashIcon className="h-5 w-5 inline-block align-middle" />
|
||||
:
|
||||
<BookmarkIcon className="h-5 w-5 inline-block align-middle" />
|
||||
}
|
||||
</button>
|
||||
</form>)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { signIn } from "@/auth"
|
||||
|
||||
export default function SignInButton() {
|
||||
return (<div>
|
||||
<form
|
||||
action={async () => {
|
||||
"use server"
|
||||
await signIn("authentik")
|
||||
}}
|
||||
>
|
||||
<button type="submit">Sign In</button>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { signOut } from "@/auth"
|
||||
|
||||
export default function SignOutButton() {
|
||||
return (
|
||||
<form
|
||||
className="flex"
|
||||
action={async () => {
|
||||
"use server"
|
||||
await signOut()
|
||||
}}
|
||||
>
|
||||
<button className='ml-auto bg-transparent p-1 hover:underline hover:bg-transparent' type="submit">logout</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user