From 00497aa22cb6cef099571bfacd6e39c1c35bb264 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Mon, 30 Sep 2024 20:43:31 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=92=89=F0=9F=8E=A1=20=E2=86=9D=20[S?= =?UTF-8?q?SC-8=20SSC-10=20SSC-9]:=20Classification=20form=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(create)/(classifications)/PostForm.tsx | 396 ++++++++++-------- .../(structures)/Telescopes/DiskDetector.tsx | 105 ++--- .../(structures)/Telescopes/Sunspots.tsx | 19 +- .../Zoodex/ClassifyOthersAnimals.tsx | 8 +- citizen | 2 +- 5 files changed, 275 insertions(+), 255 deletions(-) diff --git a/app/components/(create)/(classifications)/PostForm.tsx b/app/components/(create)/(classifications)/PostForm.tsx index 4c570153..e7b87321 100644 --- a/app/components/(create)/(classifications)/PostForm.tsx +++ b/app/components/(create)/(classifications)/PostForm.tsx @@ -8,11 +8,100 @@ import UserAvatar, { UserAvatarNullUpload } from "@/app/components/(settings)/pr import { ClassificationOutput } from "./ClassificationResults"; import IntroduceUserToResearch from "../../(scenes)/chapters/(onboarding)/initialiseResearch"; -interface ClassificationOption { - id: number; - text: string; - subOptions?: ClassificationOption[]; -}; +const zoodexSouthCoastFaunaRecovery: ClassificationOption[] = [ + { id: 1, text: "Australian raven" }, + { id: 2, text: "Red-winged fairy-wren" }, + { id: 3, text: "Cat" }, + { id: 4, text: "Brown falcon" }, + { id: 5, text: "Silvereye" }, + { id: 6, text: "Echidna" }, + { id: 7, text: "Brown quail" }, + { id: 8, text: "Southern emu-wren" }, + { id: 9, text: "Fox" }, + { id: 10, text: "Brush bronzewing" }, + { id: 11, text: "Splendid fairy-wren" }, + { id: 12, text: "Mouse or smaller?" }, + { id: 13, text: "Carnaby's black cockatoo" }, + { id: 14, text: "Spotted nightjar" }, + { id: 15, text: "Quenda" }, + { id: 16, text: "Common bronzewing" }, + { id: 17, text: "Tawny frogmouth" }, + { id: 18, text: "Quokka" }, + { id: 19, text: "Emu" }, + { id: 20, text: "Tawny-crowned honeyeater" }, + { id: 21, text: "Rabbit" }, + { id: 22, text: "Galah" }, + { id: 23, text: "Wedge-tailed eagle" }, + { id: 24, text: "Western brush wallaby" }, + { id: 25, text: "Grey butcherbird" }, + { id: 26, text: "Welcome swallow" }, + { id: 27, text: "Western grey kangaroo" }, + { id: 28, text: "Grey currawong" }, + { id: 29, text: "Western bristlebird" }, + { id: 30, text: "Western ringtail possum" }, + { id: 31, text: "Grey fantail" }, + { id: 32, text: "Western fieldwren" }, + { id: 33, text: "Faulty" }, + { id: 34, text: "Laughing kookaburra" }, + { id: 35, text: "Human" }, + { id: 36, text: "Magpie" }, + { id: 37, text: "Western rosella" }, + { id: 38, text: "Nothing" }, + { id: 39, text: "Malleefowl" }, + { id: 40, text: "Western spinebill" }, + { id: 41, text: "Small mammal" }, + { id: 42, text: "Nankeen kestrel" }, + { id: 43, text: "Western wattlebird" }, + { id: 44, text: "Bird" }, + { id: 45, text: "New holland honeyeater" }, + { id: 46, text: "Western whipbird" }, + { id: 47, text: "Mammal" }, + { id: 48, text: "Noisy scrub-bird" }, + { id: 49, text: "Western whistler" }, + { id: 50, text: "Reptile" }, + { id: 51, text: "Painted button-quail" }, + { id: 52, text: "White-browed scrubwren" }, + { id: 53, text: "Bobtail skink" }, + { id: 54, text: "Purple swamphen" }, + { id: 55, text: "White-cheeked honeyeater" }, + { id: 56, text: "Heath monitor" }, + { id: 57, text: "Red wattlebird" }, + { id: 58, text: "Willie wagtail" }, + { id: 59, text: "King skink" }, + { id: 60, text: "Red-capped parrot" }, + { id: 61, text: "Brushtail possum" }, + { id: 62, text: "Western blue-tongued skink" }, + { id: 63, text: "Red-eared firetail" }, + { id: 64, text: "Bush rat" }, +]; + +const cloudClassificationOptions: ClassificationOption[] = [ + { + id: 1, + text: "Colour", + subOptions: [ + { id: 1, text: "White colour" }, + { id: 2, text: "Blue colour" }, + ], + }, + { + id: 2, + text: "Intensity", + subOptions: [ + { id: 1, text: "Bright clouds" }, + { id: 2, text: "Faint clouds" }, + { id: 3, text: "Medium clouds" }, + ], + }, + { + id: 3, + text: "Coverage", + subOptions: [ + { id: 1, text: "Clouds cover most of the height" }, + { id: 2, text: "Clouds are smaller" }, + ], + }, +]; const planetClassificationOptions: ClassificationOption[] = [ { id: 1, text: 'No dips at all' }, @@ -57,52 +146,6 @@ const roverImgClassificationOptions: ClassificationOption[] = [ { id: 6, text: 'Sandy/rocky terrain' }, ]; -const cloudClassificationOptions: ClassificationOption[] = [ - { - id: 1, - text: "Colour", - subOptions: [ - { id: 1, text: "White colour" }, - { id: 2, text: "Blue colour" }, - ], - }, - { - id: 2, - text: "Intensity", - subOptions: [ - { id: 1, text: "Bright clouds" }, - { id: 2, text: "Faint clouds" }, - { id: 3, text: "Medium clouds" }, - ], - }, - { - id: 3, - text: "Coverage", - subOptions: [ - { id: 1, text: "Clouds cover most of the height" }, - { id: 2, text: "Clouds are smaller" }, - ], - }, -]; - -// const initialCloudClassificationOptions: ClassificationOption[] = [ -// { -// id: 1, -// text: "White colour", -// }, -// { -// id: 2, -// text: "Blue colour", -// }, -// { -// id: 3, -// text: "Bright clouds", -// }, -// { -// id: 4, text: "Large clouds", -// }, -// ]; - const initialCloudClassificationOptions: ClassificationOption[] = [ { id: 1, @@ -194,77 +237,10 @@ const sunspotsConfigurationTemporary: ClassificationOption[] = [ id: 3, text: "Multiple sunspots", }, -]; - -const zoodexSouthCoastFaunaRecovery: ClassificationOption[] = [ - { id: 1, text: "Australian raven" }, - { id: 2, text: "Red-winged fairy-wren" }, - { id: 3, text: "Cat" }, - { id: 4, text: "Brown falcon" }, - { id: 5, text: "Silvereye" }, - { id: 6, text: "Echidna" }, - { id: 7, text: "Brown quail" }, - { id: 8, text: "Southern emu-wren" }, - { id: 9, text: "Fox" }, - { id: 10, text: "Brush bronzewing" }, - { id: 11, text: "Splendid fairy-wren" }, - { id: 12, text: "Mouse or smaller?" }, - { id: 13, text: "Carnaby's black cockatoo" }, - { id: 14, text: "Spotted nightjar" }, - { id: 15, text: "Quenda" }, - { id: 16, text: "Common bronzewing" }, - { id: 17, text: "Tawny frogmouth" }, - { id: 18, text: "Quokka" }, - { id: 19, text: "Emu" }, - { id: 20, text: "Tawny-crowned honeyeater" }, - { id: 21, text: "Rabbit" }, - { id: 22, text: "Galah" }, - { id: 23, text: "Wedge-tailed eagle" }, - { id: 24, text: "Western brush wallaby" }, - { id: 25, text: "Grey butcherbird" }, - { id: 26, text: "Welcome swallow" }, - { id: 27, text: "Western grey kangaroo" }, - { id: 28, text: "Grey currawong" }, - { id: 29, text: "Western bristlebird" }, - { id: 30, text: "Western ringtail possum" }, - { id: 31, text: "Grey fantail" }, - { id: 32, text: "Western fieldwren" }, - { id: 33, text: "Faulty" }, - { id: 34, text: "Laughing kookaburra" }, - { id: 35, text: "Human" }, - { id: 36, text: "Magpie" }, - { id: 37, text: "Western rosella" }, - { id: 38, text: "Nothing" }, - { id: 39, text: "Malleefowl" }, - { id: 40, text: "Western spinebill" }, - { id: 41, text: "Small mammal" }, - { id: 42, text: "Nankeen kestrel" }, - { id: 43, text: "Western wattlebird" }, - { id: 44, text: "Bird" }, - { id: 45, text: "New holland honeyeater" }, - { id: 46, text: "Western whipbird" }, - { id: 47, text: "Mammal" }, - { id: 48, text: "Noisy scrub-bird" }, - { id: 49, text: "Western whistler" }, - { id: 50, text: "Reptile" }, - { id: 51, text: "Painted button-quail" }, - { id: 52, text: "White-browed scrubwren" }, - { id: 53, text: "Bobtail skink" }, - { id: 54, text: "Purple swamphen" }, - { id: 55, text: "White-cheeked honeyeater" }, - { id: 56, text: "Heath monitor" }, - { id: 57, text: "Red wattlebird" }, - { id: 58, text: "Willie wagtail" }, - { id: 59, text: "King skink" }, - { id: 60, text: "Red-capped parrot" }, - { id: 61, text: "Brushtail possum" }, - { id: 62, text: "Western blue-tongued skink" }, - { id: 63, text: "Red-eared firetail" }, - { id: 64, text: "Bush rat" }, -]; +]; // text-only? interface ClassificationFormProps { - anomalyType: string; + anomalyType: AnomalyTypes; anomalyId: string; missionNumber: number; assetMentioned: string; @@ -272,6 +248,65 @@ interface ClassificationFormProps { structureItemId?: number; }; +interface ClassificationOption { + id: number; + text: string; + subOptions?: ClassificationOption[]; +}; + +export type AnomalyTypes = + | "planet" + | "roverImg" + | "cloud" + | "zoodex-burrowingOwl" + | "zoodex-iguanasFromAbove" + | "DiskDetective" + | "sunspot" + | "zoodex-nestQuestGo"; + +const anomalyConfig: Record = { + "planet": { + placeholder: "Describe the planetary dips you see...", + options: planetClassificationOptions, + textAreaCount: 1 + }, + "roverImg": { + placeholder: "Describe the terrain or objects found in the image...", + options: roverImgClassificationOptions, + textAreaCount: 1 + }, + "cloud": { + placeholder: "Describe the cloud formations & locations...", + options: initialCloudClassificationOptions, + textAreaCount: 1 + }, + "zoodex-burrowingOwl": { + placeholder: "Describe the behavior or condition of the owls...", + options: zoodexBurrowingOwlClassificationOptions, + textAreaCount: 1 + }, + "zoodex-iguanasFromAbove": { + placeholder: "Describe the iguana sightings...", + options: zoodexIguanasFromAboveClassificationOptions, + textAreaCount: 1 + }, + "DiskDetective": { + placeholder: "Describe the object seen in the disk...", + options: diskDetectorClassificationOptions, + textAreaCount: 1 + }, + "sunspot": { + placeholder: "Describe the sunspots you see and how many...", + options: [], + textAreaCount: 2, + }, + "zoodex-nestQuestGo": { + placeholder: "Enter details about the nest...", + options: [], + textAreaCount: 3, + }, +}; + const ClassificationForm: React.FC = ({ anomalyType, anomalyId, missionNumber, assetMentioned, originatingStructure, structureItemId }) => { const supabase = useSupabaseClient(); const session = useSession(); @@ -291,49 +326,10 @@ const ClassificationForm: React.FC = ({ anomalyType, an const { userProfile } = useProfileContext(); const [loading, setIsLoading] = useState(true); - const placeholder = (() => { - switch (anomalyType) { - case "planet": - return "Describe the planetary dips you see..."; - case "roverImg": - return "Describe the terrain or objects found in the image..."; - case "cloud": - return "Describe the cloud formations & locations..."; - case "zoodex-burrowingOwl": - return "Describe the behavior or condition of the owls..."; - case 'zoodex-iguanasFromAbove': - return "Describe the iguana sightings..."; - case 'DiskDetective': - return "Describe the object seen in the disk..."; - case 'sunspot': - return "Describe the sunspots you see..."; - default: - return "Enter your classification details..."; - }; - })(); - - const classificationOptions = (() => { - switch (anomalyType) { - case "planet": - return planetClassificationOptions; - case "roverImg": - return roverImgClassificationOptions; - case "cloud": - return initialCloudClassificationOptions; - case "zoodex-burrowingOwl": - return zoodexBurrowingOwlClassificationOptions; - case 'zoodex-iguanasFromAbove': - return zoodexIguanasFromAboveClassificationOptions; - case 'zoodex-southCoastFaunaRecovery': - return zoodexSouthCoastFaunaRecovery; - case 'DiskDetective': - return diskDetectorClassificationOptions; - case 'sunspot': - return sunspotsConfigurationTemporary; - default: - return []; - }; - })(); + const { placeholder, options: classificationOptions, textAreaCount } = anomalyConfig[anomalyType] || { placeholder: "Enter your classification details...", options: [], textAreaCount: 0 }; + const showTextArea = classificationOptions.length === 0; + + const [textAreaContents, setTextAreaContents] = useState(Array(textAreaCount).fill("")); const [hasClassified, setHasClassified] = useState(false); const [showResearch, setShowResearch] = useState(false); @@ -451,6 +447,7 @@ const ClassificationForm: React.FC = ({ anomalyType, an activePlanet: activePlanet?.id, structureId: originatingStructure ?? null, createdBy: inventoryItemId ?? null, + textAreas: textAreaContents, }; try { @@ -597,25 +594,26 @@ const ClassificationForm: React.FC = ({ anomalyType, an You need to repair the structure's durability before you can use it. ) : ( -
-
- {classificationOptions.map(option => ( - - ))} -
-
- <> +
+ {classificationOptions.length > 0 ? ( +
+
+ {classificationOptions.map(option => ( + + ))} +
+
{ + onUpload={(filePath) => { setAvatarUrl(filePath); }} /> @@ -623,7 +621,6 @@ const ClassificationForm: React.FC = ({ anomalyType, an value={content} onChange={e => setContent(e.target.value)} className="flex-grow p-3 h-24 text-white rounded-xl border border-[#3B4252] bg-[#3B4252] focus:border-[#88C0D0] focus:ring focus:ring-[#88C0D0] outline-none" - // placeholder={`What do you think about this ${anomalyType === "planet" ? "planet" : "rover image"}?`} placeholder={placeholder} />
@@ -643,12 +640,47 @@ const ClassificationForm: React.FC = ({ anomalyType, an > Submit - -
+
+
+ ) : ( +
+
+ { + setAvatarUrl(filePath); + }} + /> +