diff --git a/src/components/ObsDetails/DetailsTab/Attribution.js b/src/components/ObsDetails/DetailsTab/Attribution.tsx similarity index 82% rename from src/components/ObsDetails/DetailsTab/Attribution.js rename to src/components/ObsDetails/DetailsTab/Attribution.tsx index 2effa5c81..a3c6396bb 100644 --- a/src/components/ObsDetails/DetailsTab/Attribution.js +++ b/src/components/ObsDetails/DetailsTab/Attribution.tsx @@ -1,15 +1,13 @@ -// @flow - import { Body4 } from "components/SharedComponents"; import { t } from "i18next"; -import type { Node } from "react"; import React from "react"; +import type { License, RealmObservation } from "realmModels/types"; -type Props = { - observation: Object +interface Props { + observation: RealmObservation; } -const renderRestrictions = ( licenseCode: string ) => { +const renderRestrictions = ( licenseCode: License | null ) => { switch ( licenseCode ) { case "cc0": return t( "no-rights-reserved-cc0" ); @@ -32,7 +30,7 @@ const renderRestrictions = ( licenseCode: string ) => { // lifted from web: // https://github.com/inaturalist/inaturalist/blob/768b9263931ebeea229bbc47d8442ca6b0377d45/app/webpack/shared/components/observation_attribution.jsx -const Attribution = ( { observation }: Props ): Node => { +const Attribution = ( { observation }: Props ) => { const { user } = observation; const userName = user ? ( user.name || user.login ) diff --git a/src/realmModels/types.d.ts b/src/realmModels/types.d.ts index fc1495ada..8ad0aab58 100644 --- a/src/realmModels/types.d.ts +++ b/src/realmModels/types.d.ts @@ -92,6 +92,16 @@ interface RealmIdentification extends RealmObject { user: RealmUser; } +// https://github.com/inaturalist/iNaturalistAPI/blob/08e3aade068c50e02d0caf7a59c69ea87b70bc6e/lib/views/swagger_v1.yml.ejs#L2319-L2333 +export type License = + | "cc-by" + | "cc-by-nc" + | "cc-by-nd" + | "cc-by-sa" + | "cc-by-nc-nd" + | "cc-by-nc-sa" + | "cc0" + export interface RealmObservationPojo { _created_at?: Date; _synced_at?: Date; @@ -103,6 +113,7 @@ export interface RealmObservationPojo { identifications: Array; identifications_viewed?: boolean; latitude: number | null; + license_code: License | null; longitude: number | null; obscured?: boolean; observationPhotos: Array; @@ -119,6 +130,7 @@ export interface RealmObservationPojo { taxon_geoprivacy?: "open" | "private" | "obscured" | null; time_observed_at?: string; timeObservedAt?: string; + user: RealmUser; uuid: string; }