diff --git a/api/src/openapi/schemas/survey.ts b/api/src/openapi/schemas/survey.ts index 2969919818..51b61d27f2 100644 --- a/api/src/openapi/schemas/survey.ts +++ b/api/src/openapi/schemas/survey.ts @@ -507,7 +507,8 @@ export const surveyBlockSchema: OpenAPIV3.SchemaObject = { }, geojson: { description: 'Geojson', - type: 'object' + type: 'object', + nullable: true }, sample_block_count: { description: 'Sample block count', diff --git a/api/src/repositories/survey-block-repository.ts b/api/src/repositories/survey-block-repository.ts index 0d9f37f3fc..863d3e44c0 100644 --- a/api/src/repositories/survey-block-repository.ts +++ b/api/src/repositories/survey-block-repository.ts @@ -19,7 +19,7 @@ export const SurveyBlockRecord = z.object({ survey_id: z.number(), name: z.string(), description: z.string(), - geojson: z.any(), + geojson: z.any().nullable(), revision_count: z.number() }); export type SurveyBlockRecord = z.infer; diff --git a/app/src/interfaces/useSurveyApi.interface.ts b/app/src/interfaces/useSurveyApi.interface.ts index 5ac2daf906..28c0958d07 100644 --- a/app/src/interfaces/useSurveyApi.interface.ts +++ b/app/src/interfaces/useSurveyApi.interface.ts @@ -140,7 +140,7 @@ export interface IGetSurveyBlock { name: string; description: string; revision_count: number; - geojson: Feature; + geojson: Feature | null; sample_block_count: number; } diff --git a/database/src/seeds/03_basic_project_survey_setup.ts b/database/src/seeds/03_basic_project_survey_setup.ts index 89eef14992..efcf50b1bd 100644 --- a/database/src/seeds/03_basic_project_survey_setup.ts +++ b/database/src/seeds/03_basic_project_survey_setup.ts @@ -92,6 +92,7 @@ export async function seed(knex: Knex): Promise { ${insertMethodTechnique(surveyId)} ${insertSurveySamplingMethodData(surveyId)} ${insertSurveySamplePeriodData(surveyId)} + ${insertSurveyBlockData(surveyId)} `); // Insert regions into surveys @@ -182,6 +183,19 @@ const insertSurveyParticipationData = (surveyId: number) => ` ; `; +const insertSurveyBlockData = (surveyId: number) => ` + INSERT into survey_block + ( survey_id, name, description, geojson ) + VALUES + ( + ${surveyId}, + '${faker.lorem.words(2)}', + '${faker.lorem.words(10)}', + NULL + ) + ; +`; + /** * SQL to insert Survey Proprietor data *