Euclid: Constraints on f(R) cosmologies from the spectroscopic and photometric primary probes