Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-search): get api route from useConfig #10632

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/plugin-search/src/Search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { generateReindexHandler } from '../utilities/generateReindexHandler.js'
export const generateSearchCollection = (
pluginConfig: SearchPluginConfigWithLocales,
): CollectionConfig => {
const apiBasePath = pluginConfig?.apiBasePath || '/api'
const searchSlug = pluginConfig?.searchOverrides?.slug || 'search'
const searchCollections = pluginConfig?.collections || []
const collectionLabels = pluginConfig?.labels
Expand Down Expand Up @@ -71,7 +70,6 @@ export const generateSearchCollection = (
{
path: '@payloadcms/plugin-search/client#ReindexButton',
serverProps: {
apiBasePath,
collectionLabels,
searchCollections,
searchSlug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Popup,
PopupList,
toast,
useConfig,
useLocale,
useModal,
useTranslation,
Expand All @@ -20,11 +21,11 @@ import { ReindexConfirmModal } from './ReindexConfirmModal/index.js'
const confirmReindexModalSlug = 'confirm-reindex-modal'

export const ReindexButtonClient: React.FC<ReindexButtonProps> = ({
apiBasePath,
collectionLabels,
searchCollections,
searchSlug,
}) => {
const apiBasePath = useConfig().config.routes.api
const { closeModal, openModal } = useModal()
const {
i18n: { t },
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-search/src/Search/ui/ReindexButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SearchReindexButtonServerComponent } from './types.js'
import { ReindexButtonClient } from './index.client.js'

export const ReindexButton: SearchReindexButtonServerComponent = (props) => {
const { apiBasePath, collectionLabels, i18n, searchCollections, searchSlug } = props
const { collectionLabels, i18n, searchCollections, searchSlug } = props

const getStaticLocalizedPluralLabels = () => {
return Object.fromEntries(
Expand All @@ -26,7 +26,6 @@ export const ReindexButton: SearchReindexButtonServerComponent = (props) => {

return (
<ReindexButtonClient
apiBasePath={apiBasePath}
collectionLabels={getStaticLocalizedPluralLabels()}
searchCollections={searchCollections}
searchSlug={searchSlug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { CustomComponent, PayloadServerReactComponent, StaticLabel } from '
import type { CollectionLabels } from '../../../types.js'

export type ReindexButtonProps = {
apiBasePath: string
collectionLabels: Record<string, StaticLabel>
searchCollections: string[]
searchSlug: string
Expand Down
Loading