from django.contrib import admin
from .models import Company, Profile, JobStatus, RequiredFolder, Job, JobFolderCompletion, JobFile, Invitation, Client

@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
    list_display = ('name', 'is_uprn_required', 'created_at')

@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
    list_display = ('user', 'company', 'role')
    list_filter = ('role', 'company')

@admin.register(JobStatus)
class JobStatusAdmin(admin.ModelAdmin):
    list_display = ('name', 'company', 'is_starting_status', 'order')
    list_filter = ('company',)

@admin.register(RequiredFolder)
class RequiredFolderAdmin(admin.ModelAdmin):
    list_display = ('name', 'company')
    list_filter = ('company',)

@admin.register(Client)
class ClientAdmin(admin.ModelAdmin):
    list_display = ('name', 'company', 'client_job_ref_prefix')
    list_filter = ('company',)
    search_fields = ('name',)

@admin.register(Job)
class JobAdmin(admin.ModelAdmin):
    list_display = ('job_ref', 'company', 'client', 'status', 'postcode')
    list_filter = ('company', 'client', 'status')
    search_fields = ('job_ref', 'uprn', 'address_line_1', 'postcode')

@admin.register(JobFolderCompletion)
class JobFolderCompletionAdmin(admin.ModelAdmin):
    list_display = ('job', 'folder', 'is_completed')

@admin.register(JobFile)
class JobFileAdmin(admin.ModelAdmin):
    list_display = ('job', 'folder', 'file', 'uploaded_at')

@admin.register(Invitation)
class InvitationAdmin(admin.ModelAdmin):
    list_display = ('email', 'company', 'invited_by', 'created_at', 'expires_at', 'is_accepted')
    list_filter = ('company', 'is_accepted')
    search_fields = ('email',)