diff --git a/backend/src/api/featured-image/content-types/featured-image/schema.json b/backend/src/api/featured-image/content-types/featured-image/schema.json new file mode 100644 index 0000000..0239a02 --- /dev/null +++ b/backend/src/api/featured-image/content-types/featured-image/schema.json @@ -0,0 +1,31 @@ +{ + "kind": "singleType", + "collectionName": "featured_images", + "info": { + "singularName": "featured-image", + "pluralName": "featured-images", + "displayName": "featuredImage" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "featuredImage": { + "allowedTypes": [ + "images", + "files", + "videos", + "audios" + ], + "type": "media", + "multiple": false, + "required": true + }, + "satellite": { + "type": "relation", + "relation": "oneToOne", + "target": "api::satellite.satellite" + } + } +} diff --git a/backend/src/api/featured-image/controllers/featured-image.js b/backend/src/api/featured-image/controllers/featured-image.js new file mode 100644 index 0000000..4ad445e --- /dev/null +++ b/backend/src/api/featured-image/controllers/featured-image.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * featured-image controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::featured-image.featured-image'); diff --git a/backend/src/api/featured-image/routes/featured-image.js b/backend/src/api/featured-image/routes/featured-image.js new file mode 100644 index 0000000..7630cd3 --- /dev/null +++ b/backend/src/api/featured-image/routes/featured-image.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * featured-image router + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::featured-image.featured-image'); diff --git a/backend/src/api/featured-image/services/featured-image.js b/backend/src/api/featured-image/services/featured-image.js new file mode 100644 index 0000000..20d44ba --- /dev/null +++ b/backend/src/api/featured-image/services/featured-image.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * featured-image service + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::featured-image.featured-image'); diff --git a/backend/src/api/most-recent-image/content-types/most-recent-image/schema.json b/backend/src/api/most-recent-image/content-types/most-recent-image/schema.json deleted file mode 100644 index a097da1..0000000 --- a/backend/src/api/most-recent-image/content-types/most-recent-image/schema.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "kind": "collectionType", - "collectionName": "most_recent_images", - "info": { - "singularName": "most-recent-image", - "pluralName": "most-recent-images", - "displayName": "Most Recent Image" - }, - "options": { - "draftAndPublish": true - }, - "pluginOptions": {}, - "attributes": { - "mostRecentImage": { - "allowedTypes": [ - "images" - ], - "type": "media", - "multiple": false, - "required": true - }, - "satellite": { - "type": "relation", - "relation": "manyToOne", - "target": "api::satellite.satellite", - "inversedBy": "most_recent_images" - } - } -} diff --git a/backend/src/api/most-recent-image/controllers/most-recent-image.js b/backend/src/api/most-recent-image/controllers/most-recent-image.js deleted file mode 100644 index 8139ca5..0000000 --- a/backend/src/api/most-recent-image/controllers/most-recent-image.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -/** - * most-recent-image controller - */ - -const { createCoreController } = require('@strapi/strapi').factories; - -module.exports = createCoreController('api::most-recent-image.most-recent-image'); diff --git a/backend/src/api/most-recent-image/routes/most-recent-image.js b/backend/src/api/most-recent-image/routes/most-recent-image.js deleted file mode 100644 index 8640e95..0000000 --- a/backend/src/api/most-recent-image/routes/most-recent-image.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -/** - * most-recent-image router - */ - -const { createCoreRouter } = require('@strapi/strapi').factories; - -module.exports = createCoreRouter('api::most-recent-image.most-recent-image'); diff --git a/backend/src/api/most-recent-image/services/most-recent-image.js b/backend/src/api/most-recent-image/services/most-recent-image.js deleted file mode 100644 index c5725b3..0000000 --- a/backend/src/api/most-recent-image/services/most-recent-image.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -/** - * most-recent-image service - */ - -const { createCoreService } = require('@strapi/strapi').factories; - -module.exports = createCoreService('api::most-recent-image.most-recent-image'); diff --git a/backend/src/api/satellite/content-types/satellite/schema.json b/backend/src/api/satellite/content-types/satellite/schema.json index 121ac83..9378b19 100644 --- a/backend/src/api/satellite/content-types/satellite/schema.json +++ b/backend/src/api/satellite/content-types/satellite/schema.json @@ -42,12 +42,6 @@ "target": "api::project.project", "mappedBy": "satellites" }, - "most_recent_images": { - "type": "relation", - "relation": "oneToMany", - "target": "api::most-recent-image.most-recent-image", - "mappedBy": "satellite" - }, "missionStatus": { "type": "string" }, diff --git a/backend/types/generated/contentTypes.d.ts b/backend/types/generated/contentTypes.d.ts index 10a9ea6..dab7b1a 100644 --- a/backend/types/generated/contentTypes.d.ts +++ b/backend/types/generated/contentTypes.d.ts @@ -866,62 +866,61 @@ export interface ApiAuthorAuthor extends Schema.CollectionType { }; } -export interface ApiHeroHero extends Schema.SingleType { - collectionName: 'heroes'; +export interface ApiFeaturedImageFeaturedImage extends Schema.SingleType { + collectionName: 'featured_images'; info: { - singularName: 'hero'; - pluralName: 'heroes'; - displayName: 'Hero'; - description: ''; + singularName: 'featured-image'; + pluralName: 'featured-images'; + displayName: 'featuredImage'; }; options: { draftAndPublish: true; }; attributes: { - image: Attribute.Media & Attribute.Required; - text: Attribute.Text; + featuredImage: Attribute.Media & Attribute.Required; + satellite: Attribute.Relation< + 'api::featured-image.featured-image', + 'oneToOne', + 'api::satellite.satellite' + >; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; publishedAt: Attribute.DateTime; - createdBy: Attribute.Relation<'api::hero.hero', 'oneToOne', 'admin::user'> & + createdBy: Attribute.Relation< + 'api::featured-image.featured-image', + 'oneToOne', + 'admin::user' + > & Attribute.Private; - updatedBy: Attribute.Relation<'api::hero.hero', 'oneToOne', 'admin::user'> & + updatedBy: Attribute.Relation< + 'api::featured-image.featured-image', + 'oneToOne', + 'admin::user' + > & Attribute.Private; }; } -export interface ApiMostRecentImageMostRecentImage - extends Schema.CollectionType { - collectionName: 'most_recent_images'; +export interface ApiHeroHero extends Schema.SingleType { + collectionName: 'heroes'; info: { - singularName: 'most-recent-image'; - pluralName: 'most-recent-images'; - displayName: 'Most Recent Image'; + singularName: 'hero'; + pluralName: 'heroes'; + displayName: 'Hero'; + description: ''; }; options: { draftAndPublish: true; }; attributes: { - mostRecentImage: Attribute.Media & Attribute.Required; - satellite: Attribute.Relation< - 'api::most-recent-image.most-recent-image', - 'manyToOne', - 'api::satellite.satellite' - >; + image: Attribute.Media & Attribute.Required; + text: Attribute.Text; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; publishedAt: Attribute.DateTime; - createdBy: Attribute.Relation< - 'api::most-recent-image.most-recent-image', - 'oneToOne', - 'admin::user' - > & + createdBy: Attribute.Relation<'api::hero.hero', 'oneToOne', 'admin::user'> & Attribute.Private; - updatedBy: Attribute.Relation< - 'api::most-recent-image.most-recent-image', - 'oneToOne', - 'admin::user' - > & + updatedBy: Attribute.Relation<'api::hero.hero', 'oneToOne', 'admin::user'> & Attribute.Private; }; } @@ -987,11 +986,6 @@ export interface ApiSatelliteSatellite extends Schema.CollectionType { 'manyToMany', 'api::project.project' >; - most_recent_images: Attribute.Relation< - 'api::satellite.satellite', - 'oneToMany', - 'api::most-recent-image.most-recent-image' - >; missionStatus: Attribute.String; slug: Attribute.UID<'api::satellite.satellite', 'name'> & Attribute.Required; @@ -1033,8 +1027,8 @@ declare module '@strapi/types' { 'plugin::users-permissions.user': PluginUsersPermissionsUser; 'api::article.article': ApiArticleArticle; 'api::author.author': ApiAuthorAuthor; + 'api::featured-image.featured-image': ApiFeaturedImageFeaturedImage; 'api::hero.hero': ApiHeroHero; - 'api::most-recent-image.most-recent-image': ApiMostRecentImageMostRecentImage; 'api::project.project': ApiProjectProject; 'api::satellite.satellite': ApiSatelliteSatellite; } diff --git a/frontend/src/__generated__/gql.ts b/frontend/src/__generated__/gql.ts index f0dcde4..7e9384d 100644 --- a/frontend/src/__generated__/gql.ts +++ b/frontend/src/__generated__/gql.ts @@ -19,7 +19,7 @@ const documents = { "\nquery GET_SATELLITES {\n satellites {\n data {\n id\n attributes {\n celestrakURL\n catalogNumberNORAD\n name\n previewImage {\n data {\n attributes {\n url\n }\n }\n }\n missionStatus\n slug\n }\n }\n }\n }\n": types.Get_SatellitesDocument, "\nquery Query($publicationState: PublicationState) {\n hero(publicationState: $publicationState) {\n data {\n attributes {\n text\n image {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n }": types.QueryDocument, "\nquery GET_ARTICLES($pagination: PaginationArg, $filters: ArticleFiltersInput) {\n articles(sort: [\"datePublished:desc\"], pagination: $pagination, filters: $filters) {\n data {\n id\n attributes {\n author {\n data {\n attributes {\n name\n avatar {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n previewTitle\n datePublished\n body\n coverImage {\n data {\n attributes {\n url\n }\n }\n }\n createdAt\n publishedAt\n slug\n Tag\n }\n }\n meta {\n pagination {\n total\n }\n }\n }\n}\n": types.Get_ArticlesDocument, - "\nquery MostRecentImages {\n mostRecentImages(sort: [\"publishedAt:desc\"]) {\n data {\n attributes {\n mostRecentImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n": types.MostRecentImagesDocument, + "\nquery FeaturedImage {\n featuredImage {\n data {\n attributes {\n featuredImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n": types.FeaturedImageDocument, "query GET_SATELLITE_INFO($filters: SatelliteFiltersInput) {\n satellites(filters: $filters) {\n data {\n id\n attributes {\n celestrakURL\n catalogNumberNORAD\n content\n name\n projects {\n data {\n attributes {\n title\n previewImage {\n data {\n attributes {\n url\n }\n }\n }\n slug\n }\n id\n }\n }\n }\n }\n }\n }\n ": types.Get_Satellite_InfoDocument, }; @@ -57,10 +57,6 @@ export function gql(source: "\nquery GET_SATELLITES {\n satellites {\n d * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql(source: "\nquery Query($publicationState: PublicationState) {\n hero(publicationState: $publicationState) {\n data {\n attributes {\n text\n image {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n }"): (typeof documents)["\nquery Query($publicationState: PublicationState) {\n hero(publicationState: $publicationState) {\n data {\n attributes {\n text\n image {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n }"]; -/** - * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function gql(source: "\nquery Query($publicationState: PublicationState) {\n hero(publicationState: $publicationState) {\n data {\n attributes {\n text\n image {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n }"): (typeof documents)["\nquery Query($publicationState: PublicationState) {\n hero(publicationState: $publicationState) {\n data {\n attributes {\n text\n image {\n data {\n attributes {\n url\n }\n }\n }\n }\n }\n }\n }"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -68,7 +64,7 @@ export function gql(source: "\nquery GET_ARTICLES($pagination: PaginationArg, $f /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\nquery MostRecentImages {\n mostRecentImages(sort: [\"publishedAt:desc\"]) {\n data {\n attributes {\n mostRecentImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n"): (typeof documents)["\nquery MostRecentImages {\n mostRecentImages(sort: [\"publishedAt:desc\"]) {\n data {\n attributes {\n mostRecentImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n"]; +export function gql(source: "\nquery FeaturedImage {\n featuredImage {\n data {\n attributes {\n featuredImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n"): (typeof documents)["\nquery FeaturedImage {\n featuredImage {\n data {\n attributes {\n featuredImage {\n data {\n attributes {\n url\n }\n }\n }\n satellite {\n data {\n attributes {\n catalogNumberNORAD\n name\n }\n }\n }\n createdAt\n updatedAt\n publishedAt\n }\n }\n }\n}\n\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/frontend/src/__generated__/graphql.ts b/frontend/src/__generated__/graphql.ts index 57a94be..a79dfd0 100644 --- a/frontend/src/__generated__/graphql.ts +++ b/frontend/src/__generated__/graphql.ts @@ -222,6 +222,32 @@ export enum Enum_Article_Tag { Updates = 'Updates' } +export type FeaturedImage = { + __typename?: 'FeaturedImage'; + createdAt?: Maybe; + featuredImage: UploadFileEntityResponse; + publishedAt?: Maybe; + satellite?: Maybe; + updatedAt?: Maybe; +}; + +export type FeaturedImageEntity = { + __typename?: 'FeaturedImageEntity'; + attributes?: Maybe; + id?: Maybe; +}; + +export type FeaturedImageEntityResponse = { + __typename?: 'FeaturedImageEntityResponse'; + data?: Maybe; +}; + +export type FeaturedImageInput = { + featuredImage?: InputMaybe; + publishedAt?: InputMaybe; + satellite?: InputMaybe; +}; + export type FileInfoInput = { alternativeText?: InputMaybe; caption?: InputMaybe; @@ -253,7 +279,7 @@ export type FloatFilterInput = { startsWith?: InputMaybe; }; -export type GenericMorph = Article | Author | Hero | I18NLocale | MostRecentImage | Project | Satellite | UploadFile | UploadFolder | UsersPermissionsPermission | UsersPermissionsRole | UsersPermissionsUser; +export type GenericMorph = Article | Author | FeaturedImage | Hero | I18NLocale | Project | Satellite | UploadFile | UploadFolder | UsersPermissionsPermission | UsersPermissionsRole | UsersPermissionsUser; export type Hero = { __typename?: 'Hero'; @@ -392,61 +418,12 @@ export type JsonFilterInput = { startsWith?: InputMaybe; }; -export type MostRecentImage = { - __typename?: 'MostRecentImage'; - createdAt?: Maybe; - mostRecentImage: UploadFileEntityResponse; - publishedAt?: Maybe; - satellite?: Maybe; - updatedAt?: Maybe; -}; - -export type MostRecentImageEntity = { - __typename?: 'MostRecentImageEntity'; - attributes?: Maybe; - id?: Maybe; -}; - -export type MostRecentImageEntityResponse = { - __typename?: 'MostRecentImageEntityResponse'; - data?: Maybe; -}; - -export type MostRecentImageEntityResponseCollection = { - __typename?: 'MostRecentImageEntityResponseCollection'; - data: Array; - meta: ResponseCollectionMeta; -}; - -export type MostRecentImageFiltersInput = { - and?: InputMaybe>>; - createdAt?: InputMaybe; - id?: InputMaybe; - not?: InputMaybe; - or?: InputMaybe>>; - publishedAt?: InputMaybe; - satellite?: InputMaybe; - updatedAt?: InputMaybe; -}; - -export type MostRecentImageInput = { - mostRecentImage?: InputMaybe; - publishedAt?: InputMaybe; - satellite?: InputMaybe; -}; - -export type MostRecentImageRelationResponseCollection = { - __typename?: 'MostRecentImageRelationResponseCollection'; - data: Array; -}; - export type Mutation = { __typename?: 'Mutation'; /** Change user password. Confirm with the current password. */ changePassword?: Maybe; createArticle?: Maybe; createAuthor?: Maybe; - createMostRecentImage?: Maybe; createProject?: Maybe; createSatellite?: Maybe; createUploadFile?: Maybe; @@ -457,8 +434,8 @@ export type Mutation = { createUsersPermissionsUser: UsersPermissionsUserEntityResponse; deleteArticle?: Maybe; deleteAuthor?: Maybe; + deleteFeaturedImage?: Maybe; deleteHero?: Maybe; - deleteMostRecentImage?: Maybe; deleteProject?: Maybe; deleteSatellite?: Maybe; deleteUploadFile?: Maybe; @@ -480,9 +457,9 @@ export type Mutation = { resetPassword?: Maybe; updateArticle?: Maybe; updateAuthor?: Maybe; + updateFeaturedImage?: Maybe; updateFileInfo: UploadFileEntityResponse; updateHero?: Maybe; - updateMostRecentImage?: Maybe; updateProject?: Maybe; updateSatellite?: Maybe; updateUploadFile?: Maybe; @@ -512,11 +489,6 @@ export type MutationCreateAuthorArgs = { }; -export type MutationCreateMostRecentImageArgs = { - data: MostRecentImageInput; -}; - - export type MutationCreateProjectArgs = { data: ProjectInput; }; @@ -557,11 +529,6 @@ export type MutationDeleteAuthorArgs = { }; -export type MutationDeleteMostRecentImageArgs = { - id: Scalars['ID']['input']; -}; - - export type MutationDeleteProjectArgs = { id: Scalars['ID']['input']; }; @@ -644,6 +611,11 @@ export type MutationUpdateAuthorArgs = { }; +export type MutationUpdateFeaturedImageArgs = { + data: FeaturedImageInput; +}; + + export type MutationUpdateFileInfoArgs = { id: Scalars['ID']['input']; info?: InputMaybe; @@ -655,12 +627,6 @@ export type MutationUpdateHeroArgs = { }; -export type MutationUpdateMostRecentImageArgs = { - data: MostRecentImageInput; - id: Scalars['ID']['input']; -}; - - export type MutationUpdateProjectArgs = { data: ProjectInput; id: Scalars['ID']['input']; @@ -796,12 +762,11 @@ export type Query = { articles?: Maybe; author?: Maybe; authors?: Maybe; + featuredImage?: Maybe; hero?: Maybe; i18NLocale?: Maybe; i18NLocales?: Maybe; me?: Maybe; - mostRecentImage?: Maybe; - mostRecentImages?: Maybe; project?: Maybe; projects?: Maybe; satellite?: Maybe; @@ -843,6 +808,11 @@ export type QueryAuthorsArgs = { }; +export type QueryFeaturedImageArgs = { + publicationState?: InputMaybe; +}; + + export type QueryHeroArgs = { publicationState?: InputMaybe; }; @@ -860,19 +830,6 @@ export type QueryI18NLocalesArgs = { }; -export type QueryMostRecentImageArgs = { - id?: InputMaybe; -}; - - -export type QueryMostRecentImagesArgs = { - filters?: InputMaybe; - pagination?: InputMaybe; - publicationState?: InputMaybe; - sort?: InputMaybe>>; -}; - - export type QueryProjectArgs = { id?: InputMaybe; }; @@ -958,7 +915,6 @@ export type Satellite = { content?: Maybe; createdAt?: Maybe; missionStatus?: Maybe; - most_recent_images?: Maybe; name: Scalars['String']['output']; previewImage?: Maybe; projects?: Maybe; @@ -968,14 +924,6 @@ export type Satellite = { }; -export type SatelliteMost_Recent_ImagesArgs = { - filters?: InputMaybe; - pagination?: InputMaybe; - publicationState?: InputMaybe; - sort?: InputMaybe>>; -}; - - export type SatelliteProjectsArgs = { filters?: InputMaybe; pagination?: InputMaybe; @@ -1008,7 +956,6 @@ export type SatelliteFiltersInput = { createdAt?: InputMaybe; id?: InputMaybe; missionStatus?: InputMaybe; - most_recent_images?: InputMaybe; name?: InputMaybe; not?: InputMaybe; or?: InputMaybe>>; @@ -1023,7 +970,6 @@ export type SatelliteInput = { celestrakURL?: InputMaybe; content?: InputMaybe; missionStatus?: InputMaybe; - most_recent_images?: InputMaybe>>; name?: InputMaybe; previewImage?: InputMaybe; projects?: InputMaybe>>; @@ -1473,10 +1419,10 @@ export type Get_ArticlesQueryVariables = Exact<{ export type Get_ArticlesQuery = { __typename?: 'Query', articles?: { __typename?: 'ArticleEntityResponseCollection', data: Array<{ __typename?: 'ArticleEntity', id?: string | null, attributes?: { __typename?: 'Article', previewTitle: string, datePublished: any, body: any, createdAt?: any | null, publishedAt?: any | null, slug: string, Tag?: Enum_Article_Tag | null, author?: { __typename?: 'AuthorEntityResponse', data?: { __typename?: 'AuthorEntity', attributes?: { __typename?: 'Author', name: string, avatar?: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string } | null } | null } | null } | null } | null } | null, coverImage?: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string } | null } | null } | null } | null }>, meta: { __typename?: 'ResponseCollectionMeta', pagination: { __typename?: 'Pagination', total: number } } } | null }; -export type MostRecentImagesQueryVariables = Exact<{ [key: string]: never; }>; +export type FeaturedImageQueryVariables = Exact<{ [key: string]: never; }>; -export type MostRecentImagesQuery = { __typename?: 'Query', mostRecentImages?: { __typename?: 'MostRecentImageEntityResponseCollection', data: Array<{ __typename?: 'MostRecentImageEntity', attributes?: { __typename?: 'MostRecentImage', createdAt?: any | null, updatedAt?: any | null, publishedAt?: any | null, mostRecentImage: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string } | null } | null }, satellite?: { __typename?: 'SatelliteEntityResponse', data?: { __typename?: 'SatelliteEntity', attributes?: { __typename?: 'Satellite', catalogNumberNORAD?: string | null, name: string } | null } | null } | null } | null }> } | null }; +export type FeaturedImageQuery = { __typename?: 'Query', featuredImage?: { __typename?: 'FeaturedImageEntityResponse', data?: { __typename?: 'FeaturedImageEntity', attributes?: { __typename?: 'FeaturedImage', createdAt?: any | null, updatedAt?: any | null, publishedAt?: any | null, featuredImage: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string } | null } | null }, satellite?: { __typename?: 'SatelliteEntityResponse', data?: { __typename?: 'SatelliteEntity', attributes?: { __typename?: 'Satellite', catalogNumberNORAD?: string | null, name: string } | null } | null } | null } | null } | null } | null }; export type Get_Satellite_InfoQueryVariables = Exact<{ filters?: InputMaybe; @@ -1492,5 +1438,5 @@ export const Get_ProjectsDocument = {"kind":"Document","definitions":[{"kind":"O export const Get_SatellitesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GET_SATELLITES"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"satellites"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"celestrakURL"}},{"kind":"Field","name":{"kind":"Name","value":"catalogNumberNORAD"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"previewImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"missionStatus"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const QueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Query"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"publicationState"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"PublicationState"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hero"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"publicationState"},"value":{"kind":"Variable","name":{"kind":"Name","value":"publicationState"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"text"}},{"kind":"Field","name":{"kind":"Name","value":"image"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const Get_ArticlesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GET_ARTICLES"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"pagination"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"PaginationArg"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filters"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ArticleFiltersInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"articles"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"sort"},"value":{"kind":"ListValue","values":[{"kind":"StringValue","value":"datePublished:desc","block":false}]}},{"kind":"Argument","name":{"kind":"Name","value":"pagination"},"value":{"kind":"Variable","name":{"kind":"Name","value":"pagination"}}},{"kind":"Argument","name":{"kind":"Name","value":"filters"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filters"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"avatar"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"previewTitle"}},{"kind":"Field","name":{"kind":"Name","value":"datePublished"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"publishedAt"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"Tag"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"meta"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pagination"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"total"}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const MostRecentImagesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MostRecentImages"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"mostRecentImages"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"sort"},"value":{"kind":"ListValue","values":[{"kind":"StringValue","value":"publishedAt:desc","block":false}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"mostRecentImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"satellite"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"catalogNumberNORAD"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"publishedAt"}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const FeaturedImageDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FeaturedImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"featuredImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"featuredImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"satellite"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"catalogNumberNORAD"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"publishedAt"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const Get_Satellite_InfoDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GET_SATELLITE_INFO"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filters"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"SatelliteFiltersInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"satellites"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filters"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filters"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"celestrakURL"}},{"kind":"Field","name":{"kind":"Name","value":"catalogNumberNORAD"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"projects"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"previewImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attributes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}},{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 249fc29..3fa7c81 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -4,7 +4,7 @@ import ColoredSection from "@/components/ui/coloredSection"; import Image from "next/image"; import Link from "next/link"; -import fetchMostRecentImage from "@/lib/data/fetchMostRecentImage"; +import fetchFeaturedImage from "@/lib/data/fetchFeaturedImage"; import SatelliteDataHome from "@/components/satelliteData/SatelliteDataHome"; import SatelliteSelector from "@/components/homeComponents/SatelliteSelector"; @@ -19,7 +19,7 @@ const SatelliteGlobeNoSSR = dynamic( ); export default async function Home() { - const mostRecentImageURL = await fetchMostRecentImage(); + const featuredImageURL = await fetchFeaturedImage(); return ( <> @@ -97,8 +97,8 @@ export default async function Home() {
-

Most recent picture

- {mostRecentImageURL} +

Featured Satellite Image

+ {featuredImageURL}
diff --git a/frontend/src/lib/data/fetchFeaturedImage.tsx b/frontend/src/lib/data/fetchFeaturedImage.tsx new file mode 100644 index 0000000..c45a18f --- /dev/null +++ b/frontend/src/lib/data/fetchFeaturedImage.tsx @@ -0,0 +1,81 @@ +import { gql } from "@/__generated__/gql"; +import { getClient } from "../ApolloClient"; +import Image from "next/image"; +import { OuiImage } from "@/components/fullBlogCard"; + +const STRAPI_URL = process.env.STRAPI_URL; + +const GET_FEATURED_IMAGE = gql(` +query FeaturedImage { + featuredImage { + data { + attributes { + featuredImage { + data { + attributes { + url + } + } + } + satellite { + data { + attributes { + catalogNumberNORAD + name + } + } + } + createdAt + updatedAt + publishedAt + } + } + } +} + +`); + +export default async function fetchFeaturedImage() { + const graphqlData = await getClient().query({ + query: GET_FEATURED_IMAGE, + }); + + let featuredImageURL = + graphqlData.data.featuredImage?.data?.attributes?.featuredImage?.data + ?.attributes?.url; + + if (STRAPI_URL && featuredImageURL != undefined) { + featuredImageURL = STRAPI_URL + featuredImageURL; + } else { + featuredImageURL = ""; + } + + const imageSatelliteRelation = + graphqlData.data.featuredImage?.data?.attributes?.satellite?.data + ?.attributes?.name; + + return ( +
+ {featuredImageURL ? ( +
+
+ Most recent satellite image +
+
+

Taken by {imageSatelliteRelation}

+
+
+ ) : ( +
+ +
+ )} +
+ ); +} diff --git a/frontend/src/lib/data/fetchMostRecentImage.tsx b/frontend/src/lib/data/fetchMostRecentImage.tsx deleted file mode 100644 index 4bc9ef8..0000000 --- a/frontend/src/lib/data/fetchMostRecentImage.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { gql } from "@/__generated__/gql"; -import { getClient } from "../ApolloClient"; -import Image from "next/image"; - -const STRAPI_URL = process.env.STRAPI_URL; - -const GET_MOST_RECENT_IMAGE = gql(` -query MostRecentImages { - mostRecentImages(sort: ["publishedAt:desc"]) { - data { - attributes { - mostRecentImage { - data { - attributes { - url - } - } - } - satellite { - data { - attributes { - catalogNumberNORAD - name - } - } - } - createdAt - updatedAt - publishedAt - } - } - } -} - -`); - -export default async function fetchMostrecentImage() { - const graphqlData = await getClient().query({ - query: GET_MOST_RECENT_IMAGE, - }); - - let mostRecentImageURL = - graphqlData.data.mostRecentImages?.data[0]?.attributes?.mostRecentImage - ?.data?.attributes?.url; - - if (STRAPI_URL && mostRecentImageURL != undefined) { - mostRecentImageURL = STRAPI_URL + mostRecentImageURL; - } else { - mostRecentImageURL = ""; - } - - const imageSatelliteRelation = - graphqlData.data.mostRecentImages?.data[0]?.attributes?.satellite?.data - ?.attributes?.name; - - return ( -
-
- Most recent satellite image -
-
-

Taken by {imageSatelliteRelation}

-
-
- ); -}