Skip to content

Commit

Permalink
fix: default flow doesn't loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Jul 29, 2024
1 parent f953726 commit f1b553a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/ProjectCreateForm/ProjectCreateForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FormEvent, useCallback, useContext, useRef, useState } from 'react';
import React, { FormEvent, useCallback, useContext, useEffect, useRef, useState } from 'react';
import { useForm, Controller } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import dynamic from 'next/dynamic';
Expand Down Expand Up @@ -71,6 +71,13 @@ const ProjectCreateForm: React.FC = () => {
const errorsResolver = errorsProvider(errors, isSubmitted);
const titleWatcher = watch('title');
const keyWatcher = watch('id');
const flowWatch = watch('flow');

useEffect(() => {
if (!flowWatch && flowRecomendations.length) {
setValue('flow', flowRecomendations[0]);
}
}, [setValue, flowRecomendations, flowWatch]);

const isKeyEnoughLength = Boolean(keyWatcher?.length >= 3);
const existingProject = trpc.project.getById.useQuery(
Expand Down
1 change: 0 additions & 1 deletion src/pages/projects/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const getServerSideProps = declareSsrProps(

try {
const project = await ssrHelpers.project.getById.fetch({ id, goalsQuery: queryState });
await ssrHelpers.flow.recommedations.fetch();

if (!project) {
throw new TRPCError({ code: 'NOT_FOUND' });
Expand Down

0 comments on commit f1b553a

Please sign in to comment.