mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
a3f6635633
Tags on the place form are pills in their own colour, with a palette under the dot that recolours a tag for the whole trip (PUT /trips/:id/tags/:id was there already, the client now reaches it through repo and store) and a custom colour field of its own instead of the system picker. A new tag is made in a colour picked the same way. Description, notes and the note for one day's visit sit in one card under a switch, each with a line on where the text shows up; the day tab is named after its day and is only there with one visit in context. Nothing about the three fields changes underneath. Opening hours get a switch for open around the clock next to closed. Google writes a place open all week as one period on Sunday that never closes; it read as Sunday open and every other day closed, and now opens every day. The phone form follows the desktop: category as one field with a list, tags in one field, the texts switch, and phone, e-mail and opening hours, which it did not have. The hours and the text tabs are shared hooks (usePlaceHours, usePlaceTextTabs). Files and costs on the phone sheets are drawn as fields like the rest, and the paste hint, a keyboard shortcut a phone has no use for, is gone with its key.
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import type { Dispatch, SetStateAction } from 'react'
|
|
import PlFileAttach from './PlFileAttach'
|
|
import MLinkedCosts from './MLinkedCosts'
|
|
import { useReservationFiles } from '../../../../components/Planner/useRecordLinks'
|
|
import type { BudgetItem } from '../../../../types'
|
|
import type { TripPlanner } from '../MTripShell'
|
|
|
|
interface MBookingFilesCostsProps {
|
|
planner: TripPlanner
|
|
/** The saved booking or transport; linking waits for it. */
|
|
reservationId: number | null | undefined
|
|
pendingFiles: File[]
|
|
setPendingFiles: Dispatch<SetStateAction<File[]>>
|
|
canUploadFiles: boolean
|
|
/** The Costs addon is on. */
|
|
showCosts: boolean
|
|
createDisabled: boolean
|
|
onCreate: () => void
|
|
onEdit: (item: BudgetItem) => void
|
|
}
|
|
|
|
/**
|
|
* The foot of the phone booking and transport sheets (#2084): the Files row
|
|
* with the files already on the booking and one of the trip's to link, then
|
|
* the Costs block with its linked expenses. The attached files are listed
|
|
* whoever uploaded them, so one from the desktop shows here too (#2217). Both
|
|
* sheets carry exactly this, so it lives here once.
|
|
*/
|
|
export default function MBookingFilesCosts({
|
|
planner, reservationId, pendingFiles, setPendingFiles, canUploadFiles, showCosts, createDisabled, onCreate, onEdit,
|
|
}: MBookingFilesCostsProps) {
|
|
const bookingFiles = useReservationFiles(reservationId)
|
|
const showFiles = canUploadFiles || bookingFiles.attached.length > 0 || bookingFiles.linkable.length > 0
|
|
|
|
return (
|
|
<>
|
|
{showFiles && (
|
|
<PlFileAttach
|
|
planner={planner}
|
|
files={pendingFiles}
|
|
onAdd={files => setPendingFiles(prev => [...prev, ...files])}
|
|
onRemove={idx => setPendingFiles(prev => prev.filter((_, i) => i !== idx))}
|
|
canAttach={canUploadFiles}
|
|
attached={bookingFiles.attached}
|
|
linkable={bookingFiles.linkable}
|
|
onLink={bookingFiles.link}
|
|
/>
|
|
)}
|
|
{showCosts && (
|
|
<MLinkedCosts
|
|
reservationId={reservationId}
|
|
hintKey="reservations.createExpenseHint"
|
|
createDisabled={createDisabled}
|
|
onCreate={onCreate}
|
|
onEdit={onEdit}
|
|
/>
|
|
)}
|
|
</>
|
|
)
|
|
}
|