-
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.
Merge pull request #3 from ucmo-cs/frontend/init
(Frontend): init the front end + login page layout
- Loading branch information
Showing
19 changed files
with
436 additions
and
37 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,87 @@ | ||
import { useState } from 'react' | ||
import {Button} from "@/components/ui/button.tsx"; | ||
import "@/index.css" | ||
import {useCallback, useEffect, useState} from 'react'; | ||
import {Button} from "@/components/ui/button"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCaption, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table"; | ||
import "@/index.css"; | ||
|
||
function App() { | ||
const [count, setCount] = useState(0) | ||
|
||
return ( | ||
<div className={"flex m-auto w-1/2 h-screen justify-center flex-col items-center"}> | ||
<h1>Vite + React</h1> | ||
<Button onClick={() => setCount((count) => count + 1)} variant={"destructive"}> | ||
count is {count} | ||
</Button> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to test HMR | ||
</p> | ||
<p className="read-the-docs"> | ||
Click on the Vite and React logos to learn more | ||
</p> | ||
</div> | ||
) | ||
const [accounts, setAccounts] = useState<Account[]>([]); | ||
|
||
const getFakeAccounts = useCallback(() => { | ||
fetch("http://localhost:8080/accounts") | ||
.then(response => response.json()) | ||
.then(data => setAccounts(data)) | ||
.catch(error => console.error(error)); | ||
}, [accounts]); | ||
|
||
const postFakeAccount = () => { | ||
fetch("http://localhost:8080/account", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify({ | ||
"acctId": 12, | ||
"userType": 0, | ||
"username": "test", | ||
"password": "password", | ||
"email": "[email protected]", | ||
"phoneNumber": "123-456-7890", | ||
}) | ||
}).then(response => response.json()) | ||
.then(data => console.log(data)) | ||
.then(() => getFakeAccounts()) | ||
.catch(error => console.error(error)); | ||
}; | ||
|
||
useEffect(() => { | ||
console.log("mounted"); // TODO remove | ||
|
||
getFakeAccounts(); | ||
|
||
return () => { | ||
console.log("unmounted"); // TODO remove | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className={"flex flex-col items-center"}> | ||
<h1>Commerce Bank Frontend</h1> | ||
<Button className="my-6" onClick={postFakeAccount}>This creates a fake class</Button> | ||
<Table> | ||
<TableCaption>list of Accounts in DB</TableCaption> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>Id</TableHead> | ||
<TableHead>Type</TableHead> | ||
<TableHead>username</TableHead> | ||
<TableHead>Password</TableHead> | ||
<TableHead>email</TableHead> | ||
<TableHead>phoneNumber</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{accounts.map((account) => ( | ||
<TableRow key={account.acctId}> | ||
<TableCell>{account.acctId}</TableCell> | ||
<TableCell>{account.userType}</TableCell> | ||
<TableCell>{account.username}</TableCell> | ||
<TableCell>{account.password}</TableCell> | ||
<TableCell>{account.email}</TableCell> | ||
<TableCell>{account.phoneNumber}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
) | ||
} | ||
|
||
export default App |
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,18 @@ | ||
import {Outlet} from "react-router-dom"; | ||
|
||
function Layout() { | ||
return ( | ||
<> | ||
<nav className={"py-3 w-11/12 mx-auto"}> | ||
<div className={"flex items-center bg-commerce-green rounded-full px-2 py-1 nav-shadow"}> | ||
<img src={"/commerce_globe_45x48.png"} alt={"Logo"} /> | ||
</div> | ||
</nav> | ||
<div className={"grow flex justify-center items-center"}> | ||
<Outlet /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default Layout; |
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,25 @@ | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> {} | ||
|
||
const Input = React.forwardRef<HTMLInputElement, InputProps>( | ||
({ className, type, ...props }, ref) => { | ||
return ( | ||
<input | ||
type={type} | ||
className={cn( | ||
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", | ||
className | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Input.displayName = "Input" | ||
|
||
export { Input } |
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,24 @@ | ||
import * as React from "react" | ||
import * as LabelPrimitive from "@radix-ui/react-label" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const labelVariants = cva( | ||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" | ||
) | ||
|
||
const Label = React.forwardRef< | ||
React.ElementRef<typeof LabelPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & | ||
VariantProps<typeof labelVariants> | ||
>(({ className, ...props }, ref) => ( | ||
<LabelPrimitive.Root | ||
ref={ref} | ||
className={cn(labelVariants(), className)} | ||
{...props} | ||
/> | ||
)) | ||
Label.displayName = LabelPrimitive.Root.displayName | ||
|
||
export { Label } |
Oops, something went wrong.