-
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 #19 from harley-codes/task/create-project-page
Create project page
- Loading branch information
Showing
35 changed files
with
1,150 additions
and
116 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
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,37 +1,40 @@ | ||
{ | ||
"name": "hobby-cms", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"dev:t": "next dev --turbo", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint", | ||
"lint:fix": "next lint --fix", | ||
"db:prisma-cockroach:generate": "prisma generate --schema=src/modules/database/vendors/prisma-cockroach/schema.prisma", | ||
"db:prisma-cockroach:migrate": "prisma migrate dev --name migrate --schema=src/modules/database/vendors/prisma-cockroach/schema.prisma" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@fontsource/roboto": "^5.0.8", | ||
"@mui/icons-material": "^5.14.13", | ||
"@mui/material": "^5.14.14", | ||
"@prisma/client": "5.7.1", | ||
"next": "13.5.6", | ||
"next-auth": "^4.24.3", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"sass": "^1.69.5" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"eslint": "^8", | ||
"eslint-config-next": "13.5.6", | ||
"typescript": "^5", | ||
"prisma": "^5.7.1" | ||
} | ||
"name": "hobby-cms", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"dev:t": "next dev --turbo", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint", | ||
"lint:fix": "next lint --fix", | ||
"db:prisma-cockroach:generate": "prisma generate --schema=src/modules/database/vendors/prisma-cockroach/schema.prisma", | ||
"db:prisma-cockroach:migrate": "prisma migrate dev --name migrate --schema=src/modules/database/vendors/prisma-cockroach/schema.prisma" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@fontsource/roboto": "^5.0.8", | ||
"@mui/icons-material": "^5.14.13", | ||
"@mui/material": "^5.14.14", | ||
"@prisma/client": "5.7.1", | ||
"@types/uuid": "^9.0.8", | ||
"linq": "^4.0.2", | ||
"next": "13.5.6", | ||
"next-auth": "^4.24.3", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"sass": "^1.69.5", | ||
"uuid": "^9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"eslint": "^8", | ||
"eslint-config-next": "13.5.6", | ||
"typescript": "^5", | ||
"prisma": "^5.7.1" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,17 @@ | ||
'use server' | ||
|
||
import { getDatabaseClientAsync } from '@/modules/database/databaseFactory' | ||
import { AccessTokenDetail } from '@/modules/database/responseTypes' | ||
|
||
export async function createProjectTokenServerAction(projectId: string): Promise<AccessTokenDetail> | ||
{ | ||
const client = await getDatabaseClientAsync() | ||
const token = await client.createAccessTokenAsync(projectId) | ||
return token | ||
} | ||
|
||
export async function deleteProjectTokenServerAction(tokenId: string): Promise<void> | ||
{ | ||
const client = await getDatabaseClientAsync() | ||
await client.deleteAccessTokenAsync(tokenId) | ||
} |
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 @@ | ||
'use server' | ||
|
||
import { getDatabaseClientAsync } from '@/modules/database/databaseFactory' | ||
import { ProjectUpdateValues } from '@/modules/database/requestTypes' | ||
import { ProjectDetail } from '@/modules/database/responseTypes' | ||
|
||
export async function createProjectServerAction(projectName: string, isActive: boolean): Promise<ProjectDetail> | ||
{ | ||
const client = await getDatabaseClientAsync() | ||
const project = await client.createProjectAsync(projectName, isActive) | ||
return project | ||
} | ||
|
||
export async function deleteProjectServerAction(projectId: string): Promise<void> | ||
{ | ||
const client = await getDatabaseClientAsync() | ||
await client.deleteProjectAsync(projectId) | ||
} | ||
|
||
export async function updateProjectServerAction(projectId: string, values: ProjectUpdateValues): Promise<ProjectDetail> | ||
{ | ||
const client = await getDatabaseClientAsync() | ||
const project = await client.updateProjectAsync(projectId, values) | ||
return project | ||
} |
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,14 +1,15 @@ | ||
import AppMenu from '@/app/dashboard/AppMenu' | ||
import { RequireSessionWrapper } from '@/modules/auth/RequireSessionWrapper' | ||
import { Container } from '@mui/material' | ||
|
||
export default function Layout(props: ChildProps) | ||
{ | ||
return ( | ||
<RequireSessionWrapper> | ||
<AppMenu /> | ||
<main> | ||
<Container maxWidth="lg" component="main"> | ||
{props.children} | ||
</main> | ||
</Container> | ||
</RequireSessionWrapper> | ||
) | ||
} |
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,9 +1,10 @@ | ||
import { Typography } from '@mui/material' | ||
|
||
export default function DashboardPage() | ||
{ | ||
return ( | ||
<> | ||
<h1>Dashboard</h1> | ||
<Typography variant="h4">Dashboard</Typography> | ||
</> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
src/app/dashboard/projects/_components/CreateProjectButton.tsx
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,11 @@ | ||
'use client' | ||
|
||
import { invokeNewProjectRequest } from '@/app/dashboard/projects/_components/CreateProjectDialog' | ||
import { Button } from '@mui/material' | ||
|
||
export function CreateProjectButton() | ||
{ | ||
return ( | ||
<Button onClick={() => invokeNewProjectRequest()}>Create Project</Button> | ||
) | ||
} |
98 changes: 98 additions & 0 deletions
98
src/app/dashboard/projects/_components/CreateProjectDialog.tsx
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,98 @@ | ||
'use client' | ||
|
||
import { invokeConfirmationModal } from '@/components/ConfirmationModal' | ||
import { createEvent } from '@/modules/custom-events/createEvent' | ||
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from '@mui/material' | ||
import { useState } from 'react' | ||
|
||
type Props = { | ||
currentProjectNames: string[] | ||
onCreateProject: (name: string) => void | ||
} | ||
|
||
const newProjectRequestEvent = createEvent<null>('newProjectRequest') | ||
|
||
export const invokeNewProjectRequest = () => newProjectRequestEvent.callEvent(null) | ||
|
||
const defaultState = { | ||
display: false, | ||
name: '', | ||
nameInUse: false, | ||
process: false | ||
} | ||
|
||
export function CreateProjectDialog(props: Props) | ||
{ | ||
const { currentProjectNames, onCreateProject } = props | ||
|
||
const [state, setState] = useState(defaultState) | ||
|
||
newProjectRequestEvent.useEvent(() => | ||
{ | ||
setState({ ...defaultState, display: true }) | ||
}) | ||
|
||
function setNameHandler(e: React.ChangeEvent<HTMLInputElement>) | ||
{ | ||
setState({ | ||
...state, | ||
name: e.currentTarget.value, | ||
nameInUse: currentProjectNames.includes(e.currentTarget.value) | ||
}) | ||
} | ||
|
||
function cancelHandler() | ||
{ | ||
setState({ ...state, display: false, process: false }) | ||
} | ||
|
||
function createStartHandler() | ||
{ | ||
if (state.nameInUse) return | ||
|
||
invokeConfirmationModal({ | ||
description: `Are you sure you want to create a project named "${state.name}"?`, | ||
onConfirmed: (confirmed) => | ||
{ | ||
if (confirmed) | ||
{ | ||
setState({ ...state, display: false, process: true }) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
function exitHandler() | ||
{ | ||
if (state.process) onCreateProject(state.name) | ||
setState(defaultState) | ||
} | ||
|
||
return ( | ||
<Dialog | ||
open={state.display} | ||
TransitionProps={{ | ||
onExited: exitHandler, | ||
}} | ||
fullWidth maxWidth="xs" | ||
> | ||
<DialogTitle>Create Project</DialogTitle> | ||
<DialogContent> | ||
<TextField | ||
label="Project Name" | ||
margin="normal" | ||
fullWidth | ||
value={state.name} | ||
onChange={setNameHandler} | ||
error={state.nameInUse} | ||
helperText={state.nameInUse ? 'Name already in use' : ' '} | ||
/> | ||
|
||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={cancelHandler}>Cancel</Button> | ||
<Button onClick={createStartHandler} disabled={state.nameInUse}>Create</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
} |
Oops, something went wrong.