Issues with conditional statement in custom PO form

The code should look something like below (not tested):

frappe.ui.form.on("Production Order", {
	setup: function(frm) {
		var item_group = "";
		if (frm.doc.item_type=="Type 1") {
			item_group = "Group 1";
		} else if (frm.doc.item_type=="Type 2") {
			item_group = "Group 2";
		}
		frm.set_query("production_item", function () {
			return {
				query: "erpnext.controllers.queries.item_query",
					filters: {
						'is_stock_item': 1,
						'item_group': item_group
					}
				}
		});
	}
})