-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move logged in email from landing page to meta tag * feat: header with logout link * feat: landing page * test: mock fetch for all tests * test: can open modal from landing page * feat: button hover colors * standardize colors in tailwind config
- Loading branch information
Showing
14 changed files
with
144 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const Header = () => { | ||
return ( | ||
<div className="w-full bg-gray-100 p-2 flex justify-between"> | ||
<img src="/images/logo.svg" alt="MBTA" className="w-8" /> | ||
<a href="/logout" className="underline p-1"> | ||
Log out | ||
</a> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,72 @@ | ||
import { OperatorSignInModal } from "./operatorSignIn/operatorSignInModal"; | ||
import { ReactElement } from "react"; | ||
import { DateTime } from "luxon"; | ||
import { ReactElement, useMemo, useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const Home = (): ReactElement => { | ||
const [modalOpen, setModalOpen] = useState(false); | ||
// check once to avoid it changing while looking at the page | ||
// no attempt yet to verify time zones / rolling the date at a time other than midnight | ||
const today = useMemo<string>(() => DateTime.now().toISODate(), []); | ||
const [selectedDate, setSelectedDate] = useState<string>(today); | ||
return ( | ||
<> | ||
<div className="text-3xl"> | ||
🪐 | ||
<span className="text-mbta-orange">O</span> | ||
<span className="text-mbta-red">r</span> | ||
<span className="text-mbta-blue">b</span>it | ||
<div> | ||
<Link to="/list"> | ||
<button className="bg-mbta-blue text-gray-100 rounded-md p-2 text-sm m-5"> | ||
Sign-in history | ||
</button> | ||
</Link> | ||
</div> | ||
<div className="max-w-lg mx-auto"> | ||
<div className="flex justify-between"> | ||
<hgroup className="mb-3"> | ||
<h1 className="text-xl">Operators</h1> | ||
<p>Search and sign in operators</p> | ||
</hgroup> | ||
<button | ||
className="rounded bg-gray-900 hover:bg-gray-600 text-white p-1 self-center" | ||
onClick={() => { | ||
setModalOpen(true); | ||
}} | ||
> | ||
Sign In Operator | ||
</button> | ||
</div> | ||
<OperatorSignInModal /> | ||
</> | ||
<div className="flex justify-between gap-2 items-end mb-3"> | ||
<label className="flex flex-col"> | ||
<span className="text-sm">Service Date</span> | ||
<input | ||
type="date" | ||
value={selectedDate} | ||
onChange={(evt) => { | ||
setSelectedDate(evt.target.value); | ||
}} | ||
className="rounded" | ||
/> | ||
</label> | ||
<button | ||
className="rounded border border-gray-300 hover:bg-gray-50 px-2 py-1 disabled:text-gray-300" | ||
disabled={selectedDate === today} | ||
onClick={() => { | ||
setSelectedDate(today); | ||
}} | ||
> | ||
Today | ||
</button> | ||
<button | ||
className="rounded border border-gray-300 hover:bg-gray-50 px-2 py-1" | ||
onClick={() => { | ||
console.log("TODO"); | ||
}} | ||
> | ||
Export Records | ||
</button> | ||
</div> | ||
<p className="mb-3">(Search will go here)</p> | ||
<Link className="block" to="/list"> | ||
<button className="bg-mbta-blue text-gray-100 rounded-md p-2 text-sm"> | ||
Sign-in history | ||
</button> | ||
</Link> | ||
<OperatorSignInModal | ||
show={modalOpen} | ||
close={() => { | ||
setModalOpen(false); | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { Home } from "../../components/home"; | ||
import { render } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
|
||
jest.mock("../../components/operatorSignIn/operatorSignInModal", () => ({ | ||
OperatorSignInModal: () => <div>Mock modal</div>, | ||
})); | ||
|
||
describe("home", () => { | ||
test("loads orbit placeholder", () => { | ||
test("can open modal", async () => { | ||
const view = render( | ||
<MemoryRouter> | ||
<Home /> | ||
</MemoryRouter>, | ||
); | ||
expect(view.getByText(/🪐/)).toBeInTheDocument(); | ||
expect(view.queryByText(/fit for duty/i)).not.toBeInTheDocument(); | ||
await userEvent.click( | ||
view.getByRole("button", { name: "Sign In Operator" }), | ||
); | ||
expect(view.getByText(/fit for duty/i)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import "@testing-library/jest-dom"; | ||
import { neverPromise } from "./helpers/promiseWithResolvers"; | ||
// add all jest-extended matchers | ||
import * as jestExtendedMatchers from "jest-extended"; | ||
|
||
expect.extend(jestExtendedMatchers); | ||
|
||
jest.mock("../browser", () => ({ | ||
fetch: jest.fn(() => neverPromise()), | ||
reload: jest.fn(), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters