Skip to content

Commit 7855652

Browse files
authored
Merge pull request #35 from oasisprotocol/mz/providers
Fetch providers from Nexus in creation flow
2 parents d2cdcda + 2bba3ab commit 7855652

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

src/pages/CreateApp/BuildStep.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { CreateFormHeader } from './CreateFormHeader';
44
import { CreateFormNavigation } from './CreateFormNavigation';
55
import { zodResolver } from '@hookform/resolvers/zod';
66
import { Controller, useForm } from 'react-hook-form';
7-
import { InputFormField } from './InputFormField';
87
import { Label } from '@oasisprotocol/ui-library/src/components/ui/label';
98
import {
109
RadioGroup,
@@ -14,6 +13,8 @@ import { buildFormSchema, type BuildFormData } from './types';
1413
import { SelectFormField } from './SelectFormField';
1514
import { useGetRosePrice } from '../../coin-gecko/api';
1615
import { Skeleton } from '@oasisprotocol/ui-library/src/components/ui/skeleton';
16+
import { useNetwork } from '../../hooks/useNetwork';
17+
import { useGetRuntimeRoflmarketProviders } from '../../nexus/api';
1718

1819
type AgentStepProps = {
1920
handleNext: () => void;
@@ -51,6 +52,18 @@ export const BuildStep: FC<AgentStepProps> = ({
5152
setAppDataForm,
5253
selectedTemplateName,
5354
}) => {
55+
const network = useNetwork();
56+
const providersQuery = useGetRuntimeRoflmarketProviders(network, 'sapphire');
57+
const { data } = providersQuery;
58+
const providers = data?.data.providers;
59+
const providerOptions = providers
60+
? providers?.map((provider) => ({
61+
value: provider.address,
62+
label:
63+
(provider.metadata['net.oasis.provider.name'] as string) ||
64+
provider.address,
65+
}))
66+
: [];
5467
const {
5568
data: rosePrice,
5669
isLoading: isLoadingRosePrice,
@@ -99,19 +112,12 @@ export const BuildStep: FC<AgentStepProps> = ({
99112
onSubmit={form.handleSubmit(onSubmit)}
100113
className="space-y-6 mb-6 w-full"
101114
>
102-
<InputFormField
103-
control={form.control}
104-
name="artifacts"
105-
label="Base Artifacts"
106-
placeholder="oasis boot 0.5.0, ROFL container 0.5.1"
107-
/>
108-
109115
<SelectFormField
110116
control={form.control}
111117
name="provider"
112118
label="Provider"
113119
placeholder="Select provider"
114-
options={[{ value: 'OPF', label: 'OPF' }]}
120+
options={[...providerOptions]}
115121
/>
116122

117123
<div className="grid gap-2">

src/pages/CreateApp/PaymentStep.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import { type FC } from 'react';
22
import { CreateLayout } from './CreateLayout';
33
import { CreateFormHeader } from './CreateFormHeader';
44
import { CreateFormNavigation } from './CreateFormNavigation';
5+
import { type AppData } from './types';
56

67
type AgentStepProps = {
78
handleNext: () => void;
89
handleBack: () => void;
910
selectedTemplateName?: string;
11+
appData?: AppData;
1012
};
1113

1214
export const PaymentStep: FC<AgentStepProps> = ({
1315
handleNext,
1416
handleBack,
1517
selectedTemplateName,
18+
appData,
1619
}) => {
20+
console.log('appData', appData);
21+
1722
return (
1823
<CreateLayout
1924
currentStep={4}

src/pages/CreateApp/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const Create: FC = () => {
7474
<PaymentStep
7575
handleNext={handleNext}
7676
handleBack={handleBack}
77+
appData={appData}
7778
selectedTemplateName={selectedTemplate?.name}
7879
/>
7980
)}

src/pages/CreateApp/templates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const templates = [
2424
license: parsedTemplate.license || '',
2525
},
2626
build: {
27-
provider: 'OPF',
27+
provider: '',
2828
resources: 'medium',
2929
},
3030
},

src/pages/CreateApp/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const agentFormSchema = z.object({
4747
});
4848

4949
export const buildFormSchema = z.object({
50-
artifacts: z.string().optional(),
5150
provider: z.string().min(1, {
5251
message: 'Provider is required.',
5352
}),

0 commit comments

Comments
 (0)