-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from NikDoe/feature/housing-stays-page
add another fields in create property form
- Loading branch information
Showing
21 changed files
with
422 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { accommodationList } from '@/utils/accommodation'; | ||
import { CounterInput } from '../form'; | ||
|
||
function AccommodationBlock() { | ||
return ( | ||
<> | ||
<h3 className='text-base font-bold mt-20 mb-10'>Информация о проживании</h3> | ||
<div className='grid md:grid-cols-2 gap-10 mt-10'> | ||
{accommodationList.map(({ name, labelText }) => ( | ||
<CounterInput | ||
key={name} | ||
name={name} | ||
labelText={labelText} | ||
/> | ||
))} | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default AccommodationBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CategoriesInput, CountriesInput, FormInput, PriceInput } from '../form'; | ||
|
||
function DetailsBlock() { | ||
return ( | ||
<> | ||
<h3 className='text-base font-bold mt-20 mb-10'>Детали о жилье</h3> | ||
<div className='grid md:grid-cols-2 gap-10 my-10'> | ||
<FormInput | ||
name='name' | ||
type='text' | ||
label='Название (макс. 20 символов)' | ||
defaultValue='Глэмпинг в Гомеле: Уютный домик в стиле Тосканы' | ||
/> | ||
<PriceInput /> | ||
<CategoriesInput /> | ||
<CountriesInput placeholder='Выберите страну' /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default DetailsBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Link from 'next/link'; | ||
import { Button } from '../ui/button'; | ||
|
||
function FormHeader() { | ||
return ( | ||
<div className='flex flex-col md:flex-row justify-between'> | ||
<h1 className='mb-4 text-3xl font-semibold lg:mb-20'> | ||
Объявление о жилье | ||
</h1> | ||
<Button asChild> | ||
<Link href='/experiences/create-experience'>Организовать мероприятие</Link> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export default FormHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as FormHeader } from './FormHeader'; | ||
export { default as DetailsBlock } from './DetailsBlock'; | ||
export { default as AccommodationBlock } from './AccommodationBlock'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Label } from '../ui/label'; | ||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; | ||
|
||
const DEFAULT_ARRAY_LENGTH = 4; | ||
|
||
type CounterInputProps = { | ||
name: string; | ||
maxValue?: number; | ||
labelText?: string; | ||
placeholder?: string; | ||
} | ||
|
||
function CounterInput(props: CounterInputProps) { | ||
const { maxValue, labelText, name, placeholder } = props; | ||
const length = maxValue ? maxValue + 1 : DEFAULT_ARRAY_LENGTH + 1; | ||
|
||
return ( | ||
<div> | ||
<Label htmlFor={name}> | ||
{labelText} | ||
</Label> | ||
<Select | ||
name={name} | ||
required | ||
> | ||
<SelectTrigger id={name}> | ||
<SelectValue placeholder={placeholder || 0} /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{Array.from({ length }, (_, i) => ( | ||
<SelectItem key={i + 1} value={(i).toString()}> | ||
{i} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
); | ||
} | ||
|
||
export default CounterInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
import { Label } from '@/components/ui/label'; | ||
import { formattedCountries, truncateCountryName } from '@/utils/countries'; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from '@/components/ui/select'; | ||
import { Prisma } from '@prisma/client'; | ||
|
||
const name = Prisma.PropertyScalarFieldEnum.country; | ||
|
||
function CountriesInput({ placeholder }: { placeholder?: string }) { | ||
return ( | ||
<div> | ||
<Label htmlFor={name}> | ||
Страна | ||
</Label> | ||
<Select | ||
name={name} | ||
required | ||
> | ||
<SelectTrigger id={name}> | ||
<SelectValue placeholder={placeholder} /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{formattedCountries.map((item) => { | ||
return ( | ||
<SelectItem | ||
key={item.code} | ||
value={item.code} | ||
> | ||
{truncateCountryName(item.name, 34)} | ||
</SelectItem> | ||
); | ||
})} | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
); | ||
} | ||
|
||
export default CountriesInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { CountryItem } from '@/utils/types'; | ||
import { SelectItem } from '../ui/select'; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipTrigger, | ||
} from '../ui/tooltip'; | ||
import { truncateCountryName } from '@/utils/countries'; | ||
|
||
type SelectCountryItemProps = { | ||
item: CountryItem | ||
} | ||
|
||
function SelectCountryItem({ item }: SelectCountryItemProps) { | ||
const isLongCountryName = item.name.length > 20; | ||
|
||
return ( | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<SelectItem value={item.code}> | ||
{truncateCountryName(item.name)} | ||
</SelectItem> | ||
</TooltipTrigger> | ||
{ | ||
isLongCountryName && ( | ||
<TooltipContent className='truncate'> | ||
{item.name} | ||
</TooltipContent> | ||
) | ||
} | ||
</Tooltip> | ||
); | ||
} | ||
|
||
export default SelectCountryItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.