Skip to content

Commit

Permalink
Start of Error Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Mar 27, 2023
1 parent f072336 commit 75313c5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
29 changes: 24 additions & 5 deletions src/Api/updatePortfolioActivitySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,40 @@
} elseif (!array_key_exists('imagePath', $_POST)) {
$success = false;
$message = 'Missing imagePath';
}
}


$portfolioCourseId = '';

$doenetId = mysqli_real_escape_string($conn, $_POST['doenetId']);
$label = mysqli_real_escape_string($conn, $_POST['label']);
$imagePath = mysqli_real_escape_string($conn, $_POST['imagePath']);
$public = mysqli_real_escape_string($conn, $_POST['public']);
$learningOutcomes = mysqli_real_escape_string(
$conn,
$_POST['learningOutcomes']
);

$isPublic = '0';
if ($public) {
$isPublic = '1';
}
$learningOutcomes = mysqli_real_escape_string(
$conn,
$_POST['learningOutcomes']
);

//TODO: Make this a handler function fail(message,code);

if (trim($label) == ''){
http_response_code(400);

echo json_encode([
'success' => false,
'message' => "Label can't be blank.",
]);

$conn->close();
exit();
}



$sql = "
SELECT courseId
Expand Down Expand Up @@ -89,6 +106,8 @@
'portfolioCourseId' => $portfolioCourseId,
];



// set response code - 200 OK
http_response_code(200);

Expand Down
6 changes: 5 additions & 1 deletion src/Tools/_framework/Paths/PortfolioActivitySettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export async function action({ request, params }) {

const formData = await request.formData();
let updates = Object.fromEntries(formData);
console.log("update settings updates",updates)
let response = await axios.post("/api/updatePortfolioActivitySettings.php",{
...updates, doenetId:params.doenetId
})
Expand Down Expand Up @@ -50,6 +49,11 @@ export async function loader({ params }){
return data.activityData;
}

export async function ErrorBoundry(whatdoIget){
console.log("whatdoIget",whatdoIget)
return <p>Error</p>
}

const MainGrid = styled.div`
display:grid;
grid-template-rows: auto 10px [slot1-start] 40px [slot1-end] 20px [slot2-start] min-content [slot2-end] 20px [slot3-start] 40px [slot3-end] 10px auto;
Expand Down
6 changes: 5 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import DarkmodeController from './Tools/_framework/DarkmodeController';
import Community from "./Tools/_framework/Paths/Community";
import {loader as siteLoader, SiteHeader} from "./Tools/_framework/Paths/SiteHeader";
import {loader as caroselLoader, Home} from "./Tools/_framework/Paths/Home";
import {loader as portfolioActivitySettingsLoader, action as portfolioActivitySettingsAction, PortfolioActivitySettings} from "./Tools/_framework/Paths/PortfolioActivitySettings";
import {loader as portfolioActivitySettingsLoader,
action as portfolioActivitySettingsAction,
ErrorBoundry as portfolioActivitySettingsError,
PortfolioActivitySettings} from "./Tools/_framework/Paths/PortfolioActivitySettings";
import {loader as portfolioLoader, action as portfolioAction, Portfolio } from "./Tools/_framework/Paths/Portfolio";
import { loader as portfolioEditorMenuCapLoader } from "./Tools/_framework/MenuPanelCaps/PortfilioEditorInfoCap";
import { loader as publicPortfolioLoader, PublicPortfolio } from "./Tools/_framework/Paths/PublicPortfolio";
Expand Down Expand Up @@ -103,6 +106,7 @@ const router = createBrowserRouter([
path: "/portfolio/:doenetId/settings",
loader: portfolioActivitySettingsLoader,
action: portfolioActivitySettingsAction,
ErrorBoundary: portfolioActivitySettingsError,
element: <RecoilRoot><PortfolioActivitySettings /></RecoilRoot>,
},
{
Expand Down

0 comments on commit 75313c5

Please sign in to comment.