Quinton de Kock hit a four to reach his 50 as South Africa closed in on their first win of the ICC World Cup against Afghanistan.