fix qr dialog select
This commit is contained in:
@@ -121,14 +121,14 @@ export const ImportDialog = ({
|
|||||||
</span>
|
</span>
|
||||||
<div className="flex w-40 flex-col gap-1">
|
<div className="flex w-40 flex-col gap-1">
|
||||||
{channelSet?.settings.map((channel, index) => (
|
{channelSet?.settings.map((channel, index) => (
|
||||||
<>
|
<div className="flex justify-between" key={index}>
|
||||||
<Label>
|
<Label>
|
||||||
{channel.name.length
|
{channel.name.length
|
||||||
? channel.name
|
? channel.name
|
||||||
: `Channel: ${channel.id}`}
|
: `Channel: ${channel.id}`}
|
||||||
</Label>
|
</Label>
|
||||||
<Checkbox key={index} />
|
<Checkbox key={index} />
|
||||||
</>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -31,12 +31,11 @@ export const QRDialog = ({
|
|||||||
const [selectedChannels, setSelectedChannels] = useState<number[]>([0]);
|
const [selectedChannels, setSelectedChannels] = useState<number[]>([0]);
|
||||||
const [QRCodeURL, setQRCodeURL] = useState<string>("");
|
const [QRCodeURL, setQRCodeURL] = useState<string>("");
|
||||||
|
|
||||||
const filteredChannels = Array.from(channels.values()).filter((channel) =>
|
const allChannels = Array.from(channels.values());
|
||||||
selectedChannels.includes(channel.index)
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const channelsToEncode = filteredChannels
|
const channelsToEncode = allChannels
|
||||||
|
.filter((ch) => selectedChannels.includes(ch.index))
|
||||||
.map((channel) => channel.settings)
|
.map((channel) => channel.settings)
|
||||||
.filter((ch): ch is Protobuf.ChannelSettings => !!ch);
|
.filter((ch): ch is Protobuf.ChannelSettings => !!ch);
|
||||||
const encoded = new Protobuf.ChannelSet(
|
const encoded = new Protobuf.ChannelSet(
|
||||||
@@ -64,9 +63,9 @@ export const QRDialog = ({
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="grid gap-4 py-4">
|
<div className="grid gap-4 py-4">
|
||||||
<div className="flex gap-3 px-4 py-5 sm:p-6">
|
<div className="flex gap-3 px-4 py-5 sm:p-6">
|
||||||
<div className="flex w-40 flex-col gap-1">
|
<div className="flex w-40 flex-col gap-2">
|
||||||
{filteredChannels.map((channel) => (
|
{allChannels.map((channel) => (
|
||||||
<div key={channel.index}>
|
<div className="flex justify-between" key={channel.index}>
|
||||||
<Label>
|
<Label>
|
||||||
{channel.settings?.name.length
|
{channel.settings?.name.length
|
||||||
? channel.settings.name
|
? channel.settings.name
|
||||||
@@ -77,7 +76,7 @@ export const QRDialog = ({
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
key={channel.index}
|
key={channel.index}
|
||||||
checked={selectedChannels.includes(channel.index)}
|
checked={selectedChannels.includes(channel.index)}
|
||||||
onChange={() => {
|
onCheckedChange={() => {
|
||||||
if (selectedChannels.includes(channel.index)) {
|
if (selectedChannels.includes(channel.index)) {
|
||||||
setSelectedChannels(
|
setSelectedChannels(
|
||||||
selectedChannels.filter((c) => c !== channel.index)
|
selectedChannels.filter((c) => c !== channel.index)
|
||||||
|
|||||||
Reference in New Issue
Block a user