Skip to content

Commit

Permalink
Merge branch 'main' into producer-job-view
Browse files Browse the repository at this point in the history
  • Loading branch information
alderwhiteford authored Dec 8, 2023
2 parents c98f093 + 44aac7f commit a21a224
Show file tree
Hide file tree
Showing 27 changed files with 877 additions and 308 deletions.
6 changes: 3 additions & 3 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func RegisterHandlers(e *echo.Echo, dbClient *mongo.Client, logger *pterm.Logger
authMiddleware := func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
nonAuthRoutes := map[string]string{
"/api/users": "POST",
"/api/auth/login": "POST",
"/api/auth/google-provider": "POST",
"/api/users": "POST",
"/api/auth/login": "POST",
"/api/auth/google-provider": "POST",
"/api/payment/create-checkout-session": "POST",
}

Expand Down
1 change: 1 addition & 0 deletions backend/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (

// A 3D printer
type Printer struct {
Name string `bson:"name,omitempty" json:"name,omitempty"`
SupportedFilament []FilamentType `bson:"supportedFilament,omitempty" json:"supportedFilament,omitempty"`
Dimensions Dimensions `bson:"dimensions,omitempty" json:"dimensions,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ export type CheckoutState = {

export type CheckoutSessionData = {
client_secret: string;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function JobViewDesigner({ jobId } : JobViewDesignerProps) {
{job?.shippingAddress.city}, {job?.shippingAddress.state}
</>
)

const trackingNumber = job?.tracking === "" ? 'No Information' : job?.tracking
const estimatedDelivery = () => {
const date = new Date(job?.createdAt as Date)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { designApi } from "../../../../api/api";
import Divider from "@mui/material/Divider";
import DownloadIcon from "@mui/icons-material/Download";
import IconButton from "@mui/material/IconButton";
import { saveAs } from "file-saver";
import StyledButton from "../../../Button/Button";

export default function DesignInfo(props: {
designId: string;
Expand All @@ -12,22 +12,23 @@ export default function DesignInfo(props: {

return (
<div>
<Divider variant="middle" className=" py-3" />
<Divider variant="middle" className="py-3 !m-0"/>
<div className=" py-3" />
<div className=" flex justify-between py-1">
<p>Filename (temp designId)</p>
<div className=" flex flex-row">
<p>{props.designId}</p>
<div className="flex justify-between py-1 items-center">
<p>Files</p>
<div className="flex flex-row items-center">
{data && (
<IconButton
<StyledButton
color="seconday"
size='sm'
onClick={() => saveAs(data, `voxeti-${props.designId}.stl`)}
>
<DownloadIcon fontSize="small" />
</IconButton>
</StyledButton>
)}
</div>
</div>
<div className=" flex justify-between py-1">
<div className=" flex justify-between py-1 mt-6">
<p>Quantity</p>
<p>{props.quantity} piece(s)</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ export default function DesignerName(props: { designerId: string; job?: Job }) {
<div className=" flex flex-row">
{data ? (
<Avatar
className={` outline outline-3 outline-offset-2 ${
className={`outline outline-4 outline-offset-2 !w-24 !h-24 ${
data.userType == "DESIGNER"
? "outline-designer"
: "outline-producer"
}`}
alt={`${data.firstName} ${data.lastName}`}
sx={{ width: 64, height: 64 }}
/>
>
{data.firstName.charAt(0)}
</Avatar>
) : (
<Skeleton variant="circular" width={64} height={64} />
)}
{data ? (
<div className=" px-4 flex flex-col justify-center">
<div className="ml-5 px-4 flex flex-col justify-center">
<p className=" text-lg">
{data && data.firstName} {data && data.lastName}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function FieldValueRow(props: {
}) {
return (
<div className=" flex flex-col">
<Divider variant="middle" className=" py-3" />
<Divider variant="middle" className="!m-0 py-3" />
<div className=" py-3" />
{props.section.map((row) => (
<div className=" flex justify-between py-1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from "react";
import { Job } from "../../../../main.types";
import { Button, createTheme, ThemeProvider } from "@mui/material";
import { createTheme, ThemeProvider } from "@mui/material";
import { jobApi } from "../../../../api/api";
import { useStateSelector } from "../../../../hooks/use-redux";
import { useApiError } from "../../../../hooks/use-api-error";
import StyledButton from "../../../Button/Button";

declare module "@mui/material/styles" {
interface Palette {
Expand Down Expand Up @@ -87,35 +88,33 @@ export default function JobAcceptButtons(props: { currentJob: Job }) {
if (jobStatus.toUpperCase() === "PENDING") {
return (
<ThemeProvider theme={theme}>
<div className=" flex flex-row flex-wrap items-center justify-end gap-y-1 gap-x-2">
<Button
variant="contained"
color="black"
className=" w-32"
<div className="flex flex-row items-center justify-end gap-y-1 gap-x-2">
<StyledButton
color="primary"
onClick={acceptJob}
size="md"
>
Accept
</Button>
<Button
variant="outlined"
color="black"
className=" w-32"
</StyledButton>
<StyledButton
color="seconday"
href="/jobs"
onClick={declineJob}
size="md"
>
Decline
</Button>
</StyledButton>
</div>
</ThemeProvider>
);
} else {
return (
<ThemeProvider theme={theme}>
<div className=" flex flex-row flex-wrap items-center justify-end gap-y-1 gap-x-4">
<p className=" text-producer">JOB ACCEPTED</p>
<Button href="/jobs" variant="outlined" color="black" className="">
<div className=" flex flex-row items-center justify-end gap-y-1 gap-x-2">
<StyledButton color="success" size="md">Job Accepted</StyledButton>
<StyledButton href="/jobs" color="seconday" size="md">
Current Jobs
</Button>
</StyledButton>
</div>
</ThemeProvider>
);
Expand Down
133 changes: 133 additions & 0 deletions frontend/src/components/Profile/EditAddresses.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { Address, User } from "../../main.types";
import React from "react";
import FieldValuePairs from "./FieldValuePairs";
import EditSaveButton from "./EditSaveButton";
import SelectionButton from "./SelectionButton";
import StyledButton from "../Button/Button";

export default function EditAddresses(props: {
currentSection: string;
setSection: (section: string) => void;
addresses?: Address[];
index: number;
setIndex: (section: number) => void;
saveEdit: (body: Partial<User>) => void;
}) {
const [currentAddresses, setCurrentAddresses] = React.useState<Address[]>(
props.addresses ? props.addresses.map((a: Address) => ({ ...a })) : []
);

const section: string = "addresses";
const editing: boolean = props.currentSection == section;

const changeFieldValue = (key: string, value: string) => {
if (editing) {
const tempAddress = { ...currentAddresses[props.index] };
switch (key) {
case "Name":
tempAddress.name = value;
break;
case "Line 1":
tempAddress.line1 = value;
break;
case "Line 2":
tempAddress.line2 = value;
break;
case "City":
tempAddress.city = value;
break;
case "State":
tempAddress.state = value;
break;
case "Zipcode":
tempAddress.zipCode = value;
break;
case "Country":
tempAddress.country = value;
break;
}
currentAddresses[props.index] = tempAddress;
setCurrentAddresses(currentAddresses);
}
};

const AddressForm = (props: { index: number }) => {
const shippingInfo: [string, string?, string?][][] = [
[["Name", currentAddresses[props.index]?.name]],
[
["Line 1", currentAddresses[props.index]?.line1],
["Line 2", currentAddresses[props.index]?.line2],
],
[
["City", currentAddresses[props.index]?.city],
["State", currentAddresses[props.index]?.state],
],
[
["Zipcode", currentAddresses[props.index]?.zipCode],
["Country", currentAddresses[props.index]?.country],
],
];

return (
<FieldValuePairs
rows={shippingInfo}
edit={editing}
updateFields={changeFieldValue}
/>
);
};

return (
<div>
{props.index !== currentAddresses.length ? (
<div className="flex h-full flex-row items-center justify-center sm:justify-between flex-wrap">
<AddressForm index={props.index} />
<div className=" flex items-center">
<EditSaveButton
edit={editing}
onSave={() => props.saveEdit({ addresses: currentAddresses })}
onStart={() => props.setSection(section)}
/>
</div>
</div>
) : (
<div className="flex h-full flex-col items-center justify-center">
<div className=" py-8">
<StyledButton
size={"sm"}
color={"seconday"}
type="submit"
onClick={() => {
const addressesCopy = [...currentAddresses];
addressesCopy.push({
name: "",
line1: "",
zipCode: "",
city: "",
state: "",
country: "",
});

setCurrentAddresses(addressesCopy);
}}
>
Add Address
</StyledButton>
</div>
</div>
)}

<SelectionButton
currentIndex={props.index}
maxIndex={currentAddresses.length}
display={currentAddresses[props.index]?.name || "Add New Address"}
onChange={(delta: number) => {
props.setSection(
props.index + delta === currentAddresses.length ? section : ""
);
props.setIndex(props.index + delta);
}}
/>
</div>
);
}
51 changes: 51 additions & 0 deletions frontend/src/components/Profile/EditLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";
import FieldValuePairs from "./FieldValuePairs";
import EditSaveButton from "./EditSaveButton";
import { User } from "../../main.types";

export default function EditLogin(props: {
currentSection: string;
setSection: (section: string) => void;
email: string;
socialProvider: string;
saveEdit: (body: Partial<User>) => void;
}) {
const [newEmail, setNewEmail] = React.useState(props.email);
const [newPassword, setNewPassword] = React.useState("");

const section: string = "login";
const nonSSO: boolean = props.socialProvider == "NONE";
const editing: boolean = props.currentSection == section;

const loginInfo: [string, string, string?][][] = [
[["Email", newEmail]],
[["Password", editing ? "" : "****************", "password"]],
];

return (
<div className="flex h-full flex-row flex-wrap justify-center sm:justify-between">
<FieldValuePairs
rows={nonSSO ? loginInfo : [loginInfo[0]]}
edit={editing}
updateFields={(key, value) => {
key === "Password" ? setNewPassword(value) : setNewEmail(value);
}}
/>
<div className=" flex items-center">
{nonSSO && (
<EditSaveButton
edit={editing}
onSave={() =>
props.saveEdit(
newPassword !== ""
? { email: newEmail, password: newPassword }
: { email: newEmail }
)
}
onStart={() => props.setSection(section)}
/>
)}
</div>
</div>
);
}
Loading

0 comments on commit a21a224

Please sign in to comment.