Let $L_2[-\pi,\pi]$ be the complex Hilbert space that has $C[-\pi,\pi]$ as a linear subspace with inner product $(a,b)=\int_{-\pi}^\pi a(x)\overline{b(x)}dx$ for $a,b\in C[-\pi,\pi]$.
Further $\{e_n\}_{n=-\infty}^\infty$ where $e_n(x)=\frac{1}{\sqrt{2\pi}}e^{inx}$ (for $n\in\mathbb{Z}$) is an orthonormal basis for $L_2[-\pi,\pi]$.
For $u(x)=x$ where $u\in L_2[-\pi,\pi]$, we find
$$(u,e_n)=\int_{-\pi}^\pi u(x)\overline{e_n(x)}dx=\frac{1}{\sqrt{2\pi}}\int_{-\pi}^\pi xe^{-inx}dx=\frac{2 i (π n\cos(π n)-\sin(π n))}{\sqrt{2\pi}n^2}.$$
How do I use all the above to show that $$\sum_{n=1}^\infty \frac{1}{n^2}=\frac{\pi^2}{6}?$$
Edit: So by @G.Sassatelli's hint I find $$(u,e_n)=\frac{(-1)^n\sqrt{2\pi}i}{n}$$ and $$|(u,e_n)|^2=\frac{2\pi}{n^2}.$$ Then $||u||^2=\int_{-\pi}^\pi x^2dx=\frac{2\pi^3}{3}$. Then by Parseval we find $$\sum_{n=1}^\infty \frac{2\pi}{n^2}=\frac{2\pi^3}{3}$$ which gives us our final result.
You should also take into account the case $n=0$, because $(u,e_n)$ is not defined for $n=0$. Also the integral is two times your result and this works because Parseval identity is: $\sum_{n=-\infty}^{\infty}|(u,e_n)|^2 =2\pi \sum_{n=-\infty}^{-1} \frac{1}{n^2}+|(u,e_0)|^2+2\pi\sum_{n=1}^{\infty} \frac{1}{n^2} = 4\pi \sum_{n=1}^{\infty} \frac{1}{n^2}$