form!
title "Configure Calls"

field(
	var: "fwd[timeout]",
	type: "text-single",
	datatype: "xs:integer",
	label: "Seconds to ring before voicemail",
	description: "One ring is ~5 seconds. Negative means ring forever.",
	value: @customer.fwd.timeout.to_i.to_s
)

field(
	var: "voicemail_transcription",
	type: "boolean",
	label: "Voicemail transcription",
	value: @customer.transcription_enabled.to_s
)

field(
	var: "fwd[uri]",
	type: "list-single",
	datatype: "xs:anyURI",
	open: true,
	label: "Forward calls to",
	description: "List item or any custom xmpp:, sip:, or tel: URI.",
	options: [
		{ label: "Jabber ID", value: "xmpp:#{@customer.jid}" },
		{ label: "SIP Account", value: @customer.sip_account.uri }
	],
	value: @customer.fwd.uri
)

if (lidb = @customer.tndetails.dig(:features, :lidb))
	field(
		var: "lidb_name",
		type: "fixed",
		label: "CNAM",
		value: "#{lidb[:subscriber_information]} (#{lidb[:status]})"
	)
elsif @customer.tndetails[:on_net_vendor]
	field(
		var: "lidb_name",
		type: "text-single",
		label: "CNAM Name",
		description: "or nothing/space to leave blank"
	)
end
