/**
 * Copyright (c) 2023-present Pi Dash Software, Inc. and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 * See the LICENSE file for details.
 */

import React from "react";
import { Command } from "cmdk";
import { observer } from "mobx-react";
// pi dash imports
import { SUPPORTED_LANGUAGES } from "@pi-dash/i18n";
// local imports
import { PowerKModalCommandItem } from "../../modal/command-item";

type Props = {
  onSelect: (language: string) => void;
};

export const PowerKPreferencesLanguagesMenu = observer(function PowerKPreferencesLanguagesMenu(props: Props) {
  const { onSelect } = props;

  return (
    <Command.Group>
      {SUPPORTED_LANGUAGES.map((language) => (
        <PowerKModalCommandItem key={language.value} onSelect={() => onSelect(language.value)} label={language.label} />
      ))}
    </Command.Group>
  );
});
