The ruling is a blow to Trump and the Republicans in a nationwide redistricting race that began in Texas this summer.