I don't know if I misunderstood your post but you can repair if you could get to the foundation before it's destroyed and you fight off the shark. Just hold right click on the hammer and choose repair.
yes, that's what I meant. if the foundation's health is, for example, 15, you'll need severall wood planks to return it back to 100, when building a new one only costs 2 wood planks and a rope