fix: add other properties back-end
This commit is contained in:
parent
16b415740c
commit
2dbf9e1ad4
@ -3,7 +3,6 @@ import HeroImage from "@/components/HeroImage";
|
||||
import Pagination from "@/components/Pagination";
|
||||
import { CardPropertyData } from "@/schema/property";
|
||||
import { getDefaultMetadata } from "@/utils/metadata";
|
||||
import { Country, State } from "country-state-city";
|
||||
import { Metadata } from "next";
|
||||
|
||||
const metaDesc = "Explore the latest properties on the Dynamic Realty.";
|
||||
@ -76,9 +75,6 @@ const propertiesData: CardPropertyData[] = [
|
||||
];
|
||||
|
||||
export default function ListingsForRent() {
|
||||
// const countries = State.getStatesOfCountry("ID");
|
||||
// console.log(countries);
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeroImage title="Listings For Rent" />
|
||||
|
@ -5,6 +5,16 @@ export const Properties: CollectionConfig = {
|
||||
slug: "properties",
|
||||
labels: { plural: "Properties", singular: "Property" },
|
||||
fields: [
|
||||
{
|
||||
name: "propertyType",
|
||||
label: "Type",
|
||||
type: "select",
|
||||
options: [
|
||||
{ label: "Rent", value: "rent" },
|
||||
{ label: "Sell", value: "sell" },
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
type: "text",
|
||||
@ -22,7 +32,7 @@ export const Properties: CollectionConfig = {
|
||||
},
|
||||
{
|
||||
name: "images",
|
||||
type: "relationship",
|
||||
type: "upload",
|
||||
relationTo: "media",
|
||||
hasMany: true,
|
||||
minRows: 1,
|
||||
@ -66,19 +76,44 @@ export const Properties: CollectionConfig = {
|
||||
{
|
||||
name: "country_code",
|
||||
label: "Country",
|
||||
type: "text",
|
||||
type: "select",
|
||||
options: [
|
||||
{
|
||||
label: "United States",
|
||||
value: "US",
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
// admin: {
|
||||
// components: {
|
||||
// Field: {
|
||||
// path: "/components/payload-custom/InputCountry",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
},
|
||||
{
|
||||
name: "state_code",
|
||||
label: "State",
|
||||
type: "text",
|
||||
type: "select",
|
||||
options: [
|
||||
{
|
||||
label: "Washington",
|
||||
value: "WA",
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "city_code",
|
||||
label: "City",
|
||||
type: "text",
|
||||
type: "select",
|
||||
options: [
|
||||
{
|
||||
label: "Davenport",
|
||||
value: "Davenport",
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
|
37
src/components/payload-custom/InputCountry.tsx
Normal file
37
src/components/payload-custom/InputCountry.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { useField } from "@payloadcms/ui";
|
||||
import { TextFieldClientComponent } from "payload";
|
||||
|
||||
const InputCountry: TextFieldClientComponent = ({ path, field }) => {
|
||||
const { value, setValue } = useField({ path });
|
||||
const { showError } = useField();
|
||||
|
||||
return (
|
||||
<div className={`field-type select ${showError ? "has-error" : ""}`}>
|
||||
{/* @ts-ignore */}
|
||||
<span>jancok</span>
|
||||
{/* <label htmlFor={field.name} required={field.required}></label> */}
|
||||
<div className="select-input-wrapper">
|
||||
<select
|
||||
name={field.name}
|
||||
// @ts-ignore
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
disabled={field.admin?.readOnly}
|
||||
>
|
||||
<option value="">-- Select --</option>
|
||||
{/* {field.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</option>
|
||||
))} */}
|
||||
</select>
|
||||
</div>
|
||||
{/* {field.admin && <FieldDescription value={admin.description} />}
|
||||
{showError && <Error message={errorMessage} />} */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default InputCountry;
|
@ -239,6 +239,7 @@ export interface PropertyFeature {
|
||||
*/
|
||||
export interface Property {
|
||||
id: number;
|
||||
propertyType: 'rent' | 'sell';
|
||||
name: string;
|
||||
slug?: string | null;
|
||||
images: (number | Media)[];
|
||||
@ -263,9 +264,9 @@ export interface Property {
|
||||
bedrooms_count: string;
|
||||
};
|
||||
addressGroup: {
|
||||
country_code: string;
|
||||
state_code: string;
|
||||
city_code: string;
|
||||
country_code: 'US';
|
||||
state_code: 'WA';
|
||||
city_code: 'Davenport';
|
||||
zip_code: string;
|
||||
address: string;
|
||||
};
|
||||
@ -455,6 +456,7 @@ export interface PropertyFeaturesSelect<T extends boolean = true> {
|
||||
* via the `definition` "properties_select".
|
||||
*/
|
||||
export interface PropertiesSelect<T extends boolean = true> {
|
||||
propertyType?: T;
|
||||
name?: T;
|
||||
slug?: T;
|
||||
images?: T;
|
||||
|
Loading…
x
Reference in New Issue
Block a user