Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 104 additions & 6 deletions src/common/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
import axios from 'axios';
import qs from 'querystring';
import {
MOJANG_APIS,
FORGESVC_URL,
MC_MANIFEST_URL,
FABRIC_APIS,
JAVA_MANIFEST_URL,
FORGESVC_URL,
FTB_API_URL,
IMGUR_CLIENT_ID,
JAVA_LATEST_MANIFEST_URL,
JAVA_MANIFEST_URL,
MC_MANIFEST_URL,
MICROSOFT_LIVE_LOGIN_URL,
MICROSOFT_XBOX_LOGIN_URL,
MICROSOFT_XSTS_AUTH_URL,
MINECRAFT_SERVICES_URL,
FTB_API_URL,
JAVA_LATEST_MANIFEST_URL
MOJANG_APIS,
TECHNIC_API_URL,
TECHNIC_CLIENT_BUILD
} from './utils/constants';
import { sortByDate } from './utils';
import ga from './utils/analytics';
Expand All @@ -26,6 +28,9 @@ const axioInstance = axios.create({
}
});

// Requests to technic api need build id
let technicClientBuild = TECHNIC_CLIENT_BUILD;

const trackFTBAPI = () => {
ga.sendCustomEvent('FTBAPICall');
};
Expand All @@ -34,6 +39,14 @@ const trackCurseForgeAPI = () => {
ga.sendCustomEvent('CurseForgeAPICall');
};

const trackTechnicAPI = () => {
ga.sendCustomEvent('TechnicAPICall');
};

const trackTechnicSolderAPI = () => {
ga.sendCustomEvent('TechnicSolderAPICall');
};

// Microsoft Auth
export const msExchangeCodeForAccessToken = (
clientId,
Expand Down Expand Up @@ -367,6 +380,91 @@ export const getSearch = async (
return data?.data;
};

export const getTechnicSearch = searchFilter => {
const url = `${TECHNIC_API_URL}/search`;
const params = {
build: technicClientBuild,
q: searchFilter
};
trackTechnicAPI(url, params);
return axios.get(url, { params });
};

export const getTechnicClientBuild = () => {
try {
const url = `${TECHNIC_API_URL}/launcher/version/stable4`;
trackTechnicAPI(url, {});
const { data } = axios.get(url);
technicClientBuild = data.build;
return data.build;
} catch {
return { status: 'error' };
}
};

export const getTechnicChangelog = async changelogUrl => {
try {
trackTechnicAPI(changelogUrl, {});
const { data } = await axios.get(changelogUrl);
return data;
} catch {
return { status: 'error' };
}
};

export const getTechnicAddDownload = async name => {
const url = `${TECHNIC_API_URL}/modpack/${name}/stat/download`;
const params = {
build: technicClientBuild
};
trackTechnicAPI(url, params);
try {
return await axios.get(url, { params });
} catch (e) {
return null;
}
};

export const getTechnicAddRun = async name => {
const url = `${TECHNIC_API_URL}/modpack/${name}/stat/run`;
const params = {
build: technicClientBuild
};
trackTechnicAPI(url, params);
try {
return await axios.get(url, { params });
} catch (e) {
return null;
}
};

export const getTechnicModpackData = name => {
const url = `${TECHNIC_API_URL}/modpack/${name}`;
const params = {
build: technicClientBuild
};
trackTechnicAPI(url, params);
return axios.get(url, { params });
};

export const getTechnicSolderMultiple = (solder, type) => {
const url = `${solder}/${type}`;
const params = {
include: 'full'
};
trackTechnicSolderAPI(url, params);
return axios.get(url, { params });
};

export const getTechnicSolderData = (solder, type, name, version = null) => {
let url = `${solder}${type}/${name}`;
if (version) {
url += `/${version}`;
}
trackTechnicSolderAPI(url, {});
return axios.get(url, {});
};

export const getFTBModpackData = async modpackId => {
trackFTBAPI();
try {
Expand Down
Binary file added src/common/assets/technicIcon.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions src/common/modals/AddInstance/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ import React, { useState } from 'react';
import styled from 'styled-components';
import { Transition } from 'react-transition-group';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faLongArrowAltRight,
faArchive
} from '@fortawesome/free-solid-svg-icons';
import { faArchive, faLongArrowAltRight } from '@fortawesome/free-solid-svg-icons';
import { LoadingOutlined } from '@ant-design/icons';
import { Spin, Radio } from 'antd';
import { Radio, Spin } from 'antd';
import CurseForgeModpacks from './CurseForgeModpacks';
import FTBModpacks from './FTBModpacks';
import Import from './Import';
import NewInstance from './NewInstance';
import minecraftIcon from '../../assets/minecraftIcon.png';
import curseForgeIcon from '../../assets/curseforgeIcon.webp';
import technicIcon from '../../assets/technicIcon.webp';
import ftbIcon from '../../assets/ftbIcon.webp';
import TechnicModpacks from './TechnicModpacks';

const Content = ({
in: inProp,
Expand Down Expand Up @@ -49,6 +48,11 @@ const Content = ({
setVersion={setVersion}
setStep={setStep}
setModpack={setModpack}
/>,
<TechnicModpacks
setVersion={setVersion}
setStep={setStep}
setModpack={setModpack}
/>
];

Expand Down Expand Up @@ -103,8 +107,18 @@ const Content = ({
/>
CurseForge
</Radio.Button>
{/* <Radio.Button value={3} disabled>ATLauncher</Radio.Button>
<Radio.Button value={4} disabled>Technic</Radio.Button> */}
{/* <Radio.Button value={3} disabled>ATLauncher</Radio.Button> */}
<Radio.Button value={4}>
<img
src={technicIcon}
css={`
margin-right: 4px;
cursor: pointer;
width: 20px;
`}
/>
Technic
</Radio.Button>
<Radio.Button value={3}>
<img
src={ftbIcon}
Expand Down
Loading