Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: deno lint

- name: Test
run: deno task start && CHROME_BIN=$(which chrome) deno task test --quiet
run: deno task dev & deno task start && CHROME_BIN=$(which chrome) deno task test --quiet
2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// This file is automatically updated during development when running `dev.ts`.

import * as $0 from "./routes/index.tsx";
import * as $1 from "./routes/jobs/[job].tsx";

const manifest = {
routes: {
"./routes/index.tsx": $0,
"./routes/jobs/[job].tsx": $1,
},
islands: {},
baseUrl: import.meta.url,
Expand Down
23 changes: 22 additions & 1 deletion routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/** @jsx h */
import { h } from "preact";

export default function Home() {
import type { Handlers, PageProps } from "$fresh/server.ts";

export const handler: Handlers<string> = {
async POST(req, ctx) {
const formData = await req.formData();

const job = formData.get("job") as string;

return job
? Response.redirect(`http://localhost:8000/jobs/${job}`)
: ctx.render("error: empty input");
},
};

export default function Home({ data }: PageProps<string>) {
return (
<div>
<a href="https://www.active-connector.com/">
Expand All @@ -13,6 +27,13 @@ export default function Home() {
<h2>
Skill Test (Software Engineer)
</h2>

<form method="POST">
<input type="text" id="job" name="job" />
<button type="submit">Search Job</button>
</form>

{data ? <p>{data}</p> : null}
</div>
);
}
18 changes: 18 additions & 0 deletions routes/jobs/[job].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @jsx h */
import { h } from "preact";

import type { PageProps } from "$fresh/server.ts";

function searchJob(job: string) {
if (job === "engineer") {
return `Job "engineer" is open for you!`;
}

return `Job "${job}" is not available`;
}

export default function JobPage(props: PageProps) {
const { job } = props.params;

return <div>{searchJob(job)}</div>;
}