-- Seed data for the database

-- Truncate all tables
TRUNCATE TABLE "public"."users" CASCADE;
TRUNCATE TABLE "public"."actions" CASCADE;
TRUNCATE TABLE "public"."roles" CASCADE;
TRUNCATE TABLE "public"."role_actions" CASCADE;
TRUNCATE TABLE "public"."role_rules" CASCADE;
TRUNCATE TABLE "public"."role_user_link" CASCADE;
TRUNCATE TABLE "public"."user_handbook" CASCADE;
TRUNCATE TABLE "public"."user_handbook_filling" CASCADE;
TRUNCATE TABLE "public"."user_handbook_group" CASCADE;
TRUNCATE TABLE "public"."user_handbook_link" CASCADE;
TRUNCATE TABLE "public"."user_handbook_value" CASCADE;
TRUNCATE TABLE "public"."user_notes" CASCADE;
TRUNCATE TABLE "public"."communication_chanel_users" CASCADE;
TRUNCATE TABLE "public"."communication_templates" CASCADE;
TRUNCATE TABLE "public"."communications" CASCADE;
TRUNCATE TABLE "public"."file_manager" CASCADE;
TRUNCATE TABLE "public"."file_manager_access" CASCADE;
TRUNCATE TABLE "public"."file_manager_folder_links" CASCADE;
TRUNCATE TABLE "public"."file_manager_folders" CASCADE;
TRUNCATE TABLE "public"."file_manager_provider" CASCADE;
TRUNCATE TABLE "public"."file_manager_public_link" CASCADE;
TRUNCATE TABLE "public"."file_manager_user_provider" CASCADE;
TRUNCATE TABLE "public"."group_user_link" CASCADE;
TRUNCATE TABLE "public"."groups" CASCADE;
TRUNCATE TABLE "public"."role_action_link" CASCADE;
TRUNCATE TABLE "public"."user_settings" CASCADE;

-- Insert default file manager providers
INSERT INTO "public"."file_manager_provider" (id, name, config) VALUES ('1', 'Local', '{"provider":"local","dir":"/var/www/html/uploads"}' );

------------------------------------------------
-- Roles
------------------------------------------------
-- Insert default roles
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('1', 'Shopper', true,'[{"name":"User","view":true,"path":"/crm/users","routes":[{"name":"User List","view":true,"path":"/crm/users"},{"name":"Clients","view":true,"path":"/crm/users/clients"},{"name":"Shoppers","view":true,"path":"/crm/users/shoppers"},{"name":"Group","view":true,"path":"/crm/users/groups"},{"name":"Role","view":true,"path":"/crm/users/role"},{"name":"Settings","view":true,"path":"/crm/users/settings/edit"}]},{"name":"Handbook","view":true,"path":"/crm/handbook","routes":[{"name":"Group","view":true,"path":"/crm/handbook/group"},{"name":"Handbook","view":true,"path":"/crm/handbook"}]},{"name":"Notifications","view":true,"path":"/notifications","routes":[{"name":"Providers","view":true,"path":"/crm/notifications/providers"},{"name":"Templates","view":true,"path":"/crm/notifications/templates"},{"name":"Action","view":true,"path":"/crm/notifications/actions"}]},{"name":"Locations","view":true,"path":"/crm/locations","routes":[{"name":"Locations Group","view":true,"path":"/crm/locations/groups?page=1&parent_id=0"},{"name":"Locations","view":true,"path":"/crm/locations"}]}]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('2', 'Client', false,'[{"name":"User","view":true,"path":"/crm/users","routes":[{"name":"User List","view":true,"path":"/crm/users"},{"name":"Clients","view":true,"path":"/crm/users/clients"},{"name":"Shoppers","view":true,"path":"/crm/users/shoppers"},{"name":"Group","view":true,"path":"/crm/users/groups"},{"name":"Role","view":true,"path":"/crm/users/role"},{"name":"Settings","view":true,"path":"/crm/users/settings/edit"}]},{"name":"Handbook","view":true,"path":"/crm/handbook","routes":[{"name":"Group","view":true,"path":"/crm/handbook/group"},{"name":"Handbook","view":true,"path":"/crm/handbook"}]},{"name":"Notifications","view":true,"path":"/notifications","routes":[{"name":"Providers","view":true,"path":"/crm/notifications/providers"},{"name":"Templates","view":true,"path":"/crm/notifications/templates"},{"name":"Action","view":true,"path":"/crm/notifications/actions"}]},{"name":"Locations","view":true,"path":"/crm/locations","routes":[{"name":"Locations Group","view":true,"path":"/crm/locations/groups?page=1&parent_id=0"},{"name":"Locations","view":true,"path":"/crm/locations"}]}]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('3', 'Manager', false,'[{"name":"User","view":true,"path":"/crm/users","routes":[{"name":"User List","view":true,"path":"/crm/users"},{"name":"Clients","view":true,"path":"/crm/users/clients"},{"name":"Shoppers","view":true,"path":"/crm/users/shoppers"},{"name":"Group","view":true,"path":"/crm/users/groups"},{"name":"Role","view":true,"path":"/crm/users/role"},{"name":"Settings","view":true,"path":"/crm/users/settings/edit"}]},{"name":"Handbook","view":true,"path":"/crm/handbook","routes":[{"name":"Group","view":true,"path":"/crm/handbook/group"},{"name":"Handbook","view":true,"path":"/crm/handbook"}]},{"name":"Notifications","view":true,"path":"/notifications","routes":[{"name":"Providers","view":true,"path":"/crm/notifications/providers"},{"name":"Templates","view":true,"path":"/crm/notifications/templates"},{"name":"Action","view":true,"path":"/crm/notifications/actions"}]},{"name":"Locations","view":true,"path":"/crm/locations","routes":[{"name":"Locations Group","view":true,"path":"/crm/locations/groups?page=1&parent_id=0"},{"name":"Locations","view":true,"path":"/crm/locations"}]}]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('4', 'Worker', false,'[]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('5', 'Competitor', false,'[]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('6', 'MSP', false,'[]');
INSERT INTO "public"."roles" (id, name, default_role,access_pages) VALUES ('7', 'Admin', false,'[{"name":"User","view":true,"path":"/crm/users","routes":[{"name":"User List","view":true,"path":"/crm/users"},{"name":"Clients","view":true,"path":"/crm/users/clients"},{"name":"Shoppers","view":true,"path":"/crm/users/shoppers"},{"name":"Group","view":true,"path":"/crm/users/groups"},{"name":"Role","view":true,"path":"/crm/users/role"},{"name":"Settings","view":true,"path":"/crm/users/settings/edit"}]},{"name":"Handbook","view":true,"path":"/crm/handbook","routes":[{"name":"Group","view":true,"path":"/crm/handbook/group"},{"name":"Handbook","view":true,"path":"/crm/handbook"}]},{"name":"Notifications","view":true,"path":"/notifications","routes":[{"name":"Providers","view":true,"path":"/crm/notifications/providers"},{"name":"Templates","view":true,"path":"/crm/notifications/templates"},{"name":"Action","view":true,"path":"/crm/notifications/actions"}]},{"name":"Locations","view":true,"path":"/crm/locations","routes":[{"name":"Locations Group","view":true,"path":"/crm/locations/groups?page=1&parent_id=0"},{"name":"Locations","view":true,"path":"/crm/locations"}]}]');


------------------------------------------------
-- Handbooks
------------------------------------------------
-- Insert default system settings
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('1', 'language', 'en', '[]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('2', 'currencies', 'eur', '[]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('3', 'clients_roles', '', '[2]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('4', 'shoppers_roles', '', '[1]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('5', 'default_role', '1', '[]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('6', 'time_zone', 'europe/kiev', '[]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('7', 'manager_roles', '', '[3]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('8', 'worker_roles', '', '[4]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('9', 'competitor_roles', '', '[5]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('10', 'msp_roles', '', '[6]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('11', 'currency', 'usd', '[]');
INSERT INTO "public"."user_settings" (id, code, value, value_json) VALUES ('12', 'customizations', '', '{"logo": "/logo-small.png","app_logo": "/logo.png","text_color": "#333333","button_color": "#FF5733","background_color": "#FFFFFF","button_hover_color": "#C70039"}');
------------------------------------------------
-- Groups
------------------------------------------------
INSERT INTO "public"."groups" (id,role_id,name,color,access,permission,params,created_at,updated_at,access_page_manager) VALUES ('1','6','sub msp','#ffff','[]','sub_msp','[]','2024-01-01 00:00:00','2024-01-01 00:00:00',null);
INSERT INTO "public"."groups" (id, role_id, name, color, access, permission, params, created_at, updated_at, access_page_manager) VALUES ('2', '6', 'Validator', '#ffff', '[]', 'validator', '[]', '2025-01-01 00:00:00', '2025-01-01 00:00:00', '[{"icon": {"src": "/_next/static/media/assistant_on_hub.9a71e975.svg","width": 24,"height": 24,"blurWidth": 0,"blurHeight": 0}, "path": "/manager", "view": true, "title": "dashboard"},{"icon": {"src": "/_next/static/media/search_hands_free.09b2c6db.svg","width": 20,"height": 20,"blurWidth": 0,"blurHeight": 0}, "path": "/manager/scheduling", "view": true, "title": "scheduling", "options": [    {"path": "/manager/scheduling", "view": true, "title": "shops"},    {"path": "/manager/scheduling/applicants", "view": true, "title": "applicants"},    {"path": "/manager/scheduling/route-applicants", "view": true, "title": "routeApplicants"}  ]}]');
INSERT INTO "public"."groups" (id, role_id, name, color, access, permission, params, created_at, updated_at, access_page_manager) VALUES ('3', '6', 'Scheduler', '#ffff', '[]', 'scheduler', '[]', '2025-01-01 00:00:00', '2025-01-01 00:00:00', '[  {"icon":{"src":"/_next/static/media/assistant_on_hub.9a71e975.svg","width":24,"height":24,"blurWidth":0,"blurHeight":0},"path":"/manager","view":true,"title":"dashboard"},  {"icon":{"src":"/_next/static/media/search_hands_free.09b2c6db.svg","width":20,"height":20,"blurWidth":0,"blurHeight":0},"path":"/manager/scheduling","view":true,"title":"scheduling","options":[    {"path":"/manager/scheduling","view":false,"title":"shops"},    {"path":"/manager/scheduling/applicants","view":false,"title":"applicants"},    {"path":"/manager/scheduling/route-applicants","view":false,"title":"routeApplicants"}  ]},  {"icon":{"src":"/_next/static/media/user_3.c7d03726.svg","width":20,"height":16,"blurWidth":0,"blurHeight":0},"path":"/manager/quality-control","view":true,"title":"qualityControl","options":[    {"path":"/manager/quality-control/project-surveys","view":true,"title":"project-surveys"},    {"path":"/manager/quality-control/appeals","view":true,"title":"appeals"},    {"path":"/manager/quality-control/ai-trust-score","view":true,"title":"ai-trust-score"},    {"path":"/manager/quality-control/survey-queue","view":true,"title":"survey-queue"}  ]},  {"icon":{"src":"/_next/static/media/search_hands_free.09b2c6db.svg","width":20,"height":20,"blurWidth":0,"blurHeight":0},"path":"manager/survey-management/project-surveys","view":true,"title":"surveysManagement","options":[    {"path":"/manager/survey-management/project-surveys","view":true,"title":"projectSurveys"}  ]},  {"icon":{"src":"/_next/static/media/vue_sax.8645ea47.svg","width":19,"height":19,"blurWidth":0,"blurHeight":0},"path":"/manager/shopper-database","view":true,"title":"shopperDatabase","options":[    {"path":"/manager/shopper-database/shoppers","view":false,"title":"shoppers"},    {"path":"/manager/shopper-database/shopper-routes","view":false,"title":"shopperRoutes"}  ]}]');


INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('1', 'Additional data', 1,true);
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('1', 'If you have a car?','radio', 1, true, 1,'have_car');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('1', 1,'Yes, the car is on gas', 'if_car_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('2', 1,'Yes, petrol car', 'if_car_2', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('3', 1,'Yes, electric', 'if_car_3', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('4', 1,'No', 'if_car_4', 2);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('2', 'Where are you willing to visit?','radio', 1, true, 1,'willing_visit');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('5',2,'in your area', 'willing_visit_1', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('6', 2,'city', 'willing_visit_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('7', 2,'region', 'willing_visit_3', 2);
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('3', 'Zip code','input', 1, true, 1,'zip_code');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('4', 'Language','select',1, true, 2,'language');

INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('2', 'Client', 1,true);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('5', 'Industry','select',2, true, 3,'industry');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('6', 'Office address','input', 2, true,4,'office_address');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('7', 'Contract end date','input', 2, true, 5,'contract_end_date');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('8', 'Contract person name','input',2, true, 6,'contract_person_name');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('9', 'Competitor client','input', 2, true, 7,'competitor_client');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('10', 'Subdivisions client','multiselect', 2, true, 8,'subdivisions_client');

INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('3', 'Profile(Shopper general)', 1,true);
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('11', 'Date of birth','date', 3, true, 1,'date_of_birth');

INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('4', 'Profile(Shopper additional)', 1,true);
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('12', 'Reliable transportation','select',4, true, 2,'reliable_transportation');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('8', 12,'Yes', 'reliable_transportation_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('9', 12,'No', 'reliable_transportation_2', 2);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('13', 'Highest completed educational(optional)','select',4, true, 3,'completed_educational');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('10', 13,'High school', 'completed_educational_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('11', 13,'College', 'completed_educational_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('12', 13,'University', 'completed_educational_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('13', 13,'Master', 'completed_educational_4', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('14', 13,'PhD', 'completed_educational_5', 5);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('14', 'Current job(optional)','input', 4, true, 4,'current_job');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('15', 'Income level','input', 4, true, 5,'income_level');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('16', 'Employment type','select', 4, true, 6,'employment_type');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('15', 16,'Full-time', 'employment_type_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('16', 16,'Part-time', 'employment_type_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('17', 16,'Freelance', 'employment_type_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('18', 16,'Contract', 'employment_type_4', 4);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('17', 'Partner employment type','input', 4, true, 7,'partner_employment_type');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('18', 'Number of children(optional)','select', 4, true, 8,'number_of_children');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('19', 18,'0', 'number_of_children_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('20', 18,'1', 'number_of_children_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('21', 18,'2', 'number_of_children_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('22', 18,'3', 'number_of_children_4', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('23', 18,'4', 'number_of_children_5', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('24', 18,'5', 'number_of_children_6', 6);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('25', 18,'6', 'number_of_children_7', 7);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('26', 18,'7', 'number_of_children_8', 8);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('27', 18,'8', 'number_of_children_9', 9);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('28', 18,'9', 'number_of_children_10', 10);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('19', 'Where did you hear from us?','select', 4, true, 9,'here_from_us');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('29', 19,'Google', 'here_from_us_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('30', 19,'Facebook', 'here_from_us_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('31', 19,'Instagram', 'here_from_us_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('32', 19,'Friends', 'here_from_us_4', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('33', 19,'Other', 'here_from_us_5', 5);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('20', 'Postal code','input', 4, true, 10,'postal_code');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('21', 'PayPal address','input', 4, true, 11,'paypal_address');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('22', 'Do you like to travel?','select', 4, true, 12,'like_travel');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('34', 22,'Yes', 'like_travel_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('35', 22,'No', 'like_travel_2', 2);

INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('23', 'Pets(optional)','input', 4, true, 13,'pets');
INSERT INTO "public"."user_handbook" (id, name, type,handbook_group_id,status,sort,code) VALUES ('24', 'Do you have a valid driver’s licence?','select', 4, true, 14,'driver_licence');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('36', 24,'Yes', 'driver_licence_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('37', 243,'No', 'driver_licence_2', 2);

INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('5', 'Competitor', 1,true);
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('38', 'Colour', 'input', 5, true, 2,'colour_competitor');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('39', 'Competitor location', 'input', 5, true, 1, 'location_competitor');

INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('38', 4,'English', 'en', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('39', 4,'German', 'de', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('40', 4,'French', 'fr', 3);

---Subdivisions
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('41', 10,'Wood', 'wood', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('42', 10,'Sanitary', 'sanitary', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('43', 10,'Tiles', 'tiles', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('44', 10,'Life insurance', 'life_insurance', 4);

---Industry
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('45', 5,'Automotive', 'automotive', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('46', 5,'Business-to-Business', 'business_to_business', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('47', 5,'Car wash', 'car_wash', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('48', 5,'Convenience Stores', 'convenience_stores', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('49', 5,'Construction', 'construction', 5);

---Subdivisions
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('50',10,'Vehicle insurance', 'vehicle_insurance', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('51',10,'Property insurance', 'property_insurance', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('52',10,'Garden', 'garden', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('53',10,'Building material', 'building_material', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('54',10,'Electric', 'electric', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('55',10,'Customer service', 'customer_service', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('56',10,'TV-Hifi', 'tv_hifi', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('57',10,'Photo/Telecommunication', 'photo_telecommunication', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('58',10,'Computer Software', 'computer_software', 5);

---Industry
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('59', 5,'Enertainment', 'enertainment', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('60', 5,'Financial', 'financial', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('61', 5,'Financial consultancy', 'financial_consultancy', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('62', 5,'FMCG', 'fmcg', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('63', 5,'Food service', 'food_service', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('64', 5,'Gas Stations', 'gas_stations', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('65', 5,'Government', 'government', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('66', 5,'Grocery', 'grocery', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('67', 5,'Health Care', 'health_care', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('68', 5,'Lodging, accommodation', 'lodging_accommodation', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('69', 5,'Lottery store', 'lottery_store', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('70', 5,'Pharmacies', 'pharmacies', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('71', 5,'Real estate', 'real_estate', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('72', 5,'Retail', 'retail', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('73', 5,'Shipping, transportation', 'shipping_transportation', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('74', 5,'Storage', 'storage', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('75', 5,'Telecommunication', 'telecommunication', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('76', 5,'Training', 'training', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('77', 5,'Wholesale', 'wholesale', 5);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('78', 5,'Other', 'other', 5);

---Driving Experience
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('25', 'Driving Experience', 'select',3, true, 1,'driving_experience');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('79', 25,'0-1 year', 'driving_experience_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('80', 25,'1-3 years', 'driving_experience_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('81', 25,'3-5 years', 'driving_experience_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('82', 25,'5-10 years', 'driving_experience_4', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('83', 25,'10+ years', 'driving_experience_5', 5);

---Bank
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('26', 'Bank', 'select',3, true, 2,'bank');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('84', 26,'PrivatBank', 'bank_1', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('85', 26,'Monobank', 'bank_2', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('86', 26,'Oschadbank', 'bank_3', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('87', 26,'Raiffeisen Bank Aval', 'bank_4', 4);

---Currency
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('27', 'Currency', 'select',3, true, 3,'currencies');
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('88', 27,'USD', 'usd', 1);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('89', 27,'EUR', 'eur', 2);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('90', 27,'UAH', 'uah', 3);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('91', 27,'HUF', 'huf', 4);
INSERT INTO "public"."user_handbook_value" (id,handbook_id,label,value,sort) VALUES ('92', 27,'RUB', 'rub', 5);

---MSP Handbook
INSERT INTO "public"."user_handbook_group" (id, name, sort,status) VALUES ('6', 'Customizations', 1,true);
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('28', 'MSP Logo', 'input',6, true, 1,'logo');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('29', 'MSP App Logo', 'input',6, true, 2,'app_logo');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('30', 'MSP Main Color', 'input',6, true, 3,'main_color');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('31', 'MSP Text Color', 'input',6, true, 4,'text_color');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('32', 'MSP Sub Menu Color', 'input',6, true, 5,'sub_menu_color');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('33', 'MSP Sub Menu Text Color', 'input',6, true, 6,'sub_menu_text_color');

---MSP Handbook
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('34', 'Address', 'input',1, true,9,'address');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('35', 'Sub MSP Name', 'input',1, true,10,'sub_msp_name');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('36', 'Manager Link', 'input',1, true,11,'manager_link');
INSERT INTO "public"."user_handbook" (id, name, type, handbook_group_id, status, sort, code) VALUES ('37', 'Shopper Link', 'input',1, true,12,'shopper_link');


------------------------------------------------
-- Insert default role actions
------------------------------------------------
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('4', 0,1,3, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('5', 0,1,3, 0);

-- Insert client handbook links
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('1', 0,2,2, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('3', 0,1,2, 0);

-- Insert shopper handbook links
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('6', 0,3,1, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('7', 0,4,1, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('2', 0,1,1, 0);

-- Insert competitor handbook links
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('8', 0,5,5, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('9', 5,0,5, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('10', 10,0,5, 0);

-- Insert msp handbook links
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('11', 0,1,6, 0);
INSERT INTO "public"."user_handbook_link" (id, handbook_id,handbook_group_id,role_id,group_id) VALUES ('12', 0,6,6, 0);



------------------------------------------------
-- Actions
------------------------------------------------
-- Insert default actions
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('1', 'forgotPassword', 'Forgot password', 'Send  with link to reset password');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('2', 'resetPasswordSuccess', 'Reset password', 'Reset password success');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('3', 'registration', 'Registration', 'Registration success');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('4', 'changePassword', 'Change password', 'Change password success');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('5', 'confirmEmail', 'Confirm email', 'Confirm email success');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('6', 'sendPasswordClient', 'Send password to Client', 'You have successfully registered. Your password is: {password}');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('7', 'sendPasswordWorker', 'Send password to Worker', 'You have successfully registered. Your password is: {password}');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('8', 'sendPasswordMSP', 'Send password to MSP', 'You have successfully registered. Your password is: {password}');
INSERT INTO "public"."actions" (id, code, name,comment) VALUES ('9', 'sendPasswordSubMSP', 'Send password to SubMSP', 'You have successfully registered. Your password is: {password}');
------------------------------------------------
-- Communications
------------------------------------------------
-- Insert default communications
INSERT INTO public.communications (
id,name, type, api_url, auth_token, access_secret, webhook_url, callback_url, chanel_name, encryption_key, provider, params, status) VALUES (
1,'Twilio Communication Service', 'sms', '', '7ed9ea87eaa406e951fdddc742d2b700', 'a3166d98ebee8887941f00d76243dafc-b02bcf9f-c91e0795', 'https://webhook.twilio.com', 'https://callback.yourservice.com/twilio', 'twilio_channel', 'your_encryption_key_for_twilio', 'TwilioProvider', '{"accountSid":"AC81bdfc6785c6b837315264bb3c057a0c","authToken":"7ed9ea87eaa406e951fdddc742d2b700"}', true);

INSERT INTO public.communications (
id,name, type, api_url, auth_token, access_secret, webhook_url, callback_url, chanel_name, encryption_key, provider, params, status) VALUES (
2,'Mailgun', 'mail', '', 'f15cbf7f6bcc4ccf631bfc897967aaf6-309b0ef4-f13c2ff6', 'f15cbf7f6bcc4ccf631bfc897967aaf6-309b0ef4-f13c2ff6', 'https://webhook.mailgun.com', 'https://callback.yourservice.com/mailgun', 'mailgun_channel', 'your_encryption_key_for_mailgun', 'MailGunProvider', '{"domain":"happeas.space","smt_host":"smtp.mailgun.org","smtp_port":"25","smtp_username":"info@happeas.space","smtp_password":"E5N@UnYZizBDb5f"}', true);
--auth_token  a3166d98ebee8887941f00d76243dafc-b02bcf9f-c91e0795

INSERT INTO public.communications (
id,name, type, api_url, auth_token, access_secret, webhook_url, callback_url, chanel_name, encryption_key, provider, params, status) VALUES (
3,'Local Communication Service', 'local', '', '', '', '', '', '', '', 'LocalProvider', '{}', true);


INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'Forgot password',
  'Forgot password',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"code","label":"Code","type":"code","required":true}]',
  'Hello, <br> You have requested to reset your password. Please code <b>{code}</b> to reset your password.',
  2,
  1
);




INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'Reset password',
  'Reset password',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"code","label":"Code","type":"code","required":true}]',
  'Hello, <br> You have successfully reset your password. Please login with your new password. If you have any questions, please contact us.',
  2,
  2
);





INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'Registration',
  'Registration',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"code","label":"Code","type":"code","required":true}]',
  'Hello {name}, <br> You code <b>{code}</b> to confirm your email. If you have any questions, please contact us.',
  2,
  5
);




INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'Client send password',
  'Your password for login',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"password","label":"Password","type":"string","required":true}]',
  'Hello, <br> You have successfully register. Your password is <b>{password}</b>. If you have any questions, please contact us.',
  2,
  6
);





INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'Worker send password',
  'Your password for login',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"password","label":"Password","type":"string","required":true}]',
  'Hello, <br> You have successfully register. Your password is <b>{password}</b>. If you have any questions, please contact us.',
  2,
  7
);





INSERT INTO public.communication_templates (
  name,
  subject,
  variables,
  content,
  communication_id,
  action_id
) VALUES (
  'MSP send password',
  'Your password for login',
  '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"password","label":"Password","type":"string","required":true}]',
  'Hello, <br> You have successfully register. Your password is <b>{password}</b>. If you have any questions, please contact us.',
  2,
  8
);




INSERT INTO public.communication_templates (
    name,
    subject,
    variables,
    content,
    communication_id,
    action_id
) VALUES (
    'SubMSP send password',
    'Your password for login',
    '[{"code":"name","label":"Имя","type":"string","required":false},{"code":"password","label":"Password","type":"string","required":true}]',
    'Hello, <br> You have successfully register. Your password is <b>{password}</b>. If you have any questions, please contact us.',
    2,
    9
);



SELECT setval('user_handbook_value_id_seq', (SELECT MAX(id) FROM public.user_handbook_value) + 1);
SELECT setval('user_handbook_id_seq', (SELECT MAX(id) FROM public.user_handbook) + 1);
SELECT setval('user_handbook_group_id_seq', (SELECT MAX(id) FROM public.user_handbook_group) + 1);
SELECT setval('user_settings_id_seq', (SELECT MAX(id) FROM public.user_settings) + 1);
SELECT setval('role_user_link_id_seq', (SELECT MAX(id) FROM public.role_user_link) + 1);
SELECT setval('role_rules_id_seq', (SELECT MAX(id) FROM public.role_rules) + 1);
SELECT setval('role_action_link_id_seq', (SELECT MAX(id) FROM public.role_action_link) + 1);
SELECT setval('role_actions_id_seq', (SELECT MAX(id) FROM public.role_actions) + 1);
SELECT setval('roles_id_seq', (SELECT MAX(id) FROM public.roles) + 1);
SELECT setval('users_id_seq', (SELECT MAX(id) FROM public.users) + 1);
SELECT setval('actions_id_seq', (SELECT MAX(id) FROM public.actions) + 1);
SELECT setval('communication_chanel_users_id_seq', (SELECT MAX(id) FROM public.communication_chanel_users) + 1);
SELECT setval('communication_templates_id_seq', (SELECT MAX(id) FROM public.communication_templates) + 1);
SELECT setval('communications_id_seq', (SELECT MAX(id) FROM public.communications) + 1);
SELECT setval('user_handbook_link_id_seq', (SELECT MAX(id) FROM public.user_handbook_link) + 1);
SELECT setval('groups_id_seq', (SELECT MAX(id) FROM public.groups) + 1);

