Every $A$-module is projective if and only if $A$ is a finite direct product of fields. I want to prove the following

Every $A$-module is projective if and only if $A$ is a finite direct product of fields.

I know a relevant result: Every ideal of a ring $A$ is generated by an idempotent if and only if $A$ is a finite direct of fields.
Thus it reduces to prove that:

Every $A$-module is projective if and only if every ideal of a ring $A$ is generated by an idempotent.

Assuming LHS of above, for any ideal $I$ of A, $A/I$ is projective as $A$ module hence flat as $A$ module, implying that $I=I^{2}$. How can I complete it ?
 A: While I agree with Angina Seng that going through the Wedderburn's theorem for not necessarily commutative rings is more conceptual (and the proof is less intricate), there is a way to prove what you want just in terms of commutative algebra:
For any ideal $I \subseteq R,$ the projection $R \rightarrow R/I$ splits by projectivity. That means, in particular, that there is a principal ideal $J \subseteq R$ (isomorphic to $R/I$ as an $R$-module, it is the image of the splitting map) such that $J\oplus I=R$. In particular, $I \simeq R/J$ as an $R$-module, so all ideals of $R$ are principal.
So now let us consider any ideal $I=xR$ of $R$. Then $I^2=I$ gives $x^2R=xR,$ so there is $r \in R$  such that $x^2r=x$. Then for any element $y=xs$ of $xR$, we have $(xr)\cdot(xs)=(x^2r)s=xs,$ and so in particular, for $s=r$ we have $(xr)^2=xr$. Finally, note that $I=xR \subseteq (xr)R \subseteq (x^2r)R \subseteq xR=I$, proving equality everywhere. This shows that $I=(xr)R$ is generated by an idempotent.
