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

chore(platform): Added optional chaining due to strict null check #413

Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions apps/platform/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ export default function Index(): JSX.Element {

const router = useRouter()

const currentWorkspace = JSON.parse(
localStorage.getItem('currentWorkspace') ?? '{}'
) as Workspace
const currentWorkspace =
typeof localStorage !== 'undefined'
? (JSON.parse(
localStorage.getItem('currentWorkspace') ?? '{}'
) as Workspace)
: (JSON.parse(`{}`) as Workspace)

useEffect(() => {
Projects.getProjectsbyWorkspaceID(currentWorkspace.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function SecretPage(): React.JSX.Element {
collapsible
type="single"
>
{allSecrets.map((secret) => {
{allSecrets?.map((secret) => {
return (
<AccordionItem
className="rounded-xl bg-white/5 px-5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function DetailedProjectPage({
return (
<main className="flex flex-col gap-4">
<div className="flex justify-between ">
<div className="text-3xl">{currentProject.name}</div>
<div className="text-3xl">{currentProject?.name}</div>
<Dialog>
<DialogTrigger>
<Button>
Expand Down
6 changes: 3 additions & 3 deletions apps/platform/src/app/auth/invite/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function AuthDetailsPage(): React.JSX.Element {
const inputRef = useRef<HTMLInputElement>(null)

useEffect(() => {
inputRef.current.focus()
inputRef.current?.focus()
}, [])

return (
Expand Down Expand Up @@ -38,12 +38,12 @@ export default function AuthDetailsPage(): React.JSX.Element {
<div
className={`${NunitoSansFont.className} flex h-[10vh] cursor-text flex-col items-start gap-1 rounded-md border border-white/10 bg-neutral-800 px-3 py-2 text-sm`}
onClick={() => {
inputRef.current.focus()
inputRef.current?.focus()
}}
onKeyDown={(e) => {
// Enter or space key
if (e.key === 'Enter' || e.key === ' ') {
inputRef.current.focus()
inputRef.current?.focus()
}
}}
role="button"
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/components/shared/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function fetchNameImage(): Promise<UserNameImage | undefined> {
throw new Error('Invalid data')
}
return {
name: data.name.split(' ')[0] ?? data.email.split('@')[0],
name: data.name?.split(' ')[0] ?? data.email.split('@')[0],
image: data.profilePictureUrl
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/components/teams/teamTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const columns: ColumnDef<Payment>[] = [
aria-label="Select all"
checked={
table.getIsAllPageRowsSelected() ||
(table.getIsSomePageRowsSelected() && 'indeterminate')
Boolean(table.getIsSomePageRowsSelected() && 'indeterminate')
}
onCheckedChange={(value) => {
table.toggleAllPageRowsSelected(Boolean(value))
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/components/ui/line-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function LineTab({ customID, tabs }: LineTabsProps): React.JSX.Element {
customID={customID}
key={tab}
searchParams={searchParams}
selected={search.toLocaleLowerCase() === tab.toLocaleLowerCase()}
selected={search?.toLocaleLowerCase() === tab.toLocaleLowerCase()}
text={tab}
/>
))}
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try {
if (error instanceof z.ZodError) {
const { fieldErrors } = error.flatten()
const errorMessage = Object.entries(fieldErrors)
.map(([field, errors]) => `${field}: ${errors.join(', ')}`)
.map(([field, errors]) => `${field}: ${errors?.join(', ')}`)
.join('\n ')
throw new Error(
`Missing environment variables: \n ${errorMessage}\n Please check your .env file.`
Expand Down
15 changes: 11 additions & 4 deletions apps/platform/src/lib/workspace-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ import type { Workspace } from '@/types'
export function setWorkspace(workspaceData: Workspace[]): void {
const defaultWorkspace =
workspaceData.find((workspace) => workspace.isDefault) || null
localStorage.setItem('defaultWorkspace', JSON.stringify(defaultWorkspace))
if (getCurrentWorkspace() === null) {
localStorage.setItem('currentWorkspace', JSON.stringify(defaultWorkspace))
if (typeof localStorage !== 'undefined') {
localStorage.setItem('defaultWorkspace', JSON.stringify(defaultWorkspace))

if (getCurrentWorkspace() === null) {
localStorage.setItem('currentWorkspace', JSON.stringify(defaultWorkspace))
}
}
}

export function getCurrentWorkspace(): Workspace | null {
const currentWorkspace = localStorage.getItem('currentWorkspace')
const currentWorkspace =
typeof localStorage !== 'undefined'
? localStorage.getItem('currentWorkspace')
: `{}`

if (currentWorkspace) {
return JSON.parse(currentWorkspace) as Workspace
}
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function middleware(req: NextRequest): NextResponse {
const cookieStore = cookies()

const token = cookieStore.has('token')
const isOnboardingFinished = cookieStore.get('isOnboardingFinished').value
const isOnboardingFinished = cookieStore.get('isOnboardingFinished')?.value

const currentPath = req.nextUrl.pathname

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"turbo": "^1.12.4"
},
"dependencies": {
"@keyshade/api-client": "workspace:*",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^12.0.0",
"@semantic-release/git": "^10.0.1",
Expand All @@ -184,7 +185,6 @@
"tsc-alias": "^1.8.10",
"typescript": "^5.5.2",
"typescript-transform-paths": "^3.5.0",
"zod": "^3.23.6",
"@keyshade/api-client": "workspace:*"
"zod": "^3.23.6"
}
}