I want to calculate the fourier transform $\hat{A}$ of the following function:
$$A(x) = \begin{cases} 1, & \text{if $\lvert x \rvert \le \frac{b}{2}$ } \\[2ex] 0, & \text{else} \end{cases}$$
The fourier transform can be calculated by using the formula:
$$\hat{A}=\int_{-\infty}^{+\infty}\frac{1}{\sqrt{2\pi}}A(x)e^{-ikx} dx$$
I don't know how to deal with the condition $1, \space \space \space \text{if $\lvert x\rvert \le \frac{b}{2}$}$. How can I integrate that?
For a piecewise function $A(x)$, you should break the integral into pieces also. The fact that the function you're considering is 0 outside of a range makes that easier.
\begin{eqnarray}\hat{A}=\int_{-\infty}^{+\infty}\frac{1}{\sqrt{2\pi}}A(x)e^{-ikx} dx=\hat{A}&=&\int_{-b/2}^{+b/2}\frac{1}{\sqrt{2\pi}}e^{-ikx} dx\\ &=& \frac{1}{ik\sqrt{2\pi}}\left(e^{ikb/2}-e^{-ikb/2}\right) \\ &=& \frac{1}{k}\sqrt{\frac{2}{\pi}}\sin\left(\frac{kb}{2}\right) \end{eqnarray}