Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trazer atividades do backend #32

Closed
2 tasks done
404jv opened this issue Apr 18, 2022 · 3 comments
Closed
2 tasks done

Trazer atividades do backend #32

404jv opened this issue Apr 18, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request focus It's urgent

Comments

@404jv
Copy link
Owner

404jv commented Apr 18, 2022

Precisamos refatorar o APP para conseguir que as atividades retornadas sejam renderizadas, e atualmente o app tem os componentes necessários, só que não tá adaptado para a forma em que a API retorna os dados. Essa parte é pra ser fácil, não vai da muito trabalho.

  • Refatorar a Activity
  • Fazer conexão com o back

Detalhes

  • Existem dois tipos de atividades: teórica e prática.
  • As práticas tem 5 fases para cada level.
  • As teóricas tem apenas um texto markdown.

Rotas

  • GET /game/theory-phase/:id
    Nessa rota deve ser enviado o token e o ID da fase pelos parâmetros. Por exemplo, uma request assim: http://localhost:3333/game/practice-phase/259fa2dd-3e85-4dc3-8310-ca368c657023 vai retornar um array com 5 atividades que correspondem ao level do usuário:
[
	{
		"id": "4934e034-ab92-4a66-aaf3-88ba7b4399ae",
		"title": "Activity 0",
		"description": "Activity test",
		"phase_id": "2895a53e-b43f-43fb-8ae8-ef7bf4da1f00",
		"type": "block_activity",
		"is_needed_code": false,
		"order": 0,
		"created_at": "2022-04-18T21:32:33.877Z",
		"options": [
			{
				"id": "dfb1a720-0e23-4a8d-a59c-24dd8e7b56fe",
				"name": "Option 0",
				"activity_id": "4934e034-ab92-4a66-aaf3-88ba7b4399ae",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.918Z"
			},
			{
				"id": "dd2650d7-baf3-414c-8a7f-5f81534ea855",
				"name": "Option 2",
				"activity_id": "4934e034-ab92-4a66-aaf3-88ba7b4399ae",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.941Z"
			},
			{
				"id": "759a5418-9ce4-432a-8035-30a1bcfc7f90",
				"name": "Option 1",
				"activity_id": "4934e034-ab92-4a66-aaf3-88ba7b4399ae",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.933Z"
			}
		],
		"tips": [],
		"activity_answer": [],
		"default_code": []
	},
	{
		"id": "f3103f97-dca4-4dce-a509-f13d39950f09",
		"title": "Activity 1",
		"description": "Activity test",
		"phase_id": "2895a53e-b43f-43fb-8ae8-ef7bf4da1f00",
		"type": "block_activity",
		"is_needed_code": false,
		"order": 1,
		"created_at": "2022-04-18T21:32:33.949Z",
		"options": [
			{
				"id": "49961168-03ca-443c-83e0-105f49492c12",
				"name": "Option 1",
				"activity_id": "f3103f97-dca4-4dce-a509-f13d39950f09",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.966Z"
			},
			{
				"id": "b7d3bec7-e7c0-49cf-bedc-908afd2f68d8",
				"name": "Option 0",
				"activity_id": "f3103f97-dca4-4dce-a509-f13d39950f09",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.957Z"
			},
			{
				"id": "697d4a8b-ca56-40e4-bf96-3950fb111c55",
				"name": "Option 2",
				"activity_id": "f3103f97-dca4-4dce-a509-f13d39950f09",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:33.982Z"
			}
		],
		"tips": [],
		"activity_answer": [],
		"default_code": []
	},
	{
		"id": "4c117d44-5592-47eb-b943-98b5c3d0d62f",
		"title": "Activity 2",
		"description": "Activity test",
		"phase_id": "2895a53e-b43f-43fb-8ae8-ef7bf4da1f00",
		"type": "block_activity",
		"is_needed_code": false,
		"order": 2,
		"created_at": "2022-04-18T21:32:33.995Z",
		"options": [
			{
				"id": "bfa7e5ac-9851-4263-8098-ddc617374f35",
				"name": "Option 2",
				"activity_id": "4c117d44-5592-47eb-b943-98b5c3d0d62f",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.032Z"
			},
			{
				"id": "eee6c03b-6ff5-4059-b0cb-205921fe8be5",
				"name": "Option 1",
				"activity_id": "4c117d44-5592-47eb-b943-98b5c3d0d62f",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.024Z"
			},
			{
				"id": "4bdc3151-a472-4318-8f3e-81d3d680b5eb",
				"name": "Option 0",
				"activity_id": "4c117d44-5592-47eb-b943-98b5c3d0d62f",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.013Z"
			}
		],
		"tips": [],
		"activity_answer": [],
		"default_code": []
	},
	{
		"id": "d07b4a05-f06e-4db0-a265-8325beabed73",
		"title": "Activity 3",
		"description": "Activity test",
		"phase_id": "2895a53e-b43f-43fb-8ae8-ef7bf4da1f00",
		"type": "block_activity",
		"is_needed_code": false,
		"order": 3,
		"created_at": "2022-04-18T21:32:34.042Z",
		"options": [
			{
				"id": "39e3c728-a563-4ff4-93b1-dec50330e150",
				"name": "Option 2",
				"activity_id": "d07b4a05-f06e-4db0-a265-8325beabed73",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.081Z"
			},
			{
				"id": "c828b514-5671-4aca-85c3-d865f03baa62",
				"name": "Option 0",
				"activity_id": "d07b4a05-f06e-4db0-a265-8325beabed73",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.057Z"
			},
			{
				"id": "061353ea-2689-4d6f-acaf-05c800942b16",
				"name": "Option 1",
				"activity_id": "d07b4a05-f06e-4db0-a265-8325beabed73",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.073Z"
			}
		],
		"tips": [],
		"activity_answer": [],
		"default_code": []
	},
	{
		"id": "3b2c655d-105a-4cd9-88c8-7d6c5533bfbf",
		"title": "Activity 4",
		"description": "Activity test",
		"phase_id": "2895a53e-b43f-43fb-8ae8-ef7bf4da1f00",
		"type": "block_activity",
		"is_needed_code": false,
		"order": 4,
		"created_at": "2022-04-18T21:32:34.107Z",
		"options": [
			{
				"id": "382d18fa-38cd-4dd2-9920-c516a9ca66b2",
				"name": "Option 2",
				"activity_id": "3b2c655d-105a-4cd9-88c8-7d6c5533bfbf",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.131Z"
			},
			{
				"id": "74ebd8dd-7be6-4ea3-a113-7816920c4f15",
				"name": "Option 1",
				"activity_id": "3b2c655d-105a-4cd9-88c8-7d6c5533bfbf",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.123Z"
			},
			{
				"id": "3ebd4ae9-304c-4cd9-ae06-a3e62bbe9855",
				"name": "Option 0",
				"activity_id": "3b2c655d-105a-4cd9-88c8-7d6c5533bfbf",
				"type": "js_function",
				"hexadecimal_color": "#335A6A",
				"created_at": "2022-04-18T21:32:34.114Z"
			}
		],
		"tips": [],
		"activity_answer": [],
		"default_code": []
	}
]

A gente pega esse array e para cada atividade renderiza um componente que já fizemos. Bem simples!

  • GET /game/practice-phase/:id
    Para as fases teóricas podemos fazer a mesma coisa, só vai mudar a rota. Pensei que seria melhor organizado e performático se mudássemos a rota das fases teóricas para uma sozinha, já que as práticas vai ter diversas regras de negócios apenas dela e a teórica não tem nenhuma. Como as fases teóricas não possuem atividades podemos apenas fazer a request, exemplo: http://localhost:3333/game/theory-phase/e64e8388-c289-4ff8-b70f-02775cb679d4 e vamos obter a fase com o markdown_text:
{
	"id": "e64e8388-c289-4ff8-b70f-02775cb679d4",
	"map_id": "654b369c-8459-4c7e-be93-b74531c7f8de",
	"title": "Fase teórica",
	"type": "theory",
	"markdown_text": "# Fase teste",
	"description": "Fase teórica",
	"max_level": 1,
	"order": 4,
	"created_at": "2022-04-18T21:57:33.282Z",
	"activities": [],
	"current_level": 0
}

Podemos enviar esse tipo de fase para o componente que já criamos.

@404jv 404jv added the enhancement New feature or request label Apr 18, 2022
@404jv 404jv added the focus It's urgent label Apr 19, 2022
@404jv 404jv self-assigned this Apr 19, 2022
@FixRuan
Copy link
Contributor

FixRuan commented Apr 19, 2022

this is my 🔥 .

@FixRuan FixRuan removed their assignment Apr 19, 2022
@jvolima
Copy link
Contributor

jvolima commented Apr 20, 2022

👋

@404jv
Copy link
Owner Author

404jv commented Apr 24, 2022

Fechada com a #49

@404jv 404jv closed this as completed Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request focus It's urgent
Projects
None yet
Development

No branches or pull requests

3 participants