You were able to trade in a truck with $24,000+ collision damage before it had even been repaired? Wow, that sounds like a dealer desperate for some inventory!
Did they give you fair market value assuming it makes it out repairs o.k.? If so, did you take a hit on value with the major repair? What if it ends up being totalled?