Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monique/time fix #98

Merged
merged 4 commits into from
Apr 23, 2024
Merged
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
37 changes: 19 additions & 18 deletions src/app/orderConfirmationDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ export default function OrderConfirmationDelivery() {
const searchParams = useSearchParams();
const orderIDFromSearch = searchParams.get('orderID');
const [delivTimes, setDelivTimes] = useState<DeliveryTimes[]>([]);
const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];

useEffect(() => {
async function fetchProducts() {
const cartItems = (await fetchCartItemsWithQuantityByID(
Expand Down Expand Up @@ -76,24 +91,10 @@ export default function OrderConfirmationDelivery() {
function organizeDelivTime() {
const userGrp = user?.delivery_group == null ? 1 : user?.delivery_group;
const Time = delivTimes[userGrp]?.delivery_time.toLocaleString();
const date =
Time == null ? ['0', '0', '0'] : Time?.substring(0, 10).split('-');
const months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];

const dateStr = `${months[Number(date[1]) - 1]} ${date[2]}, ${date[0]}`;
const res: Date = new Date(Time);
const dateStr = `${
months[res.getMonth() - 1]
} ${res.getDate()}, ${res.getFullYear()}`;
return `${dateStr}`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/orderPage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function OrderPage() {
<CenterDiv>
<PageDiv>
<BackButtonDiv>
<BackButton destination="./storefront" />
<BackButton destination="./orderHistory" />
</BackButtonDiv>
<BottomColumnDiv>
<LeftColumnDiv>
Expand Down
45 changes: 19 additions & 26 deletions src/app/orderPageDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,30 @@ export default function OrderPageDelivery() {
function organizeDelivTime() {
const userGrp = user?.delivery_group == null ? 1 : user?.delivery_group;
const Time = delivTimes[userGrp]?.delivery_time.toLocaleString();
const date =
Time == null ? ['0', '0', '0'] : Time?.substring(0, 10).split('-');
const dateStr = `${months[parseInt(date[1], 10) - 1]} ${date[2]}, ${
date[0]
}`;
const res: Date = new Date(Time);
const dateStr = `${
months[res.getMonth() - 1]
} ${res.getDate()}, ${res.getFullYear()}`;
return `${dateStr}`;
}

function organizeOrderDate() {
const Time = order?.created_at.toLocaleString();
const date =
Time == null ? ['0', '0', '0'] : Time?.substring(0, 10).split('-');
const dateStr = `${months[parseInt(date[1], 10) - 1]} ${date[2]}, ${
date[0]
}`;
return `${dateStr}`;
}

function organizeOrderTime() {
const Time = order?.created_at.toLocaleString();

const Time =
order?.created_at == null ? 1 : order?.created_at.toLocaleString();
const res: Date = new Date(Time);
const dateStr = `${
months[res.getMonth() - 1]
} ${res.getDate()}, ${res.getFullYear()}`;
let ampm = 'AM';
const date =
Time == null ? ['00', '00'] : Time?.substring(11, 16).split(':');

if (parseInt(date[0], 10) >= 12) {
date[0] = (parseInt(date[0], 10) - 12).toLocaleString();
let hour = res.getHours();
if (hour > 12) {
hour -= 12;
ampm = 'PM';
} else if (hour === 12) {
ampm = 'PM';
}
const timeStr = `${date[0]}:${date[1]} ${ampm}`;
return `${timeStr}`;
const timeStr = `${hour}:${res.getMinutes()} ${ampm}`;
return [dateStr, timeStr];
}

return (
Expand All @@ -157,8 +150,8 @@ export default function OrderPageDelivery() {
<BackButton destination="./orderHistory" />
<Heading2Bold>Order No. {orderIDFromSearch}</Heading2Bold>
<OutterFavoriteDiv>
<Body1>Order Date: {organizeOrderDate()}</Body1>
<Body1>Order Time: {organizeOrderTime()}</Body1>
<Body1>Order Date: {organizeOrderDate()[0]}</Body1>
<Body1>Order Time: {organizeOrderDate()[1]}</Body1>
<ScrollDiv>
{orders.map(product => (
<FavoriteDiv key={product.id}>
Expand Down
2 changes: 2 additions & 0 deletions src/app/storefront/StoreFrontNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export default function StoreFrontNavBar(props: {
const [buttonDisplay, setButtonDisplay] = useState<StorefrontButtons[]>([]);
const [ind, setInd] = useState(0);
let newInd = 0;
const reachedSt = true;
const reachedE = false;
const [reachedStart, setReachedStart] = useState(false);
const [reachedEnd, setReachedEnd] = useState(true);

Expand Down
Loading