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 Pagination from "@/components/Pagination";
|
||||||
import { CardPropertyData } from "@/schema/property";
|
import { CardPropertyData } from "@/schema/property";
|
||||||
import { getDefaultMetadata } from "@/utils/metadata";
|
import { getDefaultMetadata } from "@/utils/metadata";
|
||||||
import { Country, State } from "country-state-city";
|
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
|
|
||||||
const metaDesc = "Explore the latest properties on the Dynamic Realty.";
|
const metaDesc = "Explore the latest properties on the Dynamic Realty.";
|
||||||
@ -76,9 +75,6 @@ const propertiesData: CardPropertyData[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function ListingsForRent() {
|
export default function ListingsForRent() {
|
||||||
// const countries = State.getStatesOfCountry("ID");
|
|
||||||
// console.log(countries);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HeroImage title="Listings For Rent" />
|
<HeroImage title="Listings For Rent" />
|
||||||
|
@ -5,6 +5,16 @@ export const Properties: CollectionConfig = {
|
|||||||
slug: "properties",
|
slug: "properties",
|
||||||
labels: { plural: "Properties", singular: "Property" },
|
labels: { plural: "Properties", singular: "Property" },
|
||||||
fields: [
|
fields: [
|
||||||
|
{
|
||||||
|
name: "propertyType",
|
||||||
|
label: "Type",
|
||||||
|
type: "select",
|
||||||
|
options: [
|
||||||
|
{ label: "Rent", value: "rent" },
|
||||||
|
{ label: "Sell", value: "sell" },
|
||||||
|
],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
type: "text",
|
type: "text",
|
||||||
@ -22,7 +32,7 @@ export const Properties: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "images",
|
name: "images",
|
||||||
type: "relationship",
|
type: "upload",
|
||||||
relationTo: "media",
|
relationTo: "media",
|
||||||
hasMany: true,
|
hasMany: true,
|
||||||
minRows: 1,
|
minRows: 1,
|
||||||
@ -66,19 +76,44 @@ export const Properties: CollectionConfig = {
|
|||||||
{
|
{
|
||||||
name: "country_code",
|
name: "country_code",
|
||||||
label: "Country",
|
label: "Country",
|
||||||
type: "text",
|
type: "select",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "United States",
|
||||||
|
value: "US",
|
||||||
|
},
|
||||||
|
],
|
||||||
required: true,
|
required: true,
|
||||||
|
// admin: {
|
||||||
|
// components: {
|
||||||
|
// Field: {
|
||||||
|
// path: "/components/payload-custom/InputCountry",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "state_code",
|
name: "state_code",
|
||||||
label: "State",
|
label: "State",
|
||||||
type: "text",
|
type: "select",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Washington",
|
||||||
|
value: "WA",
|
||||||
|
},
|
||||||
|
],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "city_code",
|
name: "city_code",
|
||||||
label: "City",
|
label: "City",
|
||||||
type: "text",
|
type: "select",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Davenport",
|
||||||
|
value: "Davenport",
|
||||||
|
},
|
||||||
|
],
|
||||||
required: true,
|
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 {
|
export interface Property {
|
||||||
id: number;
|
id: number;
|
||||||
|
propertyType: 'rent' | 'sell';
|
||||||
name: string;
|
name: string;
|
||||||
slug?: string | null;
|
slug?: string | null;
|
||||||
images: (number | Media)[];
|
images: (number | Media)[];
|
||||||
@ -263,9 +264,9 @@ export interface Property {
|
|||||||
bedrooms_count: string;
|
bedrooms_count: string;
|
||||||
};
|
};
|
||||||
addressGroup: {
|
addressGroup: {
|
||||||
country_code: string;
|
country_code: 'US';
|
||||||
state_code: string;
|
state_code: 'WA';
|
||||||
city_code: string;
|
city_code: 'Davenport';
|
||||||
zip_code: string;
|
zip_code: string;
|
||||||
address: string;
|
address: string;
|
||||||
};
|
};
|
||||||
@ -455,6 +456,7 @@ export interface PropertyFeaturesSelect<T extends boolean = true> {
|
|||||||
* via the `definition` "properties_select".
|
* via the `definition` "properties_select".
|
||||||
*/
|
*/
|
||||||
export interface PropertiesSelect<T extends boolean = true> {
|
export interface PropertiesSelect<T extends boolean = true> {
|
||||||
|
propertyType?: T;
|
||||||
name?: T;
|
name?: T;
|
||||||
slug?: T;
|
slug?: T;
|
||||||
images?: T;
|
images?: T;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user