|
|
@@ -68,8 +68,7 @@ export default function PlaceForm({ type, onSuccess, place }: PlaceFormProps) {
|
|
|
setShowMapPicker(false)
|
|
|
}
|
|
|
|
|
|
- const handleSubmit = async (e: React.FormEvent) => {
|
|
|
- e.preventDefault()
|
|
|
+ const submitPlace = async (status?: string) => {
|
|
|
setLoading(true)
|
|
|
setError('')
|
|
|
|
|
|
@@ -102,6 +101,8 @@ export default function PlaceForm({ type, onSuccess, place }: PlaceFormProps) {
|
|
|
body.currency = 'RUB'
|
|
|
}
|
|
|
|
|
|
+ if (status) body.status = status
|
|
|
+
|
|
|
if (isEdit) {
|
|
|
await api.patch(`/places/${place.id}`, body)
|
|
|
} else {
|
|
|
@@ -115,6 +116,9 @@ export default function PlaceForm({ type, onSuccess, place }: PlaceFormProps) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); submitPlace() }
|
|
|
+ const handleSaveDraft = () => submitPlace('draft')
|
|
|
+
|
|
|
const toggleTag = (id: string) => {
|
|
|
setSelectedTags((prev) =>
|
|
|
prev.includes(id) ? prev.filter((t) => t !== id) : [...prev, id]
|
|
|
@@ -292,13 +296,18 @@ export default function PlaceForm({ type, onSuccess, place }: PlaceFormProps) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <button
|
|
|
- type="submit"
|
|
|
- disabled={loading}
|
|
|
- className="w-full rounded-lg bg-green-600 px-4 py-3 font-medium text-white hover:bg-green-500 transition disabled:opacity-50"
|
|
|
- >
|
|
|
- {loading ? 'Сохранение...' : isEdit ? 'Сохранить' : `Создать ${type === 'studio' ? 'студию' : 'место'}`}
|
|
|
- </button>
|
|
|
+ <div className="flex gap-3">
|
|
|
+ {!isEdit && (
|
|
|
+ <button type="button" onClick={handleSaveDraft} disabled={loading}
|
|
|
+ className="flex-1 rounded-lg border border-white/20 px-4 py-3 font-medium text-white/80 hover:bg-white/5 transition disabled:opacity-50"
|
|
|
+ >{loading ? 'Сохранение...' : 'Сохранить черновик'}</button>
|
|
|
+ )}
|
|
|
+ <button type="submit" disabled={loading}
|
|
|
+ className={`rounded-lg bg-green-600 px-4 py-3 font-medium text-white hover:bg-green-500 transition disabled:opacity-50 ${isEdit ? 'w-full' : 'flex-1'}`}
|
|
|
+ >
|
|
|
+ {loading ? 'Сохранение...' : isEdit ? 'Сохранить' : `Опубликовать ${type === 'studio' ? 'студию' : 'место'}`}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
|
|
|
{showMapPicker && <MapPicker onSelect={handleMapPick} onClose={() => setShowMapPicker(false)} />}
|
|
|
</form>
|