hitbox for nav and standardizing api call format

This commit is contained in:
Martina 2020-11-27 17:30:40 -08:00
parent 579e879571
commit 396130ff64
5 changed files with 30 additions and 23 deletions

View File

@ -139,28 +139,28 @@ export const search = async (data) => {
export const createPendingFiles = async (data) => {
return await returnJSON(`/api/data/create-pending`, {
...DEFAULT_OPTIONS,
body: JSON.stringify(data),
body: JSON.stringify({ data }),
});
};
export const processPendingFiles = async (data) => {
export const processPendingFiles = async () => {
return await returnJSON(`/api/data/process-pending`, {
...DEFAULT_OPTIONS,
body: JSON.stringify(data),
body: JSON.stringify(),
});
};
export const addFileToSlate = async (data) => {
return await returnJSON(`/api/slates/add-url`, {
...DEFAULT_OPTIONS,
body: JSON.stringify(data),
body: JSON.stringify({ data }),
});
};
export const updateViewer = async (data) => {
return await returnJSON(`/api/users/update`, {
...DEFAULT_OPTIONS,
body: JSON.stringify(data),
body: JSON.stringify({ data }),
});
};

View File

@ -186,8 +186,12 @@ export default class ApplicationHeader extends React.Component {
return (
<header css={STYLES_APPLICATION_HEADER}>
<div css={STYLES_LEFT}>
<span css={STYLES_ICON_ELEMENT} style={{ position: "relative" }}>
<SVG.Menu height="24px" onClick={() => this._handleTogglePopup("nav")} />
<span
css={STYLES_ICON_ELEMENT}
style={{ position: "relative" }}
onClick={() => this._handleTogglePopup("nav")}
>
<SVG.Menu height="24px" />
{this.state.popup === "nav" ? (
<Boundary
captureResize={true}

View File

@ -8,7 +8,7 @@ export default async (req, res) => {
return res.status(500).send({ decorator: "CREATE_PENDING_ERROR", error: true });
}
const response = await Data.createPendingData(req.body.data);
const response = await Data.createPendingData(req.body.data.data);
if (!response) {
return res.status(404).send({ decorator: "CREATE_PENDING_ERROR", error: true });

View File

@ -30,7 +30,7 @@ export default async (req, res) => {
});
}
const slate = await Data.getSlateById({ id: req.body.slate.id });
const slate = await Data.getSlateById({ id: req.body.data.slate.id });
if (!slate) {
return res.status(404).send({
@ -47,14 +47,14 @@ export default async (req, res) => {
}
let newObjects = [];
if (Array.isArray(req.body.data)) {
newObjects = [...req.body.data];
if (Array.isArray(req.body.data.data)) {
newObjects = [...req.body.data.data];
} else {
newObjects = [req.body.data];
newObjects = [req.body.data.data];
}
let slateURLs = slate.data.objects.map((file) => file.url);
let addlObjects;
if (req.body.fromSlate) {
if (req.body.data.fromSlate) {
let newURLs = [];
addlObjects = newObjects.filter((each) => {
if (slateURLs.includes(each.url) || newURLs.includes(each.url)) {
@ -100,7 +100,7 @@ export default async (req, res) => {
cid: cid,
size: each.size,
id: each.id,
ownerId: req.body.fromSlate ? each.ownerId : user.id,
ownerId: req.body.data.fromSlate ? each.ownerId : user.id,
name: each.name,
title: each.title,
type: each.type,

View File

@ -28,9 +28,9 @@ export default async (req, res) => {
let unsafeResponse;
if (req.body.username) {
if (req.body.data.username) {
const existing = await Data.getUserByUsername({
username: req.body.username.toLowerCase(),
username: req.body.data.username.toLowerCase(),
});
if (existing && existing.id !== id) {
@ -38,7 +38,7 @@ export default async (req, res) => {
}
}
if (req.body.type === "SAVE_DEFAULT_ARCHIVE_CONFIG") {
if (req.body.data.type === "SAVE_DEFAULT_ARCHIVE_CONFIG") {
let b;
try {
b = await Utilities.getBucketAPIFromUserToken({
@ -59,7 +59,10 @@ export default async (req, res) => {
}
try {
const configResponse = await b.buckets.setDefaultArchiveConfig(b.bucketKey, req.body.config);
const configResponse = await b.buckets.setDefaultArchiveConfig(
b.bucketKey,
req.body.data.config
);
} catch (e) {
console.log(e);
Social.sendTextileSlackMessage({
@ -74,14 +77,14 @@ export default async (req, res) => {
}
}
if (req.body.type == "CHANGE_PASSWORD") {
if (!Validations.password(req.body.password)) {
if (req.body.data.type == "CHANGE_PASSWORD") {
if (!Validations.password(req.body.data.password)) {
return res.status(500).send({ decorator: "SERVER_INVALID_PASSWORD", error: true });
}
const rounds = Number(Environment.LOCAL_PASSWORD_ROUNDS);
const salt = await BCrypt.genSalt(rounds);
const hash = await Utilities.encryptPassword(req.body.password, salt);
const hash = await Utilities.encryptPassword(req.body.data.password, salt);
unsafeResponse = await Data.updateUserById({
id: user.id,
@ -91,8 +94,8 @@ export default async (req, res) => {
} else {
unsafeResponse = await Data.updateUserById({
id: user.id,
username: req.body.username ? req.body.username.toLowerCase() : user.username,
data: { ...user.data, ...req.body.data },
username: req.body.data.username ? req.body.data.username.toLowerCase() : user.username,
data: { ...user.data, ...req.body.data.data },
});
}