From 6db5e1d3b2bfc736b241c2ad9e574ff6088f0841 Mon Sep 17 00:00:00 2001 From: "Mr. Singleton" Date: Wed, 13 Dec 2023 11:12:10 -0500 Subject: [PATCH] control over which documents can be searched by a page. --- functions/src/groqQueries.ts | 1 + .../resume/resume-bio/ResumeBioSection.js | 6 ++ .../ResumeContactUsSection.js | 7 +++ .../resume-education/ResumeEducation.js | 7 +++ .../ResumeEducationSection.js | 7 +++ .../resume-experience/ResumeExperience.js | 7 +++ .../ResumeExperienceSection.js | 7 +++ .../resume/resume-feedback/ResumeFeedback.js | 7 +++ .../resume-feedback/ResumeFeedbackSection.js | 7 +++ .../resume-portfolio/ResumePortfolioItem.js | 7 +++ .../ResumePortfolioSection.js | 7 +++ .../resume/resume-skills/ResumeSkill.js | 9 ++- .../resume/resume-skills/ResumeSkillSet.js | 7 +++ .../resume-skills/ResumeSkillsSection.js | 6 ++ src/common/sanityIo/Types.ts | 2 +- src/common/sanityIo/groqQueries.ts | 3 +- src/components/block-content-ui/cmsClient.ts | 27 ++++++--- .../mackenzies-mind/header/FullTextSearch.tsx | 28 ++++++--- .../resume-bio-section/ResumeBioSection.tsx | 23 ++++--- .../ResumePortfolioEntry.tsx | 2 +- .../ResumePortfolioSection.tsx | 2 +- .../ResumeSkillReferences.tsx | 60 ++++++++++++++----- 22 files changed, 192 insertions(+), 47 deletions(-) diff --git a/functions/src/groqQueries.ts b/functions/src/groqQueries.ts index 8dd4df1c..00b71a6b 100644 --- a/functions/src/groqQueries.ts +++ b/functions/src/groqQueries.ts @@ -58,6 +58,7 @@ const SERVICE = const HOMEPAGE = `_type, + _id, title, isUnderConstruction, releaseDate, diff --git a/sanityIo/schemas/sections/resume/resume-bio/ResumeBioSection.js b/sanityIo/schemas/sections/resume/resume-bio/ResumeBioSection.js index c553f7b4..1415da17 100644 --- a/sanityIo/schemas/sections/resume/resume-bio/ResumeBioSection.js +++ b/sanityIo/schemas/sections/resume/resume-bio/ResumeBioSection.js @@ -13,6 +13,12 @@ export default { title: 'Title of Section', type: 'string', }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, { name: 'introduction', title: 'Introduction', diff --git a/sanityIo/schemas/sections/resume/resume-contact-us/ResumeContactUsSection.js b/sanityIo/schemas/sections/resume/resume-contact-us/ResumeContactUsSection.js index b57ec248..e6fb2b82 100644 --- a/sanityIo/schemas/sections/resume/resume-contact-us/ResumeContactUsSection.js +++ b/sanityIo/schemas/sections/resume/resume-contact-us/ResumeContactUsSection.js @@ -30,6 +30,13 @@ export default { title: 'Form Submit Button Text', type: 'string' }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ], preview: { select: { diff --git a/sanityIo/schemas/sections/resume/resume-education/ResumeEducation.js b/sanityIo/schemas/sections/resume/resume-education/ResumeEducation.js index 222c76b6..6e3a81af 100644 --- a/sanityIo/schemas/sections/resume/resume-education/ResumeEducation.js +++ b/sanityIo/schemas/sections/resume/resume-education/ResumeEducation.js @@ -43,6 +43,13 @@ export default { title: 'Job Description or Requirements', type: 'text', }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ], preview: { select: { diff --git a/sanityIo/schemas/sections/resume/resume-education/ResumeEducationSection.js b/sanityIo/schemas/sections/resume/resume-education/ResumeEducationSection.js index 35029ce5..a9de6e38 100644 --- a/sanityIo/schemas/sections/resume/resume-education/ResumeEducationSection.js +++ b/sanityIo/schemas/sections/resume/resume-education/ResumeEducationSection.js @@ -35,5 +35,12 @@ export default { } ] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-experience/ResumeExperience.js b/sanityIo/schemas/sections/resume/resume-experience/ResumeExperience.js index d9e40470..e8502752 100644 --- a/sanityIo/schemas/sections/resume/resume-experience/ResumeExperience.js +++ b/sanityIo/schemas/sections/resume/resume-experience/ResumeExperience.js @@ -57,6 +57,13 @@ export default { to: [{type: "ResumeSkill"}] }] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ], preview: { select: { diff --git a/sanityIo/schemas/sections/resume/resume-experience/ResumeExperienceSection.js b/sanityIo/schemas/sections/resume/resume-experience/ResumeExperienceSection.js index 31584456..ff7cd340 100644 --- a/sanityIo/schemas/sections/resume/resume-experience/ResumeExperienceSection.js +++ b/sanityIo/schemas/sections/resume/resume-experience/ResumeExperienceSection.js @@ -35,5 +35,12 @@ export default { type: 'reference', to:[{type: 'MuiTheme'}] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedback.js b/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedback.js index 5aebec2f..ea6761ed 100644 --- a/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedback.js +++ b/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedback.js @@ -36,6 +36,13 @@ export default { hotspot: true, }, }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ], preview: { select: { diff --git a/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedbackSection.js b/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedbackSection.js index a5d9e2ab..4f66d184 100644 --- a/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedbackSection.js +++ b/sanityIo/schemas/sections/resume/resume-feedback/ResumeFeedbackSection.js @@ -35,5 +35,12 @@ export default { } ] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioItem.js b/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioItem.js index c23d6b35..cf8067ed 100644 --- a/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioItem.js +++ b/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioItem.js @@ -69,5 +69,12 @@ export default { type: 'array', of:[{type: 'image'}] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioSection.js b/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioSection.js index 767f1f72..22703336 100644 --- a/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioSection.js +++ b/sanityIo/schemas/sections/resume/resume-portfolio/ResumePortfolioSection.js @@ -35,5 +35,12 @@ export default { } ] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkill.js b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkill.js index 8b76921c..dbe488f6 100644 --- a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkill.js +++ b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkill.js @@ -12,6 +12,13 @@ export default { name: 'title', title: 'Title of Skillset', type: 'string', - } + }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillSet.js b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillSet.js index 965678df..05cf0f90 100644 --- a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillSet.js +++ b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillSet.js @@ -22,5 +22,12 @@ export default { to: [{type: "ResumeSkill"}] }] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, + ] } \ No newline at end of file diff --git a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillsSection.js b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillsSection.js index 0fe8c874..19402337 100644 --- a/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillsSection.js +++ b/sanityIo/schemas/sections/resume/resume-skills/ResumeSkillsSection.js @@ -31,5 +31,11 @@ export default { of: [{type: "reference", to:{type:"ResumeSkillset"}}, ] }, + { + name: 'searchableOnPages', + title: 'Make Searchable on pages', + type: 'array', + of:[{type: "reference", to: {type:"homePage"}}] + }, ] } \ No newline at end of file diff --git a/src/common/sanityIo/Types.ts b/src/common/sanityIo/Types.ts index 6eca7261..f68d8eae 100644 --- a/src/common/sanityIo/Types.ts +++ b/src/common/sanityIo/Types.ts @@ -1,7 +1,6 @@ import {SanityImageSource} from "@sanity/asset-utils"; import {SanityImageAsset, ThwServiceItemNoRefType} from "../../components/BlockContentTypes"; import {Slug} from "@sanity/types"; -import BusinessContact from "../../../sanityIo/schemas/businessContact"; export type SanitySlug = Slug @@ -53,6 +52,7 @@ export type SanityBusinessContact = { export type SanityTransformHwHomePage = { _type?: string title?: string + _id?:string description?: string bookAppointmentLink?: string bookAppointmentQrCode?: SanityImageSource diff --git a/src/common/sanityIo/groqQueries.ts b/src/common/sanityIo/groqQueries.ts index 4ccd4920..86f59597 100644 --- a/src/common/sanityIo/groqQueries.ts +++ b/src/common/sanityIo/groqQueries.ts @@ -42,7 +42,8 @@ const SERVICE = ` -const HOMEPAGE = `_type, +const HOMEPAGE = `_type, + _id, title, isUnderConstruction, releaseDate, diff --git a/src/components/block-content-ui/cmsClient.ts b/src/components/block-content-ui/cmsClient.ts index dd4e20a8..97e32b79 100644 --- a/src/components/block-content-ui/cmsClient.ts +++ b/src/components/block-content-ui/cmsClient.ts @@ -466,8 +466,9 @@ const useFetchServicesQuery = (pageSlug?: string) => { }); } -const fullTextSearch = (textToSearch: string): Promise => { +const fullTextSearch = (textToSearch: string, pageId: string): Promise => { + console.log("the page id", pageId) return sanityClient .fetch( `*[ @@ -476,6 +477,7 @@ const fullTextSearch = (textToSearch: string): Promise => { careerTitle, introduction, name, + email, contentText, contentTexts, contentTitle, @@ -486,18 +488,17 @@ const fullTextSearch = (textToSearch: string): Promise => { contentSummaryTitle, contentSummaryTexts, videoUrl, - ] match '*${textToSearch}*']{ + ] match '*${textToSearch}*' && references('${pageId}')]{ ..., "skillsUsed" : skillsUsed[]->, "skills" : skills[]->, }`, // {searchText: textToSearch} ).then((data: any) => { - console.log("data from fulltext search", data) return data }) } -const skillReferenceSearch = (skill: ResumeSkill): Promise => { +const skillReferenceSearch = (skill: ResumeSkill, pageId: string): Promise => { return sanityClient .fetch( `*[references($searchText)]{ @@ -506,9 +507,21 @@ const skillReferenceSearch = (skill: ResumeSkill): Promise => { "skillsUsed" : skillsUsed[]->, "skills":skills[]->, }`, - {searchText: skill._id} - ).then((data: any) => { - console.log("data from skillReference search", data) + {searchText: skill._id, pageId: pageId} + ).then((data: any[]) => { + + + data.sort((left, right)=>{ + if (left._type === right._type) { + return 0 + } + + if(left._type > right._type) + return 1 + + return -1 + }) + return data }) } diff --git a/src/components/templates/mackenzies-mind/header/FullTextSearch.tsx b/src/components/templates/mackenzies-mind/header/FullTextSearch.tsx index 2db23102..75d0a6e6 100644 --- a/src/components/templates/mackenzies-mind/header/FullTextSearch.tsx +++ b/src/components/templates/mackenzies-mind/header/FullTextSearch.tsx @@ -9,7 +9,7 @@ import makeStyles from "@mui/styles/makeStyles"; import {Theme} from "@mui/material/styles"; import { AnimatedAboutUsSectionType, - HeroAnimatedContentSectionType, + HeroAnimatedContentSectionType, ResumeBioSectionType, ResumeExperience, ResumeSkill, SanityHeroContentSlide, @@ -18,6 +18,8 @@ import { import ResumeExperienceItem from "../../my-digital-resume/resume-experience-section/ResumeExperienceItem"; import {COLORS} from "../../../../theme/common/ColorPalette"; import ResumeSkillReferences from "../../my-digital-resume/resume-skills-section/ResumeSkillReferences"; +import PageContext from "../../../page-context/PageContext"; +import ResumeBioSection from "../../my-digital-resume/resume-bio-section/ResumeBioSection"; export const useStyles = makeStyles((theme: Theme) => ({ endAdornedInput: { @@ -55,10 +57,11 @@ const FullTextSearch: FunctionComponent = (props: IProps) => { const [searchText, setSearchText] = React.useState() const myClasses = useStyles(customizedTheme) const [results, setResults] = React.useState() + const pageContext = useContext(PageContext) const searchCMS = async () => { console.log("about to search full text") if (searchText) { - const cmsResponse = await cmsClient.fullTextSearch(searchText) + const cmsResponse = await cmsClient.fullTextSearch(searchText, pageContext.page?._id??"") console.log("results", cmsResponse) setResults(cmsResponse) } @@ -149,7 +152,6 @@ const FullTextSearch: FunctionComponent = (props: IProps) => { case "AnimatedServicesSection": const convertedAnimatedServicesSection: AnimatedAboutUsSectionType = theResult; - console.log(convertedAnimatedServicesSection) return Services: @@ -181,25 +183,37 @@ const FullTextSearch: FunctionComponent = (props: IProps) => { padding: "16px" }}> - My Experience + {convertedResumeExperience.title} Experience case "ResumeSkill": const convertedResumeSkill: ResumeSkill = theResult; - console.log(convertedResumeSkill) return - My Skill - - {convertedResumeSkill.title} + Experience with {convertedResumeSkill.title} + case "ResumeBioSection": + const resumeBioSectionObj: ResumeBioSectionType = theResult; + + return + + My Bio + - {resumeBioSectionObj.title} + + + default: return {theResult?._type} diff --git a/src/components/templates/my-digital-resume/resume-bio-section/ResumeBioSection.tsx b/src/components/templates/my-digital-resume/resume-bio-section/ResumeBioSection.tsx index 96aa1a53..05564b51 100644 --- a/src/components/templates/my-digital-resume/resume-bio-section/ResumeBioSection.tsx +++ b/src/components/templates/my-digital-resume/resume-bio-section/ResumeBioSection.tsx @@ -1,4 +1,4 @@ -import React, {FunctionComponent, useContext} from 'react' +import React, {FunctionComponent} from 'react' import {Button, ButtonGroup, Grid, Typography, useMediaQuery, useTheme,} from '@mui/material'; import {ResumeBioSectionType} from "../../../BlockContentTypes"; import {urlFor} from "../../../block-content-ui/static-pages/cmsStaticPagesClient"; @@ -6,13 +6,11 @@ import {SanityTransformHwHomePage} from "../../../../common/sanityIo/Types"; import useThwCommonStyles from "../../../../common/sanityIo/ThwCommonStyles"; import SocialMediaBlock from "../social-media-block/SocialMediaBlock"; import BusinessCardSubmitEmail from "../../transform-hw/pages/BusinessCardSubmitEmail"; -import CustomizedThemeProvider from "../../../customized-theme-provider/CustomizedThemeProvider"; -import CustomizedThemeContext from "../../../customized-theme-provider/CustomizedThemeContext"; interface IProps { sectionData: ResumeBioSectionType - homePage: SanityTransformHwHomePage + homePage?: SanityTransformHwHomePage } const ResumeBioSection: FunctionComponent = (props: IProps) => { @@ -22,7 +20,6 @@ const ResumeBioSection: FunctionComponent = (props: IProps) => { const smDown = useMediaQuery(theme.breakpoints.down('sm')) - const customizedthemeContext = useContext(CustomizedThemeContext) return ( @@ -49,13 +46,13 @@ const ResumeBioSection: FunctionComponent = (props: IProps) => { Phone {props.homePage.businessContact?.phone} + variant='body1'>{props.homePage?.businessContact?.phone} Email {props.homePage.businessContact?.email} + variant='body1'>{props.homePage?.businessContact?.email} {/**/} {/* = (props: IProps) => { @@ -88,7 +85,7 @@ const ResumeBioSection: FunctionComponent = (props: IProps) => {