Skip to content

Commit

Permalink
Fixes (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-wal authored Oct 31, 2024
1 parent 1d02be5 commit a19673d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/application/[owner]/[repo]/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ApplicationDetailPage: React.FC<ComponentProps> = ({
<div className="p-10">
<div className="mb-10">
<AppInfoCard
application={data.application_file}
initialApplication={data.application_file}
allocation={data.allocation}
repo={repo}
owner={owner}
Expand Down
16 changes: 8 additions & 8 deletions src/components/cards/AppInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import AllocatorBalance from '../AllocatorBalance'
import AllowedSps from './dialogs/allowedSps'

interface ComponentProps {
application: Application
initialApplication: Application
repo: string
owner: string
allocation?: Allocation
Expand All @@ -76,7 +76,7 @@ type DeviationType = 'contract' | 'directly'
* @prop {UseSession} session - User session data.
*/
const AppInfoCard: React.FC<ComponentProps> = ({
application: initialApplication,
initialApplication,
repo,
owner,
allocation,
Expand Down Expand Up @@ -862,6 +862,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
}

const handleAllowedSPsSubmit = async (
application: Application,
client: string,
clientContractAddress: string,
addedSPs: string[],
Expand All @@ -871,15 +872,11 @@ const AppInfoCard: React.FC<ComponentProps> = ({
): Promise<void> => {
try {
setApiCalling(true)
const requestId = application['Allocation Requests'].find(
(alloc) => alloc.Active,
)?.ID

const userName = session.data?.user?.githubUsername

if (
application.Lifecycle.State === 'ReadyToSign' &&
requestId &&
['ReadyToSign', 'Granted'].includes(application.Lifecycle.State) &&
userName
) {
await mutationChangeAllowedSPs.mutateAsync({
Expand All @@ -891,6 +888,8 @@ const AppInfoCard: React.FC<ComponentProps> = ({
newAvailableResult,
maxDeviation,
})
} else {
throw new Error('Application is incorrect state.')
}
} catch (error) {
console.log(error)
Expand Down Expand Up @@ -1070,7 +1069,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
<h2 className="text-xl font-bold">Additional info</h2>
</CardHeader>
<CardContent className="grid text-sm">
{[['SPs', availableAllowedSPs.join(',')]].map(
{[['Available allowed SPs', availableAllowedSPs.join(', ')]].map(
([label, value], idx) => {
const rowStyles = getRowStyles(idx)
return (
Expand Down Expand Up @@ -1121,6 +1120,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
) && (
<div className="flex gap-2">
<AllowedSps
application={application}
onSubmit={handleAllowedSPsSubmit}
client={application.Lifecycle['On Chain Address']}
clientContractAddress={
Expand Down
9 changes: 7 additions & 2 deletions src/components/cards/dialogs/allowedSps/AllowedSps.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button } from '@/components/ui/button'
import { Spinner } from '@/components/ui/spinner'
import useWallet from '@/hooks/useWallet'
import { type Application } from '@/type'
import { Add, Delete } from '@mui/icons-material'
import {
Dialog,
Expand All @@ -18,7 +19,9 @@ import { useEffect, useState } from 'react'
import { useQuery } from 'react-query'

interface ComponentProps {
application: Application
onSubmit: (
application: Application,
client: string,
clientContractAddress: string,
added: string[],
Expand All @@ -34,6 +37,7 @@ interface ComponentProps {
}

export const AllowedSPs: React.FC<ComponentProps> = ({
application,
client,
clientContractAddress,
initDeviation,
Expand Down Expand Up @@ -129,6 +133,7 @@ export const AllowedSPs: React.FC<ComponentProps> = ({
setIsDialogOpen(false)

await onSubmit(
application,
client,
clientContractAddress,
added,
Expand All @@ -139,8 +144,8 @@ export const AllowedSPs: React.FC<ComponentProps> = ({
} catch (error) {
console.log(error)
} finally {
setData([''])
setInitData([''])
setData(availableAllowedSPs ?? [''])
setInitData(availableAllowedSPs ?? [''])
setApiCalling(false)
}
}
Expand Down

0 comments on commit a19673d

Please sign in to comment.