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(platoform): Swapped all legacy API calls with @keyshade/api-client #584

Merged
Show file tree
Hide file tree
Changes from 2 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
53 changes: 32 additions & 21 deletions apps/platform/src/app/(main)/project/[project]/@secret/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
TableHeader,
TableRow
} from '@/components/ui/table'
import { Secrets } from '@/lib/api-functions/secrets'
import type { Secret } from '@/types'
import type { Secret } from '@keyshade/schema'
import { SecretController } from '@keyshade/api-client'
import { ScrollArea } from '@/components/ui/scroll-area'
import {
Tooltip,
Expand All @@ -39,17 +39,30 @@ function SecretPage(): React.JSX.Element {

useEffect(() => {
setIsLoading(true)
Secrets.getAllSecretbyProjectId(pathname.split('/')[2])
.then((data) => {

const secretController = new SecretController(
process.env.NEXT_PUBLIC_BACKEND_URL
)

async function getAllSecretsByProjectSlug() {
const { success, error, data } =
await secretController.getAllSecretsOfProject(
{ projectSlug: pathname.split('/')[2] },
{}
)

if (success && data) {
//@ts-ignore
setAllSecrets(data)
})
.catch((error) => {
} else {
// eslint-disable-next-line no-console -- we need to log the error
console.error(error)
})
.finally(() => {
setIsLoading(false)
})
}
}

getAllSecretsByProjectSlug()

setIsLoading(false)
}, [pathname])

if (isLoading) {
Expand All @@ -73,33 +86,31 @@ function SecretPage(): React.JSX.Element {
return (
<AccordionItem
className="rounded-xl bg-white/5 px-5"
key={secret.secret.id}
value={secret.secret.id}
key={secret.id}
value={secret.id}
>
<AccordionTrigger
className="hover:no-underline"
rightChildren={
<div className="text-xs text-white/50">
{dayjs(secret.secret.updatedAt).toNow(true)} ago by{' '}
<span className="text-white">
{secret.secret.lastUpdatedBy.name}
</span>
{dayjs(secret.updatedAt).toNow(true)} ago by{' '}
<span className="text-white">{secret.lastUpdatedById}</span>
</div>
}
>
<div className="flex gap-x-5">
<div className="flex items-center gap-x-4">
{/* <SecretLogoSVG /> */}
{secret.secret.name}
{secret.name}
</div>
{secret.secret.note ? (
{secret.note ? (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<NoteIconSVG className="w-7" />
</TooltipTrigger>
<TooltipContent className="border-white/20 bg-white/10 text-white backdrop-blur-xl">
<p>{secret.secret.note}</p>
<p>{secret.note}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
Expand All @@ -115,10 +126,10 @@ function SecretPage(): React.JSX.Element {
</TableRow>
</TableHeader>
<TableBody>
{secret.values.map((value) => {
{secret.versions.map((value) => {
return (
<TableRow key={value.environment.id}>
<TableCell>{value.environment.name}</TableCell>
<TableCell>{value.environment.slug}</TableCell>
<TableCell className="max-w-40 overflow-auto">
{value.value}
</TableCell>
Expand Down
31 changes: 23 additions & 8 deletions apps/platform/src/app/(main)/project/[project]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import type { Project } from '@/types'
import { Projects } from '@/lib/api-functions/projects'
import { ProjectController } from '@keyshade/api-client'
import type { Project } from '@keyshade/schema'

interface DetailedProjectPageProps {
params: { project: string }
Expand All @@ -38,14 +38,29 @@ function DetailedProjectPage({
const tab = searchParams.get('tab') ?? 'rollup-details'

useEffect(() => {
Projects.getProjectbyID(params.project)
.then((project) => {
setCurrentProject(project)
})
.catch((error) => {

const projectController = new ProjectController(
process.env.NEXT_PUBLIC_BACKEND_URL
)

async function getProjectBySlug(){
const {success, error, data} = await projectController.getProject(
{projectSlug: params.project},
{}
)

if( success && data ){
//@ts-ignore
setCurrentProject(data)
}
else{
// eslint-disable-next-line no-console -- we need to log the error
console.error(error)
})
}
}

getProjectBySlug()

}, [params.project])

return (
Expand Down
Loading