<Page x:Class="ComputerShopWpf.Views.UsersPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Пользователи">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Text="Пользователи" Style="{StaticResource PageTitleStyle}"/>

        <Border Grid.Row="1"
                Background="{StaticResource PanelBrush}"
                BorderBrush="{StaticResource BorderBrush}"
                BorderThickness="1"
                Padding="16"
                Margin="0,4,0,10">
            <StackPanel>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="240"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0" Margin="0,0,14,0">
                        <TextBlock Text="Логин"/>
                        <TextBox x:Name="LoginTextBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1" Margin="0,0,14,0">
                        <TextBlock Text="Пароль"/>
                        <PasswordBox x:Name="NewPasswordBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="2">
                        <TextBlock Text="Роль"/>
                        <ComboBox x:Name="RoleComboBox">
                            <ComboBoxItem Content="admin"/>
                            <ComboBoxItem Content="manager"/>
                            <ComboBoxItem Content="viewer"/>
                        </ComboBox>
                    </StackPanel>
                </Grid>
                <StackPanel Orientation="Horizontal" Margin="0,6,0,0">
                    <Button x:Name="AddButton" Content="Добавить" Click="AddButton_Click"/>
                    <Button x:Name="UpdateRoleButton" Content="Изменить роль" Click="UpdateRoleButton_Click"/>
                    <Button x:Name="DeleteButton" Content="Удалить" Click="DeleteButton_Click"/>
                    <Button x:Name="RefreshButton" Content="Обновить" Click="RefreshButton_Click"/>
                </StackPanel>
            </StackPanel>
        </Border>

        <DataGrid x:Name="UsersDataGrid"
                  Grid.Row="2"
                  SelectionChanged="UsersDataGrid_SelectionChanged">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding [user_id]}" Width="80"/>
                <DataGridTextColumn Header="Логин" Binding="{Binding [login]}" Width="220"/>
                <DataGridTextColumn Header="Роль" Binding="{Binding [role_name]}" Width="160"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Page>
