# Ruby Calculator - Interactive calculator built with Ruby on Rails
# Author: RSK World (Molla Samser, Founder | Rima Khatun, Designer & Tester)
# Contact: help@rskworld.in | +91 93305 39277
# Website: https://rskworld.in
# Year: 2026
# Description: Build a fully functional calculator using Ruby on Rails with modern UI

Rails.application.routes.draw do
  # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
  
  # Defines the root path route ("/")
  root "calculator#index"
  
  # Calculator routes
  get "calculator", to: "calculator#index"
  post "calculator/calculate", to: "calculator#calculate"
  post "calculator/memory", to: "calculator#memory"
  get "calculator/history", to: "calculator#history"
  
  # Advanced Calculator routes
  get "advanced", to: "advanced_calculator#index"
  post "advanced/plot_function", to: "advanced_calculator#plot_function"
  post "advanced/calculate_derivative", to: "advanced_calculator#calculate_derivative"
  post "advanced/calculate_integral", to: "advanced_calculator#calculate_integral"
  post "advanced/solve_equation", to: "advanced_calculator#solve_equation"
  post "advanced/convert_base", to: "advanced_calculator#convert_base"
  post "advanced/bitwise_operation", to: "advanced_calculator#bitwise_operation"
  post "advanced/get_all_formats", to: "advanced_calculator#get_all_formats"
  post "advanced/calculate_loan", to: "advanced_calculator#calculate_loan"
  post "advanced/generate_amortization", to: "advanced_calculator#generate_amortization"
  post "advanced/calculate_compound_interest", to: "advanced_calculator#calculate_compound_interest"
  post "advanced/calculate_tip", to: "advanced_calculator#calculate_tip"
  post "advanced/calculate_bmi", to: "advanced_calculator#calculate_bmi"
  post "advanced/calculate_bmr", to: "advanced_calculator#calculate_bmr"
  post "advanced/calculate_body_fat", to: "advanced_calculator#calculate_body_fat"
  post "advanced/calculate_water_intake", to: "advanced_calculator#calculate_water_intake"
  post "advanced/calculate_statistics", to: "advanced_calculator#calculate_statistics"
  post "advanced/matrix_operations", to: "advanced_calculator#matrix_operations"
  
  # Converter routes
  get "converter", to: "converter#index"
  post "converter/convert_currency", to: "converter#convert_currency"
  post "converter/convert_unit", to: "converter#convert_unit"
  get "converter/get_units", to: "converter#get_units"
  
  # Theme routes
  post "theme/update", to: "theme#update"
  get "theme/current", to: "theme#current"
  
  # Favorites routes
  get "favorites", to: "favorites#index"
  post "favorites", to: "favorites#create"
  get "favorites/:id", to: "favorites#show", as: "favorite"
  patch "favorites/:id", to: "favorites#update"
  delete "favorites/:id", to: "favorites#destroy"
  post "favorites/:id/use", to: "favorites#use_favorite", as: "use_favorite"
  
  # API routes for AJAX calls
  namespace :api do
    namespace :v1 do
      post "calculate", to: "calculator#calculate"
      post "memory", to: "calculator#memory"
      get "history", to: "calculator#history"
      post "convert_currency", to: "converter#convert_currency"
      post "convert_unit", to: "converter#convert_unit"
      get "units/:category", to: "converter#get_units"
      get "theme", to: "theme#current"
      post "theme", to: "theme#update"
      get "favorites", to: "favorites#index"
      post "favorites", to: "favorites#create"
      delete "favorites/:id", to: "favorites#destroy"
      
      # Advanced calculator API endpoints
      post "plot_function", to: "advanced_calculator#plot_function"
      post "solve_equation", to: "advanced_calculator#solve_equation"
      post "convert_base", to: "advanced_calculator#convert_base"
      post "bitwise_operation", to: "advanced_calculator#bitwise_operation"
      post "calculate_loan", to: "advanced_calculator#calculate_loan"
      post "calculate_bmi", to: "advanced_calculator#calculate_bmi"
      post "calculate_statistics", to: "advanced_calculator#calculate_statistics"
      post "matrix_operations", to: "advanced_calculator#matrix_operations"
    end
  end
end
