Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(platform): Added screen for CREATE NEW PROJECT #540

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
41 changes: 22 additions & 19 deletions apps/platform/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { toast } from 'sonner'
import { useRouter } from 'next/navigation'
import type {
CreateProjectRequest,
CreateProjectResponse
CreateProjectResponse,
Workspace
} from '@keyshade/schema'
import { ProjectController } from '@keyshade/api-client'
import { AddSVG } from '@public/svg/shared'
Expand Down Expand Up @@ -41,7 +42,6 @@ import {
DialogTrigger
} from '@/components/ui/dialog'
import { Projects } from '@/lib/api-functions/projects'
import { z } from 'zod'

export default function Index(): JSX.Element {
const [isSheetOpen, setIsSheetOpen] = useState<boolean>(false)
Expand All @@ -53,16 +53,16 @@ export default function Index(): JSX.Element {
environments: [
{
name: '',
description: '',
isDefault: false
projectId: Date.now().toString(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just set it to ''. Either ways, this won't be sent to the backend

description: ''
}
],
accessLevel: 'GLOBAL'
})

const router = useRouter()

const createNewProject = async () => {
const createNewProject = async () => {
const projectController = new ProjectController(
process.env.NEXT_PUBLIC_BACKEND_URL
)
Expand All @@ -77,20 +77,23 @@ export default function Index(): JSX.Element {

const response = await projectController.createProject(request, {})

if (response.success) {
const data = response.data as CreateProjectResponse;

if (response.success && response.data ) {

const createdProject: ProjectWithoutKeys = {
id: response.data.id,
name: response.data.name,
description: response.data.description,
createdAt: response.data.createdAt,
updatedAt: response.data.updatedAt,
storePrivateKey: response.data.storePrivateKey,
isDisabled: response.data.isDisabled,
accessLevel: response.data.accessLevel,
lastUpdatedById: response.data.lastUpdatedById,
workspaceId: response.data.workspaceId,
isForked: response.data.isForked,
forkedFromId: response.data.forkedFromId
id: data.id,
name: data.name,
description: data.description,
createdAt: data.createdAt,
updatedAt: data.updatedAt,
storePrivateKey: data.storePrivateKey,
isDisabled: data.isDisabled,
accessLevel: data.accessLevel as "GLOBAL" | "INTERNAL" | "PRIVATE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Access level is already inferred as these types.

lastUpdatedById: data.lastUpdatedById,
workspaceId: data.workspaceId,
isForked: data.isForked,
forkedFromId: data.forkedFromId
}

setProjects((prevProjects) => [...prevProjects, createdProject])
Expand Down Expand Up @@ -285,7 +288,7 @@ export default function Index(): JSX.Element {
<div className="flex h-[2.25rem] w-[25.625rem] justify-end">
<Button
className="font-inter h-[2.25rem] w-[8rem] rounded-[0.375rem] text-[0.875rem] font-[500]"
onClick={() => void createNewProject()}
onClick={createNewProject}
variant="secondary"
>
Create project
Expand Down
1 change: 1 addition & 0 deletions apps/platform/src/app/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function AuthPage(): React.JSX.Element {
setInInvalidEmail(false)

try {

const response = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/send-otp/${encodeURIComponent(userEmail)}`,
{
Expand Down
8 changes: 6 additions & 2 deletions apps/platform/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export const zProject = z.object({

export const zEnvironment = z.object({
name: z.string(),
description: z.string().nullable(),
isDefault: z.boolean().optional()
projectId: z.string(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use these. We already have type definitions set in the schema package.

description: z.string().optional()

// description: z.string().nullable(),
// isDefault: z.boolean().optional(),

})

export const zNewProject = z.object({
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ProjectSchema = z
privateKey: z.string(),
storePrivateKey: z.boolean(),
isDisabled: z.boolean(),
accessLevel: z.string(),
accessLevel: projectAccessLevelEnum,
pendingCreation: z.boolean(),
isForked: z.boolean(),
lastUpdatedById: z.string(),
Expand Down
Loading