import { z } from '@frontmcp/lazy-zod';
import { Tool, ToolContext } from '@frontmcp/sdk';

import { crmStore } from '../data/crm.store';

const inputSchema = {
  id: z.string().describe('User ID to delete'),
};

const outputSchema = z.object({
  success: z.boolean(),
  message: z.string(),
});

@Tool({
  name: 'users-delete',
  description: 'Delete a user from the CRM',
  inputSchema,
  outputSchema,
})
export default class UsersDeleteTool extends ToolContext {
  async execute(input: z.infer<z.ZodObject<typeof inputSchema>>): Promise<z.infer<typeof outputSchema>> {
    const deleted = crmStore.deleteUser(input.id);
    return {
      success: deleted,
      message: deleted ? `User ${input.id} deleted` : `User ${input.id} not found`,
    };
  }
}
