import { h } from "../jsx.ts";
import watt, { Story, watt as originalWatt } from "../wattpad.ts";
import wattpad, { User } from "../wattpad.ts";
import { Context } from "../oak.ts";
import Base from "../templates/Base.tsx";
import FourOhFour from "./404.tsx";
export default async (params: URLSearchParams, ctx: Context) => {
const name = params.get("name");
const chapterNumber = Number(params.get("page")) ?? 0;
if (!name) {
throw "deez";
}
const user = new User(originalWatt.session, name);
try {
await user.init();
await user.updateStories(chapterNumber);
} catch {
return FourOhFour(undefined, ctx);
}
const res: Story[] = [];
for (let i = 0; i < user.stories.length; i++) {
const rizz = await watt.getStory(user.stories[i].id, false);
res.push(
{rizz.storyJSON.description}{rizz.name}
{user.description
? user.description.replaceAll("\n", "
")
: undefined}