Skip to content

Commit

Permalink
feat: add researches
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Aug 24, 2023
1 parent 9549c44 commit 1073556
Show file tree
Hide file tree
Showing 13 changed files with 349 additions and 276 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@rjsf/core": "^5.12.1",
"@rjsf/mui": "^5.12.1",
"@rjsf/utils": "^5.12.1",
"@rjsf/validator-ajv6": "^5.12.1",
"@rjsf/validator-ajv8": "^5.12.1",
"@sentry/react": "^7.64.0",
"@sentry/vite-plugin": "^2.7.0",
Expand Down
17 changes: 10 additions & 7 deletions src/layouts/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const RootLayout: FC = () => {
useEffectOnce(() => {
const token = getToken()
if (token) {
navigate("/dashboard")
navigate("/research")
} else {
navigate("/auth/login")
}
Expand All @@ -42,16 +42,19 @@ export const RootLayout: FC = () => {
<Typography variant="h6" component="div">
RogueStats
</Typography>
<Tooltip title="构建版本" arrow>
<div className="bg-slate-800 text-white text-xs px-2 py-1 cursor-help">
{import.meta.env.VITE_BUILD_GIT_COMMIT || "未知构建"}
</div>
<Tooltip
title="构建版本"
arrow
className="bg-slate-800 hover:bg-slate-700 text-white text-xs px-2 py-1 cursor-help"
>
{import.meta.env.VITE_BUILD_GIT_COMMIT || "未知构建"}
</Tooltip>
<div className="flex-1" />
{token && <AccountButton />}
</Toolbar>
</AppBar>
<Container maxWidth="lg" className="pt-16">

<Container maxWidth="lg" className="pt-24">
<Outlet />
</Container>
</>
Expand Down Expand Up @@ -81,7 +84,7 @@ const AccountButton: FC = () => {

return (
<>
<Tooltip title="Account">
<Tooltip title="账户" arrow>
<IconButton
size="large"
aria-controls={open ? "account-menu-" : undefined}
Expand Down
57 changes: 0 additions & 57 deletions src/pages/Dashboard.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const LoginPage: FC = () => {

useEffectOnce(() => {
if (getToken()) {
navigate("/dashboard")
navigate("/research")
}
})

Expand All @@ -67,7 +67,7 @@ export const LoginPage: FC = () => {
},
onCompleted: data => {
toast.success(`已登录为 ${data.login.name}`)
navigate("/dashboard")
navigate("/research")
},
onError: error => {
console.debug(error)
Expand Down
137 changes: 0 additions & 137 deletions src/pages/__generated__/DashboardQuery.graphql.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/pages/__generated__/DashboardResearchFragment.graphql.ts

This file was deleted.

32 changes: 32 additions & 0 deletions src/pages/research/ResearchDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Card } from "@mui/material"
import validator from "@rjsf/validator-ajv8"
import { FC } from "react"
import { graphql, useLazyLoadQuery } from "react-relay"
import { useParams } from "react-router-dom"
import { Form } from "../../components/rjsf/Form"
import { ResearchDetailPageQuery } from "./__generated__/ResearchDetailPageQuery.graphql"

export const ResearchDetailPage: FC = () => {
const { id } = useParams<{ id: string }>()
if (!id) throw new Error("id is required")

const data = useLazyLoadQuery<ResearchDetailPageQuery>(
graphql`
query ResearchDetailPageQuery($id: ID!) {
research(id: $id) {
id
name
schema
}
}
`,
{ id },
)

return (
<Card className="p-4 shadow-lg">
<h1 className="text-lg">{data.research.name}</h1>
<Form schema={data.research.schema} validator={validator} />
</Card>
)
}
Loading

0 comments on commit 1073556

Please sign in to comment.